:root {
  --bg: #0c1018;
  --bg-elevated: #111827;
  --surface: #1a2332;
  --surface-2: #222d3f;
  --surface-hover: #2a3649;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #eef2f7;
  --text-muted: #94a3b8;
  --accent: #4f9cf9;
  --accent-2: #38bdf8;
  --accent-hover: #3b82f6;
  --accent-glow: rgba(79, 156, 249, 0.28);
  --self-bg: linear-gradient(135deg, #3b82f6 0%, #38bdf8 100%);
  --self-bg-solid: #3b82f6;
  --system-bg: #1e293b;
  --success: #2dd4bf;
  --warn: #fbbf24;
  --danger: #fb7185;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.2);
  --sidebar-w: 280px;
  --blur: blur(20px);
}

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

.hidden { display: none !important; }

html, body {
  height: 100%;
  font-family: 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 0% -20%, rgba(79, 156, 249, 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(56, 189, 248, 0.08), transparent 50%),
    var(--bg);
  overflow: hidden;
}

::selection {
  background: rgba(124, 140, 255, 0.35);
  color: #fff;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hover) transparent;
}
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-hover);
  border-radius: 99px;
}
*::-webkit-scrollbar-track { background: transparent; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.screen { display: none !important; height: 100%; width: 100%; }
.screen.active { display: flex !important; }

/* Login */
#login-screen.active {
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(165deg, rgba(26, 35, 50, 0.96) 0%, rgba(17, 24, 39, 0.98) 100%);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-extra-block {
  margin-top: 14px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.15);
  overflow: hidden;
}
.login-extra-block summary {
  padding: 11px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}
.login-extra-block summary::-webkit-details-marker { display: none; }
.login-extra-block summary::after {
  content: '›';
  float: right;
  font-size: 1rem;
  opacity: 0.5;
  transition: transform 0.2s;
}
.login-extra-block[open] summary::after { transform: rotate(90deg); }
.login-extra-block summary:hover { color: var(--text); background: var(--surface-hover); }
.login-extra-block .login-invite,
.login-extra-block .login-download {
  margin-top: 0;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
}
.login-extra-block .login-download { border-top: none; padding-top: 0; }

.login-brand { margin-bottom: 8px; }
.logo-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 8px 28px var(--accent-glow);
}
.app-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.logo { font-size: 48px; margin-bottom: 16px; }
.login-card h1 {
  font-size: 1.65rem;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 20px; line-height: 1.5; }

.login-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}
.login-download {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.login-download-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 8px;
}
.btn-small.disabled,
.btn-small:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.promo-section .promo-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 10px 0 0;
  text-align: center;
}
.promo-section .promo-stats strong {
  color: var(--accent-soft, #a78bfa);
}
.download-app-section code {
  font-size: 0.7rem;
  color: var(--muted);
}

.login-invite {
  text-align: center;
}
.invite-section .invite-qr-box,
.login-invite {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.invite-qr-box {
  width: 100%;
  max-width: 240px;
  margin: 12px auto;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(79, 156, 249, 0.28);
}
.invite-qr-img {
  display: block;
  width: 200px;
  height: 200px;
  max-width: 100%;
  margin: 0 auto;
  border-radius: 14px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}
.login-invite .invite-qr-img {
  width: 160px;
  height: 160px;
}

.login-admin-link {
  margin-top: 18px;
  text-align: center;
  font-size: 0.85rem;
}
.login-admin-link a {
  color: var(--text-muted);
  text-decoration: none;
}
.login-admin-link a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.app-download-setup-hint {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-muted);
}
.app-download-setup-hint strong { color: var(--warn); }
.app-download-setup-hint code {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text);
}
.invite-link-input {
  width: 100%;
  margin: 10px 0 8px;
  padding: 10px 12px;
  font-size: 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--text-muted);
  font-family: ui-monospace, Consolas, monospace;
  transition: border-color 0.15s, background 0.15s;
}
.invite-link-input:focus {
  outline: none;
  border-color: rgba(79, 156, 249, 0.45);
  background: rgba(0, 0, 0, 0.35);
}
.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}
.invite-actions .btn-small {
  border-radius: 12px;
  min-height: 40px;
}
.invite-actions .btn-small.primary {
  flex: 1;
  min-width: 100px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.login-tags span {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(79, 156, 249, 0.08);
  border: 1px solid rgba(79, 156, 249, 0.15);
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.auth-error {
  font-size: 0.85rem;
  color: var(--danger);
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  text-align: left;
}
.auth-error.hidden { display: none; }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}
.auth-form.hidden { display: none; }

.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label span { font-size: 0.85rem; color: var(--text-muted); }
.auth-form input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}
.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.auth-form button {
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--accent-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.auth-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px var(--accent-glow);
}
.auth-form button:active { transform: translateY(0); }

/* App layout */
#app-screen.active {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  flex-direction: row;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.3);
}

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 10px 0;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.55) 0%, rgba(15, 23, 42, 0.75) 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.sidebar-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  margin: -4px -6px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.sidebar-user-main:hover { background: var(--surface-hover); }

