* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --brand: #10b981;
  --brand-dark: #059669;
  --brand-light: #6ee7b7;
  --brand-bg: #ecfdf5;
  --bubble-mine: #95ec69;
  --bubble-mine-border: #7ed957;
  --sidebar: #f7f8fa;
  --sidebar-hover: #eef0f4;
  --sidebar-active: #e3e6ec;
  --chat-bg: #f0f2f5;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-light: #f0f0f0;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
}

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'SF Pro Text', 'Microsoft YaHei', sans-serif;
  background: var(--chat-bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
}

.screen { height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ===== Icons ===== */
.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }
.icon-xl { width: 56px; height: 56px; }
.icon-xxl { width: 80px; height: 80px; opacity: 0.85; }
.app-logo { display: block; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(4, 78, 56, 0.18)); }
.app-logo-xl { width: 56px; height: 56px; }
.app-logo-xxl { width: 80px; height: 80px; opacity: 0.92; }

/* ===== 登录页 ===== */
.auth-screen {
  position: relative;
  align-items: center;
  justify-content: center;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(16,185,129,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(5,150,105,0.1) 0%, transparent 50%),
    linear-gradient(160deg, #f0fdf4 0%, #ecfdf5 40%, #f0f2f5 100%);
}

.login-card {
  position: relative;
  background: var(--surface);
  border-radius: 16px;
  padding: 44px 40px 36px;
  width: 400px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.8);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(47, 50, 65, 0.35));
}

.login-card h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--chat-bg);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 9px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--surface);
  color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fafbfc;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
  transition: var(--transition);
}

.login-card input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16,185,129,0.35);
}

.btn-primary:active { transform: translateY(0); }

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.error-msg { color: var(--danger); font-size: 13px; margin-top: 12px; }

.auth-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: var(--brand-dark);
  margin: -12px 0 20px;
  min-height: 20px;
}

.auth-status::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(16, 185, 129, 0.25);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: auth-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.auth-server-link {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s;
}

.auth-server-link:hover { color: var(--brand-dark); }

#login-form .auth-server-link {
  display: block;
  width: 100%;
  margin-top: 8px;
}

body.reset-page {
  height: auto;
  min-height: 100vh;
  overflow: auto;
}

.reset-page .auth-screen {
  min-height: 100vh;
  padding: 24px 16px;
}

.reset-card {
  text-align: left;
  width: min(400px, 100%);
}

.reset-card .login-logo,
.reset-card h1,
.reset-card .login-sub {
  text-align: center;
}

.reset-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 0 0 6px;
}

.reset-verified {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-bg);
  color: var(--brand-dark);
  font-size: 13px;
}

.reset-card .reset-code-row {
  margin-bottom: 12px;
}

.reset-card .reset-code-row input {
  margin-bottom: 0;
}

.reset-ok-msg {
  color: var(--brand-dark);
}

/* ===== 主布局 ===== */
#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#app-screen > .guardian-banner {
  flex-shrink: 0;
}

.guardian-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  font-size: 13px;
  font-weight: 500;
}

.guardian-banner.hidden { display: none; }

#app-screen.guardian-mode .chat-input {
  opacity: 0.55;
  pointer-events: none;
}

.guardian-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
}

.guardian-list-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.guardian-list-item.has-actions {
  padding-bottom: 12px;
}

.guardian-list-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.guardian-list-info {
  flex: 1;
  min-width: 0;
}

.guardian-list-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.guardian-list-name {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guardian-role-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--text-secondary);
  background: var(--sidebar-bg);
}

.guardian-role-badge.is-primary {
  color: var(--brand-dark);
  background: var(--brand-bg);
}

.guardian-list-side {
  flex-shrink: 0;
  margin-left: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.guardian-text-btn {
  border: none;
  background: none;
  padding: 4px 2px;
  font-size: 13px;
  font-family: inherit;
  color: var(--danger);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.3;
}

.guardian-text-btn.is-neutral {
  color: var(--text-secondary);
}

.guardian-text-btn.is-neutral:hover {
  color: var(--brand-dark);
}

.guardian-text-btn:hover {
  color: #dc2626;
  text-decoration: underline;
}

.guardian-list-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.guardian-list-actions:has(> :nth-child(2):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.guardian-list-actions:has(> :only-child) {
  grid-template-columns: 1fr;
}

.guardian-list-actions .btn-ghost,
.guardian-list-actions .btn-danger-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  padding: 7px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.guardian-co-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.guardian-co-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guardian-co-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.guardian-list-item.is-compact {
  padding: 8px 10px;
  background: var(--sidebar-bg);
  border-color: transparent;
  box-shadow: none;
}

.guardian-list-item.is-compact .guardian-list-name {
  font-size: 14px;
  font-weight: 500;
}

.guardian-manage-card {
  width: 440px;
  max-width: calc(100vw - 32px);
  padding: 22px 22px 18px;
}

.guardian-manage-card .guardian-list {
  max-height: none;
  overflow: visible;
}

.guardian-manage-card h3 {
  margin-bottom: 16px;
}

.guardian-manage-section {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

#guardian-manage-child-section:not(.hidden) {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}

.guardian-manage-section .modal-label {
  margin-bottom: 10px;
}

.guardian-list:has(.guardian-list-item) + .guardian-bind-panel {
  margin-top: 12px;
}

.guardian-bind-panel {
  padding: 12px;
  background: var(--sidebar-bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.guardian-bind-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.guardian-bind-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 0;
}

.guardian-bind-row input {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 40px;
  margin-bottom: 0;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 40px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.guardian-bind-row input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.guardian-bind-row input::placeholder {
  color: var(--text-muted);
}

.guardian-bind-btn {
  flex-shrink: 0;
  height: 40px;
  min-width: 96px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  line-height: 1;
  color: var(--brand-dark);
  background: var(--brand-bg);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.guardian-bind-btn:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.guardian-bind-btn:active {
  transform: scale(0.98);
}

.guardian-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--sidebar-bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border-light);
}

.guardian-manage-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.guardian-manage-footer .btn-primary {
  width: auto;
  min-width: 108px;
  padding: 9px 24px;
}

.guardian-ring-btn {
  color: #b45309;
  border-color: #fcd34d;
  background: #fffbeb;
}

.guardian-ring-btn:hover {
  background: #fef3c7;
  border-color: #fbbf24;
}

.guardian-ring-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.guardian-ring-overlay.hidden {
  display: none;
}

.guardian-ring-card {
  width: min(100%, 360px);
  padding: 32px 28px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
  text-align: center;
}

.guardian-ring-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: guardian-ring-pulse 1.2s ease-in-out infinite;
}

@keyframes guardian-ring-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.45); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 14px rgba(251, 191, 36, 0); }
}

.guardian-ring-card h2 {
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--text);
}