.sidebar-user-text { min-width: 0; }
.sidebar-user-text strong {
  display: block;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.coin-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(245, 158, 11, 0.08));
  color: #fcd34d;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.15);
}
.coin-pill:hover {
  background: rgba(251, 191, 36, 0.22);
  transform: scale(1.03);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  font-size: 1.2rem;
  box-shadow: 0 3px 10px var(--accent-glow);
}

.online-dot { font-size: 0.7rem; color: var(--success); display: block; margin-top: 2px; }

.btn-icon {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0%, transparent 100%);
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
}
.tab-icon {
  font-size: 1.15rem;
  line-height: 1;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.18s, transform 0.15s, box-shadow 0.18s, border-color 0.18s;
}
.tab-label { line-height: 1.2; font-weight: 500; letter-spacing: 0.02em; }
.tab:hover { color: var(--text); }
.tab:hover .tab-icon {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(79, 156, 249, 0.2);
}
.tab.active {
  color: var(--text);
  font-weight: 600;
  background: rgba(79, 156, 249, 0.07);
  border-color: rgba(79, 156, 249, 0.15);
}
.tab.active .tab-icon {
  background: linear-gradient(145deg, rgba(79, 156, 249, 0.45), rgba(56, 189, 248, 0.22));
  border-color: rgba(79, 156, 249, 0.35);
  box-shadow: 0 4px 14px var(--accent-glow);
  transform: translateY(-1px);
}

.tab-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  margin-left: 0;
  background: var(--warn);
  color: #000;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}
.tab-badge.hidden { display: none; }
.tab-badge-secondary {
  background: var(--danger);
  color: #fff;
  right: auto;
  left: 50%;
  top: 0;
  transform: translateX(6px);
}

.item-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}

.panel {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.panel.hidden { display: none; }

.panel-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.panel-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 12px 0 8px;
  font-weight: 500;
}

.user-list { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s ease;
  border: 1px solid transparent;
}
.user-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.user-item:active { transform: scale(0.99); }

.item-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.sidebar-user .avatar {
  overflow: hidden;
}

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.bubble.msg-recalled {
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  padding: 4px 0;
}

.msg-meta-muted {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.item-name { flex: 1; font-size: 0.9rem; font-weight: 500; }
.item-info { flex: 1; min-width: 0; }
.item-info .item-name { display: block; }
.item-id { font-size: 0.7rem; color: var(--text-muted); display: block; overflow: hidden; text-overflow: ellipsis; }

.item-status { font-size: 0.7rem; color: var(--text-muted); }
.item-status.online { color: var(--success); }
.item-tag { font-size: 0.7rem; color: var(--accent); }

.request-list { margin-bottom: 8px; }

.request-card {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.request-from { font-weight: 600; margin-bottom: 4px; }
.request-msg { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.request-actions { display: flex; gap: 8px; }

.group-actions { margin-bottom: 8px; }
.join-form {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.join-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
}
.join-form input:focus { border-color: var(--accent); }

.btn-small {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn-small:hover { background: var(--surface-hover); }
.btn-small.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.btn-small.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.greet-btn { margin-left: auto; }

.add-friend-box {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.add-friend-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 8px;
  outline: none;
}
.add-friend-box input:focus { border-color: var(--accent); }

.friend-list-section {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.friend-list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.friend-list-header .panel-title {
  margin: 12px 0 4px;
}
.friend-list-summary {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 12px 0 4px;
}
.friend-list-search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  margin-bottom: 8px;
  outline: none;
}
.friend-list-search:focus {
  border-color: var(--accent);
}
.friend-list-scroll {
  max-height: min(42vh, 320px);
  overflow-y: auto;
  padding-right: 2px;
}
.friend-list-scroll .empty {
  padding: 16px 8px;
  text-align: center;
}
.friend-list-item .item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}
.friend-list-item .item-info {
  flex: 1;
  min-width: 0;
}
.friend-list-item .item-name {
  display: block;
  cursor: inherit;
}

.profile-edit-section .coin-input {
  margin-bottom: 8px;
}
.profile-sig-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: right;
  margin: -4px 0 10px;
}
.profile-edit-section textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  outline: none;
}
.profile-edit-section textarea:focus {
  border-color: var(--accent);
}
.password-section .coin-input {
  margin-bottom: 8px;
}

.profile-role-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 4px;
  background: var(--surface-2);
  color: var(--accent-soft, #a78bfa);
  border: 1px solid var(--border);
}
.profile-role-badge.role-admin {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.35);
}
.profile-role-badge.role-service {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.35);
}

.cs-faq {
  margin: 14px 0 0;
  padding-left: 18px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.6;
}
.cs-inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.cs-inbox-list {
  max-height: min(28vh, 200px);
  overflow-y: auto;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cs-inbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
}
.cs-inbox-item:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.cs-inbox-item.unread {
  border-color: rgba(124, 92, 255, 0.45);
}
.cs-last-msg {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.cs-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cs-lookup-result {
  margin: 8px 0 12px;
}
.cs-lookup-card {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
}
.cs-lookup-card .btn-small {
  margin-top: 8px;
}
.cs-admin-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.cs-recharge-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 280px;
  overflow-y: auto;
}
.cs-recharge-item {
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(251, 191, 36, 0.25);
  background: rgba(251, 191, 36, 0.06);
}
.cs-recharge-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.cs-recharge-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.cs-recharge-msg {
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.cs-recharge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.recharge-contact-card {
  margin: 10px 0 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(79, 156, 249, 0.22);
  background: linear-gradient(165deg, rgba(79, 156, 249, 0.1), rgba(15, 23, 42, 0.5));
}
.recharge-contact-note {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.recharge-contact-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recharge-contact-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}
.recharge-contact-row strong {
  color: var(--text);
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-all;
  text-align: right;
}
.recharge-message-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  margin-bottom: 10px;
}
.recharge-message-input:focus {
  outline: none;
  border-color: rgba(79, 156, 249, 0.45);
}
.recharge-modal-box {
  max-width: 420px;
}
.required-mark {
  color: var(--danger);
}

.panel-hint,
.my-id-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.4;
}
.my-id-hint {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--accent-soft, #a78bfa);
}

.my-id-display {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 10px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.my-id-display strong {
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text);
  letter-spacing: 0.05em;
}
.btn-tiny {
  padding: 4px 10px;
  font-size: 0.72rem;
  border-radius: 8px;
  border: 1px solid rgba(79, 156, 249, 0.25);
  background: rgba(79, 156, 249, 0.1);
  color: var(--accent-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-tiny:hover {
  border-color: var(--accent);
  color: var(--text);
}

.item-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.item-actions .btn-small { padding: 4px 8px; font-size: 0.7rem; }

.search-results { margin-top: 12px; }
.search-results.hidden { display: none; }

.balance-pop {
  animation: balancePop 0.5s ease;
}
@keyframes balancePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); color: var(--success); }
  100% { transform: scale(1); }
}