.guardian-ring-desc {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.guardian-ring-desc span {
  color: var(--text);
  font-weight: 600;
}

.guardian-ring-dismiss {
  width: 100%;
}

.link-pending-url {
  font-size: 13px;
  color: var(--brand-dark);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
  word-break: break-all;
  text-align: left;
}

.msg-text .msg-link {
  color: var(--brand-dark);
  text-decoration: underline;
  cursor: pointer;
}

.msg-text .msg-link:hover {
  color: var(--brand);
}

.link-access-item {
  flex-wrap: wrap;
  align-items: flex-start;
}

.link-access-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.link-access-child {
  font-size: 14px;
  font-weight: 500;
}

.link-access-url {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msg-bubble-link-access {
  min-width: 220px;
  max-width: min(320px, 88vw);
}

.link-access-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-access-msg-title {
  font-size: 13px;
  font-weight: 600;
}

.link-access-msg-url {
  font-size: 13px;
  word-break: break-all;
  line-height: 1.45;
}

.link-access-msg-status {
  font-size: 12px;
  color: var(--text-muted);
}

.link-access-msg-status.status-approved {
  color: #2e9f4b;
}

.link-access-msg-status.status-denied {
  color: #d64545;
}

.link-access-msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.link-access-msg-actions .btn-accept,
.link-access-msg-actions .btn-reject {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
}

.logout-access-item .link-access-url {
  -webkit-line-clamp: 1;
}

.btn-danger-ghost {
  background: none;
  color: #ef4444;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-danger-ghost:hover { background: #fef2f2; }

.modal-actions .btn-danger-ghost { width: auto; }

.modal-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.sidebar {
  width: 280px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 12px;
  position: relative;
  min-height: 52px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  flex: 1;
  min-width: 0;
}

.sidebar-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.sidebar-top-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: var(--sidebar-hover);
  color: var(--brand-dark);
}

/* 头像 */
.wx-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.02em;
}

.wx-avatar.lg { width: 44px; height: 44px; font-size: 17px; border-radius: var(--radius); }
.wx-avatar.md { width: 48px; height: 48px; font-size: 18px; border-radius: var(--radius); }
.wx-avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.wx-avatar.group {
  background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
  font-size: 13px;
}

.wx-avatar.has-image {
  background: #e5e7eb !important;
  padding: 0;
  overflow: hidden;
}

.wx-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.avatar-btn.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.avatar-preview-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 16px;
}

.avatar-preview {
  width: 120px !important;
  height: 120px !important;
  font-size: 42px !important;
  border-radius: 16px !important;
}

.avatar-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}

.avatar-modal-actions .btn-ghost {
  width: auto;
  padding: 8px 16px;
}

/* 下拉菜单 */
.dropdown {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 50;
  min-width: 160px;
  overflow: hidden;
  padding: 6px;
}

.dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.dropdown button:hover { background: var(--sidebar-hover); }

.menu-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  cursor: default;
  user-select: none;
}

.menu-status-row .icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.menu-status-value {
  margin-left: auto;
  font-size: 12px;
  color: var(--text);
}

.menu-status-row .status-dot {
  flex-shrink: 0;
}

.status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 0 2px var(--sidebar), 0 0 6px rgba(239, 68, 68, 0.4);
}

.status-dot.connecting {
  background: #f59e0b;
  animation: status-pulse 1.2s ease-in-out infinite;
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#add-menu { top: 60px; right: 16px; }
.dropdown-up { bottom: 52px; right: 12px; }
#logout-btn { color: var(--danger) !important; }
#logout-btn:hover { background: #fef2f2 !important; }

/* 搜索 */
.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 10px;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 32px 9px 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  outline: none;
  color: var(--text);
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.1);
}

.search-input::placeholder { color: var(--text-muted); }

.search-input[type="search"]::-webkit-search-decoration,
.search-input[type="search"]::-webkit-search-cancel-button,
.search-input[type="search"]::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #d1d5db;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.search-clear-btn .icon {
  width: 12px;
  height: 12px;
}

.search-clear-btn:hover { background: #9ca3af; }

.search-cancel-btn {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--brand-dark);
  font-size: 14px;
  padding: 6px 2px;
  cursor: pointer;
  font-family: inherit;
}

.search-cancel-btn:hover { color: var(--brand); }

.sidebar.searching .request-bar,
.sidebar.searching #chat-list,
.sidebar.searching #contacts-list {
  display: none !important;
}

.global-search-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.global-search-home,
.global-search-chat-list,
.chat-search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.global-search-home::-webkit-scrollbar,
.global-search-chat-list::-webkit-scrollbar,
.chat-search-results::-webkit-scrollbar { width: 4px; }
.global-search-home::-webkit-scrollbar-thumb,
.global-search-chat-list::-webkit-scrollbar-thumb,
.chat-search-results::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.global-search-chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.global-search-chat-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
}

.global-search-chat-header h3 {
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-empty-hint,
.search-empty-result {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.search-section-title {
  padding: 10px 18px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--sidebar);
  position: sticky;
  top: 0;
  z-index: 1;
}

.search-hit {
  color: var(--brand);
  font-style: normal;
  font-weight: 600;
}

.search-msg-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 0 4px 2px;
}

.search-msg-item:hover { background: var(--sidebar-hover); }

.search-msg-item .wx-avatar { flex-shrink: 0; }

.search-msg-body { flex: 1; min-width: 0; }