/* 钱包 */
.wallet-card {
  text-align: center;
  padding: 24px 20px;
  margin-bottom: 14px;
  background: linear-gradient(145deg, #d97706 0%, #fbbf24 50%, #fde68a 100%);
  border-radius: var(--radius-lg);
  color: #1c1917;
  box-shadow: 0 8px 28px rgba(251, 191, 36, 0.25);
}
.wallet-label { font-size: 0.85rem; opacity: 0.85; }
.wallet-balance { display: block; font-size: 2rem; font-weight: 700; margin-top: 4px; }
.wallet-cash-line {
  font-size: 0.8rem;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.wallet-cash-line strong { color: var(--success); font-size: 1.1rem; }
.wallet-cash-line .muted { font-size: 0.7rem; color: var(--text-muted); }

.money-section {
  margin: 16px 0;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.recharge-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.recharge-pkg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
.recharge-pkg:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.recharge-pkg .pkg-main { font-size: 1.25rem; font-weight: 700; color: var(--warn); }
.recharge-pkg .pkg-bonus { font-size: 0.72rem; color: var(--success); }
.recharge-pkg .pkg-unit { font-size: 0.7rem; color: var(--text-muted); }
.recharge-custom {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.recharge-custom .coin-input { flex: 1; margin-bottom: 0; }
.coin-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  margin-bottom: 8px;
}
#checkin-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.wallet-logs { list-style: none; max-height: 200px; overflow-y: auto; }
.wallet-log {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.wallet-log .log-amt { font-weight: 600; }
.wallet-log.income .log-amt { color: var(--success); }
.wallet-log.expense .log-amt { color: #f87171; }
.wallet-log .log-time {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.gift-bubble {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(180, 83, 9, 0.2)) !important;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.transfer-bubble {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.2), rgba(34, 197, 94, 0.15)) !important;
  border: 1px solid rgba(74, 222, 128, 0.35);
}

.redpacket-bubble {
  min-width: 200px;
  padding: 14px !important;
  text-align: center;
  cursor: default;
  background: linear-gradient(145deg, #dc2626, #b91c1c) !important;
  color: #fff !important;
  border: none !important;
}
.redpacket-bubble.rp-empty { opacity: 0.65; filter: grayscale(0.3); }
.redpacket-bubble.rp-done { background: linear-gradient(145deg, #9ca3af, #6b7280) !important; }
.rp-icon { font-size: 2rem; }
.rp-msg { font-weight: 600; margin: 6px 0; }
.rp-meta { font-size: 0.75rem; opacity: 0.9; }
.rp-grab-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: #fbbf24;
  color: #1a1a1a;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.rp-grab-btn.hidden { display: none; }
.rp-status { margin-top: 8px; font-size: 0.85rem; }
.rp-status.hidden { display: none; }

.modal-fields.hidden { display: none; }
.modal-fields .coin-input { margin-bottom: 8px; }

.gift-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.gift-amounts.hidden { display: none; }
.gift-amounts button {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--warn);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.gift-amounts button.active {
  border-color: var(--warn);
  background: rgba(251, 191, 36, 0.15);
}
.modal-extra {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.modal-extra.hidden { display: none; }

/* 通讯录 */
.contacts-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.contacts-view.hidden { display: none; }

.contacts-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.contacts-sidebar {
  width: 280px;
  min-width: 240px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.contacts-search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.contacts-search-wrap input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.contacts-search-wrap input:focus { border-color: var(--accent); }

.contacts-summary {
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.contacts-letter {
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--bg);
  position: sticky;
  top: 0;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.contact-item:hover { background: var(--surface-hover); }
.contact-item.active {
  background: rgba(124, 140, 255, 0.18);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.contact-av {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name {
  display: block;
  font-weight: 500;
  font-size: 0.95rem;
}
.contact-sig {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}
.contact-dot.online { background: var(--success); }

.contact-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}

.contact-detail-empty {
  text-align: center;
  color: var(--text-muted);
}
.contact-detail-empty.hidden { display: none; }

.contact-detail-body {
  width: 100%;
  max-width: 360px;
}
.contact-detail-body.hidden { display: none; }

.contact-detail-header {
  text-align: center;
  margin-bottom: 24px;
}
.cd-avatar { font-size: 4rem; display: block; margin-bottom: 12px; }
.contact-detail-header h2 { font-size: 1.4rem; margin-bottom: 6px; }
.cd-status {
  display: inline-block;
  font-size: 0.8rem;
  padding: 2px 10px;
  border-radius: 12px;
  background: var(--surface-hover);
  color: var(--text-muted);
}
.cd-status.online { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.cd-signature {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.contact-detail-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  margin-bottom: 20px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row span:first-child { color: var(--text-muted); }

.contact-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-action {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-action:hover { border-color: var(--accent); }
.btn-action.primary {
  grid-column: 1 / -1;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 720px) {
  .contacts-layout { flex-direction: column; }
  .contacts-sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 8px;
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 100% 100%, rgba(79, 156, 249, 0.05), transparent 45%),
    var(--bg);
  min-width: 0;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 32px 24px;
  color: var(--text-muted);
}
.chat-empty .muted { font-size: 0.88rem; max-width: 300px; text-align: center; line-height: 1.55; }

.welcome-hero {
  text-align: center;
  padding: 28px 32px;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(79, 156, 249, 0.08) 0%, transparent 60%);
  border: 1px solid var(--border);
  max-width: 360px;
}
.welcome-icon-wrap {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(79, 156, 249, 0.25), rgba(56, 189, 248, 0.12));
  border: 1px solid rgba(79, 156, 249, 0.2);
  box-shadow: 0 8px 24px var(--accent-glow);
}
.welcome-hero h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 420px;
}
.quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, color 0.15s;
}
.quick-card:hover {
  border-color: rgba(79, 156, 249, 0.4);
  background: var(--surface-2);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.quick-card .qc-icon {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--surface-2);
}

.chat-active {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-active.hidden { display: none; }
.chat-active.secure-chat {
  position: relative;
}
.secure-chat-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.25);
}
.chat-screenshot-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}
.chat-screenshot-watermark-inner {
  position: absolute;
  width: 220%;
  height: 220%;
  top: -60%;
  left: -60%;
  transform: rotate(-24deg);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 36px 56px;
  padding: 20px;
  opacity: 0.1;
}
.chat-screenshot-watermark-inner span {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.secure-chat .messages,
.secure-chat .bubble,
.secure-chat .msg-image,
.secure-chat .msg-video {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.secure-chat-blur .messages {
  filter: blur(14px);
  transition: filter 0.15s ease;
}

/* 手机聊天：挂到 body 上全屏显示，避免侧栏布局导致黑屏 */
#chat-active.mobile-chat-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  top: env(safe-area-inset-top, 0) !important;
  bottom: env(safe-area-inset-bottom, 0) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100dvh !important;
  z-index: 500 !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bg) !important;
  min-height: 0 !important;
  margin: 0 !important;
  border: none !important;
}
#chat-active.mobile-chat-fullscreen .messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#chat-active.mobile-chat-fullscreen .chat-footer {
  flex-shrink: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(21, 25, 34, 0.88);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  flex-shrink: 0;
}

.chat-header h2 { font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em; }

.header-info {
  flex: 1;
  min-width: 0;
}

.chat-back-btn {
  flex-shrink: 0;
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-ghost {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.badge.hidden { display: none; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { max-width: min(78%, 420px); animation: fadeIn 0.22s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.msg.self { align-self: flex-end; }
.msg.self .bubble {
  background: var(--self-bg);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 16px rgba(90, 108, 232, 0.35);
}
.msg.other { align-self: flex-start; }
.msg.other .bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.system { align-self: center; max-width: 100%; }
.msg.system .bubble {
  background: var(--system-bg);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 20px;
}

.msg-meta { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.msg.self .msg-meta { text-align: right; }
.msg-send-pending .bubble { opacity: 0.72; }
.msg-send-failed .bubble {
  border: 1px solid rgba(239, 68, 68, 0.65);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.15);
}
.msg-send-hint {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #f87171;
  text-align: right;
  cursor: pointer;
  user-select: none;
}
.msg-send-hint:hover { text-decoration: underline; }
.bubble {
  padding: 11px 15px;
  border-radius: 16px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 0.94rem;
}
.msg-link {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}
.msg-link:hover {
  opacity: 0.85;
}
.msg.self .msg-link {
  color: #dbeafe;
}
.bubble-copyable {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}
.bubble-copyable.bubble-pressed {
  outline: 2px solid rgba(79, 156, 249, 0.55);
  transform: scale(0.98);
}

.typing {
  padding: 0 20px 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}
.typing.hidden { visibility: hidden; }

.chat-footer {
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: rgba(21, 25, 34, 0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.greeting-quick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.greeting-quick.hidden { display: none; }
.greeting-quick button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
}
.greeting-quick button:hover { border-color: var(--accent); color: var(--accent); }

#message-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
}
#message-input {
  flex: 1;
  padding: 10px 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  outline: none;
}
#message-input::placeholder { color: var(--text-muted); }
#message-input:focus { outline: none; }
#message-form:focus-within {
  border-color: rgba(124, 140, 255, 0.5);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
#send-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.12s ease;
}
#send-btn:hover { transform: scale(1.05); }
#send-btn:active { transform: scale(0.96); }

.input-mode-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  align-self: center;
}
.input-mode-btn.active {
  border-color: var(--accent);
  background: rgba(79, 156, 249, 0.15);
}

.voice-hold-btn {
  flex: 1;
  min-height: 42px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.voice-hold-btn.hidden { display: none; }
.voice-hold-btn:active,
.voice-hold-btn.voice-hold-active {
  background: rgba(79, 156, 249, 0.2);
  color: var(--accent-2);
}

.tool-btn.active {
  border-color: var(--accent);
  background: rgba(79, 156, 249, 0.15);
}

#message-input.hidden,
#send-btn.hidden {
  display: none;
}

/* Modal & toast */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 26px;
  width: 90%;
  max-width: 380px;
  box-shadow: var(--shadow);
  animation: modalIn 0.22s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.modal-box h3 { margin-bottom: 16px; }
.modal-box input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  margin-bottom: 16px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 33, 48, 0.95);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 200;
  font-size: 0.88rem;
  font-weight: 500;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.hidden { display: none; }

.notify-banner {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  max-width: 420px;
  margin: 0 auto;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(79, 156, 249, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  animation: notify-slide-in 0.28s ease;
}
.notify-banner.hidden { display: none; }
.notify-banner-body { flex: 1; min-width: 0; }
.notify-banner-body strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 4px;
}
.notify-banner-body p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  word-break: break-word;
}
.notify-banner-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--accent);
}
.notify-banner-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}
.notify-banner-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}
@keyframes notify-slide-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 我的 */
#panel-me {
  padding: 10px 14px 28px;
  background:
    radial-gradient(ellipse 90% 40% at 50% -10%, rgba(79, 156, 249, 0.1), transparent 55%),
    transparent;
}

.profile-card {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: 0 18px 22px;
  margin-bottom: 14px;
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.92) 0%, rgba(15, 23, 42, 0.96) 100%);
  border: 1px solid rgba(79, 156, 249, 0.18);
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.profile-card::before {
  content: '';
  display: block;
  height: 80px;
  margin: 0 -18px 0;
  background:
    linear-gradient(135deg, rgba(79, 156, 249, 0.42) 0%, rgba(56, 189, 248, 0.18) 40%, rgba(167, 139, 250, 0.22) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.profile-avatar-big {
  position: relative;
  z-index: 1;
  width: 76px;
  height: 76px;
  margin: -38px auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  line-height: 1;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(34, 45, 63, 0.95), rgba(26, 35, 50, 0.98));
  border: 3px solid rgba(79, 156, 249, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#profile-name-display {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.profile-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
}
.profile-stats span {
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 500;
}
.me-balance-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(245, 158, 11, 0.06));
  border: 1px solid rgba(251, 191, 36, 0.25);
}
.me-balance-line strong {
  font-size: 1.4rem;
  color: #fcd34d;
  font-weight: 700;
}
.me-section {
  margin-top: 12px;
  padding: 16px 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(26, 35, 50, 0.65) 0%, rgba(17, 24, 39, 0.88) 100%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}
.me-section .panel-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  letter-spacing: 0.02em;
}
.me-section .panel-hint {
  margin-bottom: 10px;
  line-height: 1.55;
}
.promo-section .promo-stats {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(79, 156, 249, 0.08);
  border: 1px solid rgba(79, 156, 249, 0.15);
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  cursor: pointer;
}
.setting-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
#sidebar-wallet-btn.hidden-by-setting { display: none !important; }
.profile-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 12px 0 8px;
}
#profile-signature {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  resize: none;
  outline: none;
}
.btn-small.full { width: 100%; margin-top: 12px; padding: 10px; }

.emoji-grid, .emoji-picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.emoji-grid.small { grid-template-columns: repeat(6, 1fr); max-height: 120px; }
.emoji-item {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}
.emoji-item:hover { background: var(--surface-hover); }