.search-msg-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.search-msg-name {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-msg-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-msg-snippet {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-more-hint {
  color: var(--text-secondary);
}

.chat-item-chevron {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.chat-search-panel {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: var(--chat-bg);
  display: flex;
  flex-direction: column;
}

.chat-search-panel.hidden { display: none; }

.chat-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-search-header .search-field { flex: 1; }

.chat-search-results {
  padding: 8px 0;
}

.chat-search-results .search-msg-item:hover {
  background: var(--surface);
}

/* 底部主导航 */
.main-tab-bar {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.main-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
}

.main-tab .icon {
  width: 24px;
  height: 24px;
}

.main-tab:hover { color: var(--text-secondary); }

.main-tab.active {
  color: var(--brand-dark);
}

/* 我的 */
.profile-panel {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 12px;
  background: var(--sidebar);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 20px 16px;
  margin-bottom: 8px;
  background: var(--surface);
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: var(--transition);
}

.profile-header:hover { background: var(--sidebar-hover); }

.profile-header-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-sub {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
  font-weight: 300;
}

.profile-menu-group {
  margin-bottom: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: var(--transition);
  border-bottom: 1px solid var(--border-light);
}

.profile-menu-item:last-child { border-bottom: none; }

.profile-menu-item:hover { background: var(--sidebar-hover); }

.profile-menu-item.danger { color: #ef4444; }

.profile-menu-item .icon {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.profile-menu-item.danger .icon { color: #ef4444; }

.profile-menu-item > span:first-of-type,
.profile-menu-item > span:nth-child(2) {
  flex: 1;
}

.profile-menu-static {
  cursor: default;
  pointer-events: none;
}

.profile-menu-static:hover { background: transparent; }

.profile-menu-value {
  font-size: 13px;
  color: var(--text-muted);
  flex: 0 0 auto !important;
}

.profile-menu-static .status-dot {
  flex-shrink: 0;
  margin-left: 6px;
}

/* 通讯录 */
.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  -webkit-user-select: none;
  user-select: none;
}

.contacts-list::-webkit-scrollbar { width: 4px; }
.contacts-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.contacts-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
}

.contacts-section-title:hover { background: var(--sidebar-hover); }

.contacts-section-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  margin-right: 2px;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.contacts-section-title.collapsed .contacts-section-chevron {
  transform: rotate(-90deg);
}

.contacts-section-label { flex: 1; min-width: 0; }

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-bottom: 2px;
}

.contact-item:hover { background: var(--sidebar-hover); }

.contact-item-body { flex: 1; min-width: 0; }

.contact-item-name {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contact-action .contact-item-name { color: var(--brand-dark); font-weight: 500; }

.contact-action-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.contact-action-icon .icon { width: 20px; height: 20px; }

.contact-action-icon-group {
  background: linear-gradient(135deg, #34d399, #059669);
}

/* 好友请求 */
.request-bar {
  flex-shrink: 0;
  margin: 0 14px 8px;
  padding: 12px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.request-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #b45309;
  margin-bottom: 8px;
}

.request-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
}

.request-item > span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-actions { display: flex; gap: 6px; }

.btn-accept {
  padding: 4px 12px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.btn-reject {
  padding: 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
}

/* 会话列表 */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.chat-list::-webkit-scrollbar { width: 4px; }
.chat-list::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-bottom: 2px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.chat-item:hover { background: var(--sidebar-hover); }
.chat-item.active {
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.chat-item.has-unread .chat-item-name { font-weight: 600; color: var(--text); }
.chat-item-pinned { background: rgba(16, 185, 129, 0.04); }
.chat-item-menu-active,
.contact-item-menu-active { background: var(--sidebar-hover) !important; }

.chat-item-body { flex: 1; min-width: 0; }

.chat-item-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.chat-item-pin {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.7;
}

.chat-item-pin .icon { width: 12px; height: 12px; }

.chat-item-name {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.unread-badge {
  background: var(--danger);
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 9px;
  padding: 0 5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  box-shadow: 0 0 0 2px var(--sidebar);
}

.status-dot.online {
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--sidebar), 0 0 6px rgba(16,185,129,0.5);
}

.empty-tip {
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* 底部栏（已废弃，保留兼容） */
.sidebar-bottom {
  display: none;
}

/* ===== 聊天区域 ===== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  overflow: hidden;
  background: var(--chat-bg);
}

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.empty-chat-logo { filter: drop-shadow(0 8px 24px rgba(16,185,129,0.2)); opacity: 0.7; }
.empty-chat-title { font-size: 22px; font-weight: 600; color: var(--text-secondary); margin-top: 8px; }
.empty-chat-sub { font-size: 14px; color: var(--text-muted); }

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

#chat-pins-btn {
  position: relative;
}

.chat-pins-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
}

.chat-pins-badge.hidden { display: none; }

.pins-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 20;
  display: flex;
  flex-direction: column;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.08);
  animation: pinsSlideIn 0.22s ease;
}

.pins-panel.hidden { display: none; }

@keyframes pinsSlideIn {
  from { transform: translateX(100%); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}

.pins-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.pins-panel-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.pins-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.pins-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.pins-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.15s;
}

.pins-item:hover { background: var(--sidebar-hover); }

.pins-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.pins-item-sender {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pins-item-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.pins-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  word-break: break-word;
}

.pins-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pins-preview-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
}

.pins-preview-empty {
  color: var(--text-muted);
  font-size: 13px;
}

.pins-preview-image {
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--sidebar-bg);
  cursor: zoom-in;
  max-width: 100%;
}

.pins-preview-image img {
  display: block;
  max-width: 100%;
  max-height: 140px;
  object-fit: cover;
  width: 100%;
}

.pins-preview .msg-file {
  background: var(--sidebar-bg);
  cursor: pointer;
}

.pins-preview .msg-file:hover { background: var(--sidebar-hover); }

.pins-preview .msg-audio {
  background: var(--sidebar-bg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.pin-preview-card { width: min(520px, 92vw); }

.pin-preview-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pin-preview-header-info h3 {
  font-size: 15px;
  font-weight: 600;
}

.pin-preview-time {
  font-size: 12px;
  color: var(--text-muted);
}

.pin-preview-body {
  max-height: min(60vh, 480px);
  overflow-y: auto;
  padding: 4px 0 12px;
}

.pin-preview-body .pins-preview-text {
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
  font-size: 14px;
}

.pin-preview-body .pins-preview-image img {
  max-height: min(50vh, 360px);
  object-fit: contain;
  width: auto;
  margin: 0 auto;
}

.pin-preview-body .pins-preview-image {
  display: flex;
  justify-content: center;
}

.pin-preview-actions {
  margin-top: 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.pins-item-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.pins-item-actions .pins-unpin { color: #ef4444; }

.message.is-pinned .msg-bubble {
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.35), var(--shadow-sm);
}

.message.is-pinned .msg-bubble::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f59e0b' stroke-width='2'%3E%3Cpath d='M12 17v5M9 3h6l1 7h4l-5 6v4H9v-4L4 10h4l1-7z'/%3E%3C/svg%3E") center/contain no-repeat;
  opacity: 0.85;
  pointer-events: none;
}

.message .msg-bubble { position: relative; }

.message.message-menu-active .msg-bubble {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
}

.message-highlight {
  animation: pinHighlight 2s ease;
}

@keyframes pinHighlight {
  0%, 100% { background: transparent; }
  15%, 45% { background: rgba(245, 158, 11, 0.12); border-radius: 8px; }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
}

#chat-more-menu {
  top: calc(100% - 4px);
  right: 16px;
}

.dropdown button.danger { color: var(--danger); }
.dropdown button.danger:hover { background: #fef2f2; }

.chat-header-main {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chat-header h2 {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header h2.chat-title-editable {
  cursor: pointer;
  user-select: none;
}

.chat-header h2.chat-title-editable:hover {
  color: var(--brand-dark);
}

.icon-btn-sm {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.chat-tag {
  font-size: 11px;
  color: var(--brand-dark);
  background: var(--brand-bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.chat-tag-btn {
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}

.chat-tag-btn:hover { background: #d1fae5; }

.group-manage-card { width: 420px; }

.group-manage-section { margin-bottom: 8px; }

.group-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.group-manage-label {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.group-manage-value {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-manage-avatar-value {
  overflow: visible;
  display: flex;
  align-items: center;
}

#group-manage-avatar.group-avatar-editable {
  cursor: pointer;
}

.btn-link {
  border: none;
  background: none;
  color: var(--brand-dark);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.btn-link:hover { text-decoration: underline; }

.group-member-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 8px;
  margin-bottom: 16px;
  max-height: 240px;
  overflow-y: auto;
}

.group-member-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.group-member-name {
  font-size: 11px;
  color: var(--text);
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.owner-badge {
  font-size: 10px;
  color: var(--brand-dark);
  background: var(--brand-bg);
  padding: 1px 6px;
  border-radius: 8px;
}

.group-manage-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.group-manage-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}

.btn-block { width: 100%; }

.btn-danger {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-danger:hover { background: #dc2626; }

.btn-danger-ghost {
  background: none;
  color: #ef4444;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-danger-ghost:hover { background: #fef2f2; }

/* 消息区 */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background:
    radial-gradient(circle at 50% 0%, rgba(16,185,129,0.03) 0%, transparent 60%),
    var(--chat-bg);
}

.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 6px; }

.msg-sender {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
  padding-left: 2px;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: min(88%, 400px);
  animation: msgIn 0.25s ease;
}

.message.image-only,
.message.media-only {
  max-width: min(90%, 400px);
}

.message.media-only:has(.msg-audio) {
  max-width: min(92%, 420px);
}

.message.mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.other { align-self: flex-start; }

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
}

.msg-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  max-width: 320px;
}

.message.media-only .msg-main,
.message.image-only .msg-main {
  min-width: auto;
  max-width: none;
}

.message.mine .msg-main { align-items: flex-end; }
.message.other .msg-main { align-items: flex-start; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 4px 12px 12px 12px;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.message.mine .msg-bubble {
  background: var(--bubble-mine);
  border: 1px solid var(--bubble-mine-border);
  border-radius: 12px 4px 12px 12px;
}

.message.other .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border-light);
}

/* 纯图片消息：无内边距，图片贴边圆角；按自身尺寸撑开，避免被 flex 挤成 0 宽 */
.msg-bubble-image {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 8px !important;
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
  flex-shrink: 0;
}

.message.mine .msg-bubble-image {
  border-radius: 8px !important;
}

.msg-image-wrap {
  line-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #e5e7eb;
  width: fit-content;
  max-width: 100%;
}

.msg-bubble:not(.msg-bubble-image) .msg-image-wrap {
  margin-top: 6px;
  border-radius: 6px;
  width: 100%;
}

.msg-image {
  display: block;
  width: auto;
  max-width: 240px;
  max-height: 320px;
  height: auto;
  object-fit: contain;
  cursor: pointer;
  vertical-align: top;
}

.msg-image-wrap.is-broken {
  min-width: 132px;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
}

.msg-image-wrap.is-broken .msg-image {
  display: none;
}

.msg-image-wrap.is-broken::after {
  content: '图片无法显示';
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.4;
  padding: 12px;
}

.msg-bubble:not(.msg-bubble-image) .msg-image {
  width: 100%;
}

.msg-text { line-height: 1.6; white-space: pre-wrap; font-size: 14px; }

.msg-reply {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 8px;
  padding: 5px 7px 5px 0;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.07);
  box-shadow: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  overflow: hidden;
}

.msg-reply-rail {
  align-self: stretch;
  width: 3px;
  flex-shrink: 0;
  border-radius: 3px 0 0 3px;
  background: rgba(28, 58, 32, 0.42);
}

.message.mine .msg-reply {
  background: rgba(0, 0, 0, 0.07);
}

.message.other .msg-reply {
  background: #eef0f3;
}

.message.other .msg-reply-rail {
  background: var(--brand);
}

.msg-reply:hover {
  background: rgba(0, 0, 0, 0.11);
}

.message.other .msg-reply:hover {
  background: #e6e8ed;
}

.msg-reply-main {
  min-width: 0;
  flex: 1;
  padding: 1px 0;
}

.msg-reply-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  color: #243528;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message.other .msg-reply-name {
  color: #0f766e;
}