.emoji-picker {
  margin-bottom: 10px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.emoji-picker.hidden { display: none; }

/* 聊天工具栏 */
.chat-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding: 6px;
  background: var(--surface-2);
  border-radius: 14px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.chat-toolbar.hidden { display: none; }
.tool-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
}
.tool-btn:hover {
  background: var(--surface-hover);
  transform: scale(1.06);
}
.tool-btn-clear {
  width: auto;
  min-width: 38px;
  padding: 0 10px;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.tool-btn-clear:hover {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.12);
}
#clear-chat-toolbar-btn.hidden { display: none; }
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
#video-call-btn.hidden,
#clear-chat-btn.hidden { display: none; }

.sub-card {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.confirm-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* 消息媒体 */
.media-bubble { padding: 8px !important; min-width: 200px; }
.media-bubble audio { width: 100%; max-width: 240px; height: 36px; }
.msg-video {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
}
.media-label { font-size: 0.75rem; color: var(--text-muted); display: block; margin-top: 4px; }
.emoji-bubble { font-size: 2.5rem; line-height: 1.2; padding: 8px 14px !important; }

/* 语音录制 / 通话 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.overlay.hidden { display: none; }
.overlay-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  min-width: 280px;
}
.record-pulse {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 1s infinite;
}
.record-pulse.record-cancel {
  background: #ef4444;
  animation: none;
  transform: scale(1.05);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
}
.voice-timer { font-size: 1.5rem; font-weight: 600; margin: 8px 0 12px; }
.voice-cancel-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.voice-cancel-hint.voice-cancel-active {
  color: #ef4444;
  font-weight: 600;
}
.voice-record-box { min-width: 260px; }

.voice-msg-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  padding: 10px 12px !important;
}
.voice-play-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
}
.msg.other .voice-play-btn {
  background: rgba(79, 156, 249, 0.15);
  color: var(--accent);
}
.voice-wave-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  height: 22px;
}
.voice-wave-bar {
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.45;
}
.voice-msg-bubble.voice-playing .voice-wave-bar {
  animation: voiceWave 0.8s ease-in-out infinite;
}
.voice-msg-bubble.voice-playing .voice-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-msg-bubble.voice-playing .voice-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-msg-bubble.voice-playing .voice-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-msg-bubble.voice-playing .voice-wave-bar:nth-child(5) { animation-delay: 0.4s; }
@keyframes voiceWave {
  0%, 100% { height: 8px; opacity: 0.45; }
  50% { height: 18px; opacity: 1; }
}
.voice-duration {
  font-size: 0.8rem;
  opacity: 0.85;
  flex-shrink: 0;
}
.voice-audio-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}
.overlay-actions { display: flex; gap: 12px; justify-content: center; }

.call-container {
  position: relative;
  width: 90vw;
  max-width: 800px;
  height: 70vh;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
}
#call-remote {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#call-local {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--border);
}
.call-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-call {
  padding: 10px 24px;
  border: none;
  border-radius: 24px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn-call.hangup { background: #ef4444; color: #fff; }
.incoming-title { font-size: 1.1rem; margin-bottom: 8px; }
.incoming-name { font-size: 1.5rem; font-weight: 600; margin-bottom: 24px; }

.sidebar-user { cursor: pointer; }

.runtime-badge {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.runtime-badge #runtime-mode.h5plus,
#runtime-mode.h5plus {
  color: var(--success);
}
.server-url-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  margin-bottom: 8px;
}
.server-url-input.hidden,
.profile-label.hidden,
#save-settings-btn.hidden { display: none; }

/* 空间 */
.space-select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  margin-bottom: 8px;
}

.space-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.space-view.hidden { display: none; }

.space-top { flex-shrink: 0; border-bottom: 1px solid var(--border); }
.space-cover {
  background: linear-gradient(135deg, #4f5fd4 0%, #7c8cff 45%, #a78bfa 100%);
  padding: 24px 20px;
}
.space-profile { display: flex; align-items: center; gap: 14px; }
.space-avatar-big {
  font-size: 48px;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.space-top h2 { font-size: 1.2rem; }
.space-sig { font-size: 0.85rem; opacity: 0.9; margin-top: 4px; }

.space-tabs {
  display: flex;
  background: var(--surface);
}
.space-tab {
  flex: 1;
  padding: 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.space-tab.active {
  color: #c4cdff;
  border-bottom-color: var(--accent);
  font-weight: 600;
  background: rgba(124, 140, 255, 0.06);
}

.space-composer {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.space-composer.hidden { display: none; }
#post-text {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  resize: none;
  margin-bottom: 8px;
}
.post-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.preview-item {
  position: relative;
  width: 72px;
  height: 72px;
}
.preview-item img, .preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.preview-item button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.composer-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.space-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.space-post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.post-avatar { font-size: 1.8rem; }
.post-head time { display: block; font-size: 0.75rem; color: var(--text-muted); }
.post-del { margin-left: auto; }
.post-text { line-height: 1.5; margin-bottom: 10px; white-space: pre-wrap; }

.post-images {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}
.post-images.grid-1 { grid-template-columns: 1fr; }
.post-images.grid-2 { grid-template-columns: 1fr 1fr; }
.post-images.grid-3 { grid-template-columns: repeat(3, 1fr); }
.post-images img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
}
.post-videos { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.post-video-item {
  max-width: 100%;
  max-height: 240px;
  border-radius: 8px;
}
.post-foot { padding-top: 8px; border-top: 1px solid var(--border); }
.like-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
  font-size: 0.9rem;
}
.like-btn.liked { color: #f472b6; }

.album-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.album-item {
  position: relative;
  aspect-ratio: 1;
  cursor: pointer;
  overflow: hidden;
  border-radius: 8px;
}
.album-item img { width: 100%; height: 100%; object-fit: cover; }
.album-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 0.65rem;
  padding: 4px;
  background: rgba(0,0,0,0.5);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.video-grid-item video {
  width: 100%;
  border-radius: 8px;
  max-height: 180px;
}
.video-grid-item span { font-size: 0.75rem; color: var(--text-muted); }

.space-link-btn { flex-shrink: 0; }

.msg-image {
  max-width: 240px;
  max-height: 280px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}

#lightbox-img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 8px;
}
#lightbox-video {
  max-width: 90vw;
  max-height: 85vh;
}
#lightbox-video.hidden, #lightbox-img.hidden { display: none; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 10;
}