.msg-reply-preview {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(20, 32, 24, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message.other .msg-reply-preview {
  color: var(--text-secondary);
}

.msg-reply-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.06);
}

.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  padding: 0 2px;
}

.message.other .msg-footer {
  justify-content: flex-start;
}

.msg-time {
  display: none;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 0;
  white-space: nowrap;
}

.message.show-time .msg-bubble .msg-time { display: block; }
.message.show-time .msg-footer .msg-time { display: inline; }
.message.show-time .msg-time {
  display: block;
}

.msg-bubble .msg-time { margin-top: 5px; }

.msg-bubble,
.msg-footer {
  cursor: default;
}

.msg-read {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-read.read { color: var(--brand-dark); font-weight: 500; }

.message.mine .msg-read { text-align: right; }

.msg-read-group {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  line-height: inherit;
}

.msg-read-group:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.group-read-card {
  width: 360px;
  padding: 0;
  overflow: hidden;
}

.group-read-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-light);
}

.group-read-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.group-read-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-light);
}

.group-read-tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: none;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

.group-read-tab:hover { color: var(--text); }

.group-read-tab.active {
  color: var(--brand-dark);
  font-weight: 600;
}

.group-read-tab.active::after {
  content: '';
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: 0;
  height: 2px;
  background: var(--brand);
  border-radius: 2px;
}

.group-read-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 8px 0;
}

.group-read-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.group-read-item:hover { background: var(--sidebar-hover); }

.group-read-name {
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-read-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.message-recalled {
  align-self: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  animation: msgIn 0.25s ease;
}

.msg-context-menu {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  background: #4c4c4c;
  border: none;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  padding: 0;
  overflow: hidden;
  max-width: calc(100vw - 16px);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.msg-context-menu.hidden { display: none; }

.msg-context-menu button {
  display: block;
  border: none;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: none;
  padding: 10px 14px;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.msg-context-menu button:last-child { border-right: none; }

.msg-context-menu button:hover,
.msg-context-menu button:active { background: rgba(255, 255, 255, 0.08); }

.msg-context-menu button.danger,
.msg-context-menu button[data-action="recall"] { color: #fca5a5; }

.chat-context-menu {
  position: fixed;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #4c4c4c;
  border: none;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  padding: 0;
  overflow: hidden;
  min-width: 140px;
  max-width: calc(100vw - 16px);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.chat-context-menu.hidden { display: none; }

.chat-context-menu button {
  display: block;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: none;
  padding: 12px 18px;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  cursor: pointer;
  text-align: center;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.chat-context-menu button:last-child { border-bottom: none; }

.chat-context-menu button:hover,
.chat-context-menu button:active { background: rgba(255, 255, 255, 0.08); }

.chat-context-menu button.danger { color: #fca5a5; }

/* 消息多选模式 */
.chat-panel.chat-select-mode .chat-header { display: none; }
.chat-panel.chat-select-mode .chat-input { display: none; }

.chat-select-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--panel-bg);
  flex-shrink: 0;
}

.chat-select-header.hidden { display: none; }

.chat-select-cancel {
  position: absolute;
  left: 12px;
  border: none;
  background: none;
  padding: 8px 4px;
  font-size: 15px;
  color: var(--brand);
  cursor: pointer;
}

.chat-select-count {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.msg-select-toolbar {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border-light);
  background: var(--panel-bg);
  flex-shrink: 0;
}

.msg-select-toolbar.hidden { display: none; }

.msg-select-action {
  flex: 1;
  border: none;
  background: none;
  padding: 14px 12px;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
}

.msg-select-action + .msg-select-action {
  border-left: 1px solid var(--border-light);
}

.msg-select-action:disabled {
  color: var(--text-muted);
  cursor: default;
}

.msg-select-action:not(:disabled):active {
  background: var(--sidebar-bg);
}

.msg-select-action.danger:not(:disabled) {
  color: #ef4444;
}

.messages-select-mode {
  gap: 0;
  padding-top: 8px;
  padding-bottom: 8px;
}

.messages-select-mode .message,
.messages-select-mode .message.mine,
.messages-select-mode .message.other {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  align-self: stretch !important;
  max-width: 100% !important;
  width: 100%;
  padding: 8px 16px 8px 12px;
  gap: 10px;
  box-sizing: border-box;
  animation: none;
}

.messages-select-mode .message.message-selected {
  background: rgba(16, 185, 129, 0.08);
}

.messages-select-mode .message .msg-select-check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 8px;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.messages-select-mode .message.message-selected .msg-select-check {
  border-color: var(--brand);
  background: var(--brand);
}

.messages-select-mode .message.message-selected .msg-select-check::after {
  content: '';
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}

.messages-select-mode .message .msg-select-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
}

.messages-select-mode .message.mine .msg-select-body {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.messages-select-mode .message.other .msg-select-body {
  justify-content: flex-start;
}

.messages-select-mode .message .msg-avatar,
.messages-select-mode .message .msg-bubble,
.messages-select-mode .message .msg-footer,
.messages-select-mode .message .msg-sender {
  pointer-events: none;
}

.forward-preview {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.forward-search-input {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.forward-search-input:focus {
  outline: none;
  border-color: var(--brand);
}

.forward-target-list { max-height: 280px; }

.forward-target-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.forward-target-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forward-target-tag {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--sidebar-bg);
  padding: 2px 8px;
  border-radius: 10px;
}

#edit-message-modal textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 96px;
  margin-bottom: 8px;
}

#edit-message-modal textarea:focus {
  outline: none;
  border-color: var(--brand);
}

.child-location-card { padding: 0; overflow: hidden; }

.child-location-status {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.child-location-status.error { color: #ef4444; }

.child-location-map-wrap {
  width: 100%;
  height: 280px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.child-location-map {
  width: 100%;
  height: 100%;
}

.child-location-map .leaflet-control-attribution {
  font-size: 10px;
}

.child-location-info {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}

.child-location-info .loc-meta {
  color: var(--text-muted);
  font-size: 12px;
}

.child-location-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
}

.child-location-actions .btn-primary,
.child-location-actions .btn-ghost { width: auto; padding: 9px 16px; }

/* 文件消息卡片 */
.msg-file {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  max-width: 260px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.message.mine .msg-file { background: rgba(255,255,255,0.35); }
.message.other .msg-file { background: var(--sidebar-bg); }

.msg-file:hover { background: rgba(255,255,255,0.85); }
.message.other .msg-file:hover { background: #eef2f7; }

.msg-file-icon,
.preview-file-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.file-icon-pdf { background: linear-gradient(135deg, #ef4444, #dc2626); }
.file-icon-doc, .file-icon-docx { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.file-icon-xls, .file-icon-xlsx { background: linear-gradient(135deg, #22c55e, #16a34a); }
.file-icon-ppt, .file-icon-pptx { background: linear-gradient(135deg, #f97316, #ea580c); }
.file-icon-image { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.file-icon-audio { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.file-icon-archive { background: linear-gradient(135deg, #eab308, #ca8a04); }
.file-icon-video { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.file-icon-text { background: linear-gradient(135deg, #64748b, #475569); }
.file-icon-default { background: linear-gradient(135deg, #64748b, #475569); }

.msg-video-wrap {
  line-height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #0f172a;
  width: fit-content;
  max-width: 100%;
}

.msg-bubble:not(.msg-bubble-image) .msg-video-wrap {
  margin-top: 6px;
  width: 100%;
}

.msg-video {
  display: block;
  width: auto;
  max-width: 240px;
  max-height: 320px;
  height: auto;
  background: #0f172a;
}

.msg-file-info { min-width: 0; flex: 1; }
.msg-file-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-file-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.preview-file {
  text-align: center;
  padding: 12px 0 4px;
}

.preview-file-name {
  font-size: 15px;
  font-weight: 600;
  margin: 12px 0 4px;
  word-break: break-all;
}

.preview-file-size {
  font-size: 13px;
  color: var(--text-muted);
}

.preview-card img.hidden { display: none; }

/* 音频播放器 */
.msg-bubble-audio {
  padding: 10px 12px !important;
  min-width: 220px;
}

.msg-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

.msg-audio-play {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  padding: 0;
}

.message.other .msg-audio-play {
  background: #64748b;
}

.msg-audio-play:hover { transform: scale(1.05); }
.msg-audio-play .icon { width: 16px; height: 16px; }
.msg-audio-play .icon-pause { display: none; }
.msg-audio-play.playing .icon-play { display: none; }
.msg-audio-play.playing .icon-pause { display: block; }

.msg-audio-body {
  flex: 1;
  min-width: 0;
}

.msg-audio-track {
  height: 4px;
  background: rgba(0,0,0,0.08);
  border-radius: 2px;
  cursor: pointer;
  overflow: hidden;
}

.message.mine .msg-audio-track { background: rgba(0,0,0,0.1); }

.msg-audio-progress {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.message.other .msg-audio-progress { background: #64748b; }

.msg-audio-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.msg-audio-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.msg-audio-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* 文件阅读器 */
.file-viewer {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(20px, env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.file-viewer::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.file-viewer-panel {
  background: var(--surface);
  border-radius: 16px;
  width: min(960px, 96vw);
  height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.file-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.file-viewer-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.file-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-viewer-page {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 64px;
  text-align: center;
}

.btn-sm {
  padding: 6px 12px !important;
  font-size: 13px !important;
  width: auto !important;
}

.file-viewer-body {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background: #f8fafc;
}

.file-viewer-loading,
.file-viewer-error {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px;
}

.file-viewer-pdf-page {
  display: flex;
  justify-content: center;
}

.file-viewer-pdf-page canvas {
  max-width: 100%;
  height: auto;
  box-shadow: var(--shadow-sm);
  background: #fff;
}

.file-viewer-docx {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  padding: 32px 40px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  line-height: 1.7;
  font-size: 14px;
}

.file-viewer-docx p { margin: 0 0 0.8em; }

.file-viewer-sheet {
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.file-viewer-sheet table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.file-viewer-sheet th,
.file-viewer-sheet td {
  border: 1px solid #e2e8f0;
  padding: 6px 10px;
  white-space: nowrap;
}

.file-viewer-sheet th {
  background: #f1f5f9;
  font-weight: 600;
}

.file-viewer-unsupported {
  text-align: center;
  padding: 40px 20px;
}

.file-viewer-unsupported-name {
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0 8px;
}

.file-viewer-unsupported-tip {
  color: var(--text-muted);
  margin-bottom: 20px;
}

.file-viewer-unsupported .preview-file-icon {
  margin: 0 auto;
  width: 56px;
  height: 56px;
  font-size: 13px;
}

.file-viewer-toolbar .btn-sm.is-active {
  background: var(--brand);
  color: #fff;
}

.file-viewer-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}

.file-viewer-media img,
.file-viewer-media video {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.file-viewer-media video {
  background: #0f172a;
}

.file-viewer-media audio {
  width: min(480px, 100%);
}

.file-viewer-media-dark {
  background: #0f172a;
  border-radius: 8px;
  padding: 12px;
}

.file-viewer-text,
.file-viewer-hex {
  margin: 0;
  background: #fff;
  padding: 16px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.file-viewer-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.file-viewer-hex {
  white-space: pre;
  overflow-x: auto;
  font-size: 12px;
}

.file-viewer-binary h4 {
  margin: 20px 0 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

.file-viewer-binary-meta {
  text-align: center;
  margin-bottom: 8px;
}

.file-viewer-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.file-viewer-zip {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-viewer-zip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--border-light);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.file-viewer-zip-item:hover {
  border-color: var(--brand);
}

.file-viewer-zip-name {
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.file-viewer-pptx {
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 28px 32px;
}

.file-viewer-pptx-images {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.file-viewer-pptx-images img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.file-viewer-pptx-text p {
  margin: 0 0 0.7em;
  font-size: 15px;
  line-height: 1.65;
}

/* 输入区（微信式：单行起步，随内容增高） */
.chat-input {
  position: relative;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* 不用 hidden/display:none，否则 iOS / Android WebView / Electron 点选文件会失效 */
.sr-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-input.drag-over { background: var(--brand-bg); }
.chat-panel.drag-over {
  outline: 2px dashed var(--brand);
  outline-offset: -4px;
}

.reply-bar {
  padding: 8px 12px 0;
}

.reply-bar-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px 7px 0;
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.reply-bar-rail {
  align-self: stretch;
  width: 3px;
  flex-shrink: 0;
  border-radius: 3px 0 0 3px;
  background: var(--brand);
}

.reply-bar-body {
  flex: 1;
  min-width: 0;
  padding: 1px 0;
}

.reply-bar-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar-title #reply-bar-name,
.reply-bar-name {
  font-weight: 600;
  color: var(--text);
}

.reply-bar-preview {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-bar-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
  background: #e5e7eb;
}

.reply-bar-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #e5e7eb;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.reply-bar-close:hover {
  background: #d1d5db;
  color: var(--text);
}

.reply-bar-close .icon {
  width: 12px;
  height: 12px;
}

.chat-input-main {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
}

.tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: var(--transition);
  flex-shrink: 0;
  border: none;
  background: transparent;
  padding: 0;
}

.tool-btn:hover {
  background: var(--sidebar-hover);
  color: var(--brand-dark);
}

.chat-more-btn .icon {
  width: 22px;
  height: 22px;
}

#message-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  background: var(--sidebar-hover);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  resize: none;
  line-height: 1.5;
  overflow-y: hidden;
  box-sizing: border-box;
}

.chat-toolbar-panel {
  display: none;
  gap: 8px;
  padding: 4px 12px 12px;
  flex-wrap: wrap;
}

.chat-input.is-toolbar-open .chat-toolbar-panel {
  display: flex;
}

.chat-send-btn {
  flex-shrink: 0;
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  margin: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  white-space: nowrap;
  transition: max-width 0.2s ease, opacity 0.15s ease, padding 0.2s ease, border-width 0.2s ease;
}

.chat-input.has-text .chat-send-btn {
  max-width: 80px;
  padding: 7px 16px;
  border-width: 1px;
  opacity: 1;
  pointer-events: auto;
}

.btn-send {
  background: var(--surface);
  color: var(--brand-dark);
  border: 1px solid var(--brand-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-send:hover {
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

@media (min-width: 769px) {
  .reply-bar {
    padding: 8px 20px 0;
  }

  .chat-input-main {
    padding: 8px 20px;
  }

  .chat-more-btn {
    display: none;
  }

  .chat-toolbar-panel {
    display: flex;
    order: -1;
    padding: 10px 20px 0;
  }

  .chat-send-btn {
    max-width: 80px;
    padding: 7px 22px;
    border-width: 1px;
    opacity: 1;
    pointer-events: auto;
  }
}

/* 弹窗：白卡片不滚动；内容过高时在遮罩层滚动，滚动条隐藏 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.2s ease;
  overflow-x: hidden;
  overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(20px, env(safe-area-inset-bottom, 0px));
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal.modal-over {
  z-index: 160;
}

.modal::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 28px;
  width: 380px;
  max-height: none;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
  margin: auto;
  flex-shrink: 0;
}

.modal-card.guardian-manage-card {
  animation: none;
}

.modal-card-wide { width: 440px; }

/* 弹框 / 预览 / 文件查看等浮层：可滚动区域隐藏滚动条 */
.modal,
.modal *,
.image-preview,
.image-preview *,
.file-viewer,
.file-viewer *,
.guardian-ring-overlay,
.guardian-ring-overlay * {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal ::-webkit-scrollbar,
.image-preview ::-webkit-scrollbar,
.file-viewer ::-webkit-scrollbar,
.guardian-ring-overlay ::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: -4px 0 16px;
}

.profile-readonly {
  font-size: 14px;
  color: var(--text-muted);
  background: var(--sidebar-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  word-break: break-all;
}

.sidebar-username-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.server-current {
  font-size: 13px;
  color: var(--brand-dark);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  word-break: break-all;
}

.server-test-result {
  font-size: 13px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.server-test-result.ok {
  color: #047857;
  background: #ecfdf5;
}

.server-test-result.fail {
  color: var(--danger);
  background: #fef2f2;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--brand);
}

.modal-card h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

.modal-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
  transition: var(--transition);
}

.modal-card input:focus,
.modal-card select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.reset-code-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: stretch;
}

.reset-code-row input {
  flex: 1;
  margin-bottom: 0;
  letter-spacing: 0.12em;
}

.reset-code-row .btn-ghost {
  width: auto;
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0 14px;
}

.modal-card select,
.friend-group-select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
}

.modal-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.member-checklist {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.member-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  transition: var(--transition);
}

.member-check:hover { background: var(--sidebar-hover); }
.member-check input { width: auto; margin: 0; accent-color: var(--brand); }

.history-sync-card {
  width: min(320px, calc(100vw - 32px));
  text-align: center;
}

.history-sync-desc {
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

.history-sync-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-sync-options .btn-primary,
.history-sync-options .btn-ghost {
  width: 100%;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-ghost {
  padding: 9px 20px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
}

.btn-ghost:hover { background: var(--sidebar-hover); }

.modal-actions .btn-primary {
  width: auto;
  padding: 9px 24px;
}

.add-friend-card {
  width: 400px;
}

.add-friend-card h3 {
  margin-bottom: 16px;
}

.add-friend-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.add-friend-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: -1px;
}

.add-friend-tab:hover {
  color: var(--text);
}

.add-friend-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 500;
}

.add-friend-panel .modal-actions {
  margin-top: 16px;
}

.my-qrcode-card {
  background: linear-gradient(180deg, rgba(16,185,129,0.08) 0%, var(--surface) 40%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.my-qrcode-user {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  margin-bottom: 20px;
}

.my-qrcode-info {
  min-width: 0;
}

.my-qrcode-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-qrcode-username {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.my-qrcode-canvas-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 12px;
}

.my-qrcode-canvas-wrap canvas {
  display: block;
  width: 200px !important;
  height: 200px !important;
}

.my-qrcode-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.qr-scanner-wrap {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  min-height: 260px;
}

.qr-scanner-wrap #qr-scanner-region {
  width: 100%;
}

.qr-scanner-wrap video {
  border-radius: 12px;
}

.qr-scan-tip {
  text-align: center;
  margin: 12px 0 0;
}

/* 统一提示 / 确认框 */
.app-dialog-card {
  width: min(360px, 92vw);
  padding: 24px 28px 22px;
  text-align: center;
}

.app-dialog-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: -8px 0 22px;
  white-space: pre-line;
  word-break: break-word;
}

.app-dialog-card h3 {
  margin-bottom: 12px;
}

.app-dialog-actions {
  justify-content: center;
  gap: 12px;
}

.app-dialog-actions .btn-primary,
.app-dialog-actions .btn-ghost,
.app-dialog-actions .btn-danger {
  min-width: 96px;
}

.app-dialog-icon--success { color: var(--brand); }
.app-dialog-icon--warning { color: #d97706; }
.app-dialog-icon--error { color: var(--danger); }
.app-dialog-icon--info { color: var(--brand); }

.app-dialog-actions .btn-danger {
  width: auto;
}

.about-card {
  width: min(400px, 92vw);
}

.about-version {
  font-size: 14px;
  color: var(--text-secondary);
  margin: -2px 0 10px;
}

.about-version strong {
  color: var(--text);
  font-weight: 600;
}

.about-site {
  font-size: 14px;
  color: var(--text-secondary);
  margin: -4px 0 12px;
}

.about-site a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.about-site a:hover {
  text-decoration: underline;
}

.about-update-status {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0 0 18px;
  white-space: pre-line;
  word-break: break-word;
}

.about-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px 0 18px;
}

.about-progress-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--border-light);
  overflow: hidden;
}

.about-progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  transition: width 0.2s ease;
}

.about-progress-text {
  min-width: 36px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.about-actions {
  flex-wrap: nowrap;
  justify-content: center;
}

.about-actions .btn-primary,
.about-actions .btn-ghost {
  min-width: 96px;
}

.about-actions .btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.profile-menu-value.has-update {
  color: var(--brand);
  font-weight: 500;
}

.shortcut-card {
  width: min(400px, 92vw);
  text-align: left;
}

.shortcut-card h3,
.shortcut-card .modal-icon {
  text-align: center;
}

.shortcut-card .modal-desc {
  text-align: center;
  margin-bottom: 8px;
}

.shortcut-list {
  margin: 8px 0 12px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 13px 14px;
  border: none;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.shortcut-row:last-child { border-bottom: none; }

.shortcut-row:hover { background: var(--sidebar-hover); }

.shortcut-row.recording {
  background: var(--brand-bg);
}

.shortcut-keys {
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.shortcut-row.recording .shortcut-keys {
  color: var(--brand);
}

.shortcut-record-hint {
  font-size: 12px;
  color: var(--brand-dark);
  text-align: center;
  margin: 0 0 12px;
}

.shortcut-send {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
}

.shortcut-send-title {
  font-size: 14px;
  margin-bottom: 10px;
}

.shortcut-send-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: fit-content;
  font-size: 14px;
  color: var(--text-secondary);
  margin: 8px 0;
  cursor: pointer;
}

.shortcut-send-option input,
.modal-card .shortcut-send-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  appearance: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
  accent-color: var(--brand);
}

.modal-card .shortcut-send-option input[type="radio"]:focus {
  border: none;
  box-shadow: none;
}

.shortcut-send-tip {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* 图片预览 */
.image-preview {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow-x: hidden;
  overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) 16px max(20px, env(safe-area-inset-bottom, 0px));
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.image-preview::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.preview-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  max-height: none;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: auto;
  flex-shrink: 0;
}

.preview-target {
  font-size: 14px;
  color: var(--brand-dark);
  font-weight: 500;
  margin-bottom: 14px;
  text-align: center;
}

.preview-card img {
  max-width: 100%;
  max-height: 60vh;
  border-radius: var(--radius-sm);
  display: block;
}

.preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

.preview-actions .btn-primary { width: auto; padding: 9px 22px; }

body.lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  animation: fadeIn 0.2s ease;
}

.lightbox.is-closing {
  animation: none;
  transition: opacity 0.18s ease;
  opacity: 0;
}

.lightbox-viewport,
.lightbox-track,
.lightbox-slide {
  width: 100%;
  height: 100%;
}

.lightbox-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.lightbox-track {
  display: flex;
  will-change: transform;
}

.lightbox-slide {
  flex: 0 0 100vw;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.lightbox img {
  max-width: 100vw;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
  pointer-events: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.lightbox-sheet {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.lightbox-sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.lightbox-sheet-panel {
  position: absolute;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  width: min(400px, calc(100vw - 20px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-50%);
  animation: lightboxSheetIn 0.22s ease;
}

@keyframes lightboxSheetIn {
  from { transform: translateX(-50%) translateY(18px); opacity: 0.65; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

.lightbox-sheet-group {
  background: #f7f7f7;
  border-radius: 12px;
  overflow: hidden;
}

.lightbox-sheet-group button {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 0.5px solid rgba(60, 60, 67, 0.16);
  background: #f7f7f7;
  padding: 16px 12px;
  font-size: 17px;
  line-height: 1.2;
  color: #111827;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-sheet-group button:last-child {
  border-bottom: none;
}

.lightbox-sheet-group button:hover {
  background: #ececee;
}

.lightbox-sheet-group button:active {
  background: #e5e5ea;
}

.lightbox-sheet-group:last-child button {
  font-weight: 600;
  color: #111827;
}

.lightbox-toast {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 14px;
  line-height: 1.3;
  pointer-events: none;
  white-space: nowrap;
}

.lightbox-chrome {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px max(18px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.lightbox-chrome-btn {
  pointer-events: auto;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
  padding: 8px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lightbox-chrome-btn:active {
  opacity: 0.7;
}

.lightbox-chrome-more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
}

.lightbox-chrome-more .icon {
  width: 22px;
  height: 22px;
  color: #fff;
}

.preview-actions #edit-image {
  margin-right: auto;
}

.ocr-result-modal {
  z-index: 220;
}

.ocr-result-card {
  padding: 20px 22px 22px;
}

.ocr-result-card .group-read-header {
  margin: -4px 0 16px;
  padding: 0 0 12px;
}

.ocr-result-card .group-read-header h3 {
  text-align: left;
  margin-bottom: 0;
}

.ocr-result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 160px;
  color: var(--text-secondary);
  font-size: 14px;
}

.ocr-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: ocrSpin 0.7s linear infinite;
}

@keyframes ocrSpin {
  to { transform: rotate(360deg); }
}

.ocr-result-body textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  min-height: 160px;
  max-height: 50vh;
  color: var(--text);
  background: var(--sidebar);
}

.ocr-result-body textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
}

.ocr-result-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.ocr-result-hint.is-success {
  color: var(--brand-dark);
}

.ocr-result-hint.error {
  color: var(--danger);
}

.ocr-result-actions {
  margin-top: 16px;
}

.ocr-result-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 手机端：列表 / 聊天分屏切换，避免双栏挤压 */
.chat-back-btn {
  display: none;
  flex-shrink: 0;
}

.chat-back-icon {
  font-size: 28px;
  line-height: 1;
  font-weight: 300;
  margin-top: -2px;
}

@media (max-width: 768px) {
  .auth-screen .login-card {
    width: min(92vw, 400px);
    margin: 16px;
    padding: 28px 22px;
  }

  .sidebar {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1;
    border-right: none;
  }

  .chat-area {
    display: none;
    flex: 1;
    width: 100%;
    min-width: 0;
  }

  .app-body {
    position: relative;
  }

  .app-body.mobile-chat-open .sidebar {
    display: flex;
  }

  .app-body.mobile-chat-open .chat-area {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 10;
    background: var(--chat-bg);
    box-shadow: -4px 0 18px rgba(15, 23, 42, 0.1);
    touch-action: pan-y;
  }

  .empty-chat {
    display: none;
  }

  .chat-back-btn {
    display: flex;
  }

  .chat-header {
    justify-content: flex-start;
    gap: 6px;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .chat-header-main {
    flex: 1;
    min-width: 0;
  }

  .chat-header h2 {
    font-size: 17px;
  }

  .messages {
    padding: 12px 14px;
    gap: 12px;
  }

  .message {
    max-width: 94%;
  }

  .message.image-only,
  .message.media-only {
    max-width: 96%;
  }

  .message.media-only:has(.msg-audio) {
    max-width: 96%;
  }

  .msg-main {
    max-width: 280px;
  }

  .message.media-only .msg-main,
  .message.image-only .msg-main {
    max-width: none;
  }

  .msg-bubble {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .chat-input {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .chat-select-header {
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
  }

  .msg-select-toolbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .reply-bar {
    padding: 8px 10px 0;
  }

  .chat-input-main {
    padding: 6px 10px;
  }

  .chat-toolbar-panel {
    padding: 4px 10px 10px;
  }

  .pins-panel {
    width: 100%;
    max-width: none;
  }

  .sidebar-top {
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
  }

  .sidebar-title {
    font-size: 17px;
  }

  .profile-header {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }

  .sidebar-top.profile-tab-hidden {
    display: none;
  }

  .search-wrap.profile-tab-hidden {
    display: none;
  }

  .chat-search-header {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }

  .modal-card {
    width: min(92vw, 420px);
    margin: 16px;
  }

  .guardian-manage-card {
    padding: 20px 16px 16px;
  }

  .guardian-list-actions {
    gap: 6px;
  }

  .guardian-list-actions .btn-ghost,
  .guardian-list-actions .btn-danger-ghost {
    padding: 7px 4px;
    font-size: 12px;
  }

  .guardian-bind-row {
    flex-wrap: wrap;
  }

  .guardian-bind-row input {
    min-width: 0;
    flex: 1 1 140px;
  }

  .guardian-bind-btn {
    flex: 0 0 auto;
  }

  .modal-card-wide {
    width: min(96vw, 520px);
  }

  .ocr-result-actions {
    flex-wrap: wrap;
  }
}

/* 微信风格图片编辑 */
body.img-editor-open {
  overflow: hidden;
}

.img-editor {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.img-editor.is-text {
  -webkit-user-select: text;
  user-select: text;
}

.img-editor.is-loading .img-editor-wrap {
  opacity: 0.35;
}

.img-editor-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top, 0px)) 16px 10px;
}

.img-editor-text-btn {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
  padding: 8px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.img-editor-done {
  color: #07c160;
  font-weight: 600;
}

.img-editor-done:disabled {
  opacity: 0.45;
}

.img-editor-stage {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.img-editor-wrap {
  position: relative;
  overflow: visible;
  touch-action: none;
}

.img-editor-view {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.img-editor-crop {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.img-editor-crop-box {
  position: absolute;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.46);
  outline: 1px solid rgba(255, 255, 255, 0.92);
  box-sizing: border-box;
}

.img-editor-crop-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.35) 1px, transparent 1px) 0 33.33%/100% 33.33%,
    linear-gradient(90deg, rgba(255, 255, 255, 0.35) 1px, transparent 1px) 33.33% 0/33.33% 100%;
  pointer-events: none;
}

.img-editor-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  z-index: 3;
}

.img-editor-handle::after {
  content: '';
  position: absolute;
  background: #fff;
}

.img-editor-handle[data-handle="nw"] { left: -1px; top: -1px; cursor: nwse-resize; }
.img-editor-handle[data-handle="ne"] { right: -1px; top: -1px; cursor: nesw-resize; }
.img-editor-handle[data-handle="se"] { right: -1px; bottom: -1px; cursor: nwse-resize; }
.img-editor-handle[data-handle="sw"] { left: -1px; bottom: -1px; cursor: nesw-resize; }
.img-editor-handle[data-handle="n"] { left: 50%; top: -1px; margin-left: -11px; cursor: ns-resize; }
.img-editor-handle[data-handle="s"] { left: 50%; bottom: -1px; margin-left: -11px; cursor: ns-resize; }
.img-editor-handle[data-handle="e"] { right: -1px; top: 50%; margin-top: -11px; cursor: ew-resize; }
.img-editor-handle[data-handle="w"] { left: -1px; top: 50%; margin-top: -11px; cursor: ew-resize; }

.img-editor-handle[data-handle="nw"]::after,
.img-editor-handle[data-handle="ne"]::after,
.img-editor-handle[data-handle="se"]::after,
.img-editor-handle[data-handle="sw"]::after {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  background: transparent;
  box-sizing: border-box;
}

.img-editor-handle[data-handle="nw"]::after { left: 0; top: 0; border-right: none; border-bottom: none; }
.img-editor-handle[data-handle="ne"]::after { right: 0; top: 0; border-left: none; border-bottom: none; }
.img-editor-handle[data-handle="se"]::after { right: 0; bottom: 0; border-left: none; border-top: none; }
.img-editor-handle[data-handle="sw"]::after { left: 0; bottom: 0; border-right: none; border-top: none; }

.img-editor-handle[data-handle="n"]::after,
.img-editor-handle[data-handle="s"]::after {
  left: 5px;
  width: 12px;
  height: 3px;
}

.img-editor-handle[data-handle="n"]::after { top: 0; }
.img-editor-handle[data-handle="s"]::after { bottom: 0; }

.img-editor-handle[data-handle="e"]::after,
.img-editor-handle[data-handle="w"]::after {
  top: 5px;
  width: 3px;
  height: 12px;
}

.img-editor-handle[data-handle="e"]::after { right: 0; }
.img-editor-handle[data-handle="w"]::after { left: 0; }

.img-editor-text {
  position: absolute;
  z-index: 4;
  min-width: 80px;
  max-width: 90%;
  width: max-content;
  margin: 0;
  padding: 2px 6px;
  border: 1px dashed currentColor;
  background: rgba(0, 0, 0, 0.28);
  outline: none;
  resize: none;
  overflow: hidden;
  line-height: 1.25;
  font-weight: 600;
  font-family: inherit;
  caret-color: currentColor;
  touch-action: manipulation;
  pointer-events: auto;
  -webkit-user-select: text !important;
  user-select: text !important;
}

.img-editor-text::placeholder {
  color: currentColor;
  opacity: 0.45;
}

.img-editor-text-del {
  position: absolute;
  z-index: 5;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: #fa5151;
  color: #fff;
  font-size: 16px;
  line-height: 20px;
  padding: 0;
  cursor: pointer;
}

.img-editor-dock {
  flex: 0 0 auto;
  padding: 6px 8px max(10px, env(safe-area-inset-bottom, 0px));
}

.img-editor-palette,
.img-editor-crop-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 40px;
  margin-bottom: 4px;
}

.img-editor-colors {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.img-editor-color {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  padding: 0;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.img-editor-color.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  transform: scale(1.15);
}

.img-editor-color[data-color="#ffffff"] {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.img-editor-undo {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.img-editor-undo svg {
  width: 22px;
  height: 22px;
}

.img-editor-undo.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.img-editor-crop-act {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 14px;
  padding: 8px 12px;
  cursor: pointer;
}

.img-editor-crop-act:disabled,
.img-editor-crop-act.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.img-editor-crop-act svg {
  width: 18px;
  height: 18px;
}

.img-editor-tools {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  padding: 4px 8px 0;
}

.img-editor-tool {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  padding: 6px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.img-editor-tool svg {
  width: 24px;
  height: 24px;
}

.img-editor-tool.active {
  color: #07c160;
}

.img-editor-toast {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 14px;
  pointer-events: none;
  white-space: nowrap;
}