/* App / 手机全屏聊天（JS 加 body.mobile-chat-open，不依赖视口宽度） */
body.mobile-chat-open {
  overflow: hidden;
}
body.mobile-chat-open #app-screen {
  position: fixed;
  inset: 0;
  top: env(safe-area-inset-top, 0);
  bottom: env(safe-area-inset-bottom, 0);
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
  border: none;
  box-shadow: none;
  flex-direction: column;
  z-index: 100;
}
body.mobile-chat-open #app-screen .sidebar {
  display: none !important;
}
body.mobile-chat-open #app-screen .chat-area {
  display: flex !important;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}
body.mobile-chat-open #app-screen .chat-active:not(.hidden) {
  display: flex !important;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}
body.mobile-chat-open #chat-back-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}

@media (max-width: 720px) {
  html, body {
    min-height: 100%;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
  }
  #app-screen {
    flex-direction: column;
    border: none;
    max-width: 100%;
    box-shadow: none;
    height: 100%;
    min-height: 0;
  }
  .sidebar {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  /* 侧栏功能页：占满屏幕，主区域不显示「开始聊天」 */
  #app-screen[data-tab="greeting"] .sidebar,
  #app-screen[data-tab="friends"] .sidebar,
  #app-screen[data-tab="groups"] .sidebar,
  #app-screen[data-tab="wallet"] .sidebar,
  #app-screen[data-tab="service"] .sidebar,
  #app-screen[data-tab="me"] .sidebar {
    flex: 1;
    max-height: none;
    border-bottom: none;
  }
  #app-screen[data-tab="greeting"] .chat-area,
  #app-screen[data-tab="friends"] .chat-area,
  #app-screen[data-tab="groups"] .chat-area,
  #app-screen[data-tab="wallet"] .chat-area,
  #app-screen[data-tab="service"] .chat-area,
  #app-screen[data-tab="me"] .chat-area {
    display: none;
  }

  /* 手机打开聊天：全屏显示聊天区 */
  #app-screen[data-tab="chat"],
  body.mobile-chat-open #app-screen {
    position: fixed;
    inset: 0;
    top: env(safe-area-inset-top, 0);
    bottom: env(safe-area-inset-bottom, 0);
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    margin: 0;
    z-index: 100;
  }
  #app-screen[data-tab="chat"] .sidebar,
  body.mobile-chat-open #app-screen .sidebar {
    display: none;
  }
  #app-screen[data-tab="chat"] .chat-area,
  body.mobile-chat-open #app-screen .chat-area {
    display: flex !important;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  #app-screen[data-tab="chat"] .chat-active:not(.hidden),
  body.mobile-chat-open #app-screen .chat-active:not(.hidden) {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
  }
  #app-screen[data-tab="chat"] #chat-back-btn,
  body.mobile-chat-open #chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  #app-screen[data-tab="contacts"] #chat-back-btn,
  #app-screen[data-tab="space"] #chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #panel-friends .friend-list-scroll {
    max-height: none;
  }

  #app-screen[data-tab="greeting"] .panel:not(.hidden),
  #app-screen[data-tab="friends"] .panel:not(.hidden),
  #app-screen[data-tab="groups"] .panel:not(.hidden),
  #app-screen[data-tab="wallet"] .panel:not(.hidden),
  #app-screen[data-tab="service"] .panel:not(.hidden),
  #app-screen[data-tab="me"] .panel:not(.hidden) {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 通讯录 / 空间：主区域全屏，侧栏只保留顶栏与 Tab */
  #app-screen[data-tab="contacts"] .sidebar,
  #app-screen[data-tab="space"] .sidebar {
    flex: 0 0 auto;
    max-height: none;
  }
  #app-screen[data-tab="contacts"] #panel-contacts,
  #app-screen[data-tab="space"] #panel-space {
    display: none !important;
  }
  #app-screen[data-tab="contacts"] .chat-area,
  #app-screen[data-tab="space"] .chat-area {
    flex: 1;
    min-height: 0;
  }

  /* 默认：上栏 + 下方聊天区 */
  #app-screen:not([data-tab]) .sidebar,
  #app-screen[data-tab=""] .sidebar {
    max-height: 38vh;
  }

  .tabs {
    grid-template-columns: repeat(4, 1fr);
    padding: 8px 10px 10px;
    gap: 5px;
    flex-shrink: 0;
  }
  .tab {
    padding: 7px 2px;
    font-size: 0.62rem;
    border-radius: 12px;
  }
  .tab-icon {
    width: 34px;
    height: 34px;
    font-size: 1.05rem;
  }
  .sidebar-user {
    flex-shrink: 0;
    margin: 8px 8px 0;
    padding: 10px;
  }
  #panel-me {
    padding: 8px 12px 24px;
  }
  .profile-card {
    border-radius: 18px;
  }
  .me-section {
    border-radius: 16px;
    padding: 14px;
  }
  .quick-actions {
    max-width: 100%;
    gap: 8px;
    grid-template-columns: repeat(3, 1fr);
  }
  .quick-card { padding: 14px 8px; }
  .login-card { padding: 32px 22px 24px; }
  .welcome-hero { padding: 22px 20px; }
  #call-local { width: 80px; height: 60px; }
}

.trade-lock-hint {
  color: #c77800;
}

.vip-card {
  border: 1px solid rgba(212, 175, 55, 0.35);
  background: linear-gradient(135deg, rgba(255, 248, 220, 0.5), rgba(255, 255, 255, 0.8));
}

.vip-benefits {
  margin: 8px 0 12px;
  padding-left: 18px;
  color: var(--text-muted, #666);
  font-size: 13px;
  line-height: 1.6;
}

.profile-vip-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #8a6d00;
  background: linear-gradient(135deg, #ffe082, #ffd54f);
  vertical-align: middle;
}

.profile-vip-badge.hidden {
  display: none;
}

.group-vip-hint {
  color: #c77800;
}

.group-members-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.group-member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border, #eee);
}

.group-member-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.group-member-name {
  font-weight: 600;
}

.group-member-status {
  font-size: 12px;
  color: var(--text-muted, #888);
}

.btn-kick-member {
  flex-shrink: 0;
  color: #c62828;
  border-color: rgba(198, 40, 40, 0.35);
}

.chat-lock-warn {
  color: #c62828;
}

.chat-lock-modal-box .coin-input {
  width: 100%;
  margin-bottom: 8px;
}

.chat-lock-section {
  border-top: 1px solid var(--border, #eee);
  padding-top: 12px;
}

.group-chat-banners {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, #e8e8ef);
  background: var(--surface, #fafafa);
}

.group-chat-banners.hidden {
  display: none;
}

.group-announcement-bar,
.group-pinned-bar,
.group-mute-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
}

.group-announcement-bar.hidden,
.group-pinned-bar.hidden,
.group-mute-bar.hidden {
  display: none;
}

.group-mute-bar {
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  font-size: 13px;
}

.official-group-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  vertical-align: middle;
}

.chat-footer.chat-muted .chat-toolbar {
  opacity: 0.45;
  pointer-events: none;
}

.group-banner-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #5a6ce8;
  border-radius: 4px;
  padding: 2px 6px;
  margin-top: 2px;
}

.group-pinned-bar .group-banner-label {
  background: #e6a817;
}

.group-announcement-text {
  margin: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text, #333);
  white-space: pre-wrap;
  word-break: break-word;
}

.group-pinned-jump {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.group-pinned-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #666);
}

.group-pinned-text {
  font-size: 13px;
  color: var(--text, #333);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.msg.msg-pinned .bubble {
  box-shadow: 0 0 0 2px rgba(230, 168, 23, 0.45);
}

.msg.msg-pinned-flash .bubble {
  animation: pinFlash 1.2s ease;
}

@keyframes pinFlash {
  0%, 100% { box-shadow: 0 0 0 2px rgba(230, 168, 23, 0.45); }
  50% { box-shadow: 0 0 0 4px rgba(230, 168, 23, 0.75); }
}

.msg-action-menu {
  position: fixed;
  z-index: 1200;
  min-width: 120px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.msg-action-menu.hidden {
  display: none;
}

.msg-action-menu button {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
}

.msg-action-menu button:hover {
  background: var(--surface-2, #f3f4f8);
}

.msg-forward-tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  opacity: 0.85;
}

.forward-modal-box {
  max-width: 420px;
}
.forward-preview {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.forward-target-list {
  max-height: 280px;
  overflow-y: auto;
  margin: 10px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.forward-target-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
}
.forward-target-item:hover {
  border-color: var(--accent);
  background: rgba(79, 156, 249, 0.08);
}
.forward-target-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
}
.forward-target-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.forward-empty {
  text-align: center;
  padding: 16px 0;
}
