/* ============================================
   文件传输助手 - 完整样式
   ============================================ */

/* === CSS变量 === */
:root {
  --primary: #1890ff;
  --primary-dark: #096dd9;
  --primary-light: #e6f7ff;
  --success: #52c41a;
  --danger: #ff4d4f;
  --warning: #faad14;
  --text: #262626;
  --text-secondary: #8c8c8c;
  --text-light: #bfbfbf;
  --bg: #f5f5f5;
  --bg-white: #ffffff;
  --bg-hover: #f0f0f0;
  --bg-active: #e6f7ff;
  --border: #e8e8e8;
  --border-light: #f0f0f0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 16px;
  --sidebar-width: 280px;
  --header-height: 60px;
  --input-area-min: 64px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { 
  height: 100%; 
}
body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; }

/* === 页面 === */
.page { 
  display: none; 
  width: 100%; 
  height: 100%;
  overflow: hidden;
}
.page.active { display: flex; }

/* ===================================
   登录页
   =================================== */
.login-container {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #e6f7ff 0%, #f0f5ff 50%, #fff 100%);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

.login-logo p {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 15px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group label small {
  font-weight: 400;
  color: var(--text-light);
}

.form-group input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg-white);
}

.form-group select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24,144,255,0.1);
}

.form-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* === 按钮 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #cf1322; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-text {
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius);
}
.btn-text:hover { background: var(--bg-hover); }

.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ===================================
   聊天布局
   =================================== */
.chat-layout {
  display: flex;
  width: 100%;
  height: 100%;
  background: var(--bg-white);
  overflow: hidden;
}

/* === 侧边栏 === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  background: #fafbfc;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  height: var(--header-height);
  border-bottom: 1px solid var(--border-light);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}

.user-name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-actions {
  display: flex;
  gap: 2px;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.chat-section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.section-add-btn:hover {
  background: var(--bg-hover);
  color: var(--primary);
}

/* === 聊天列表项 === */
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.chat-item:hover { background: var(--bg-hover); }

.chat-item.active {
  background: var(--bg-active);
  border-left-color: var(--primary);
}

.chat-item-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
}

.self-avatar {
  background: linear-gradient(135deg, #1890ff, #36cfc9);
}

.group-avatar {
  background: linear-gradient(135deg, #722ed1, #eb2f96);
}

.chat-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-item-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-desc {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* === 聊天主区域 === */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: var(--header-height);
  min-height: var(--header-height);
  flex-shrink: 0;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-info h2 {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-info span {
  font-size: 12px;
  color: var(--text-light);
}

/* === 消息区域 === */
.messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* 滚动条 */
.messages-container::-webkit-scrollbar { width: 6px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 3px; }
.messages-container::-webkit-scrollbar-thumb:hover { background: #bfbfbf; }
.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: #e8e8e8; border-radius: 2px; }

.messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  gap: 16px;
  text-align: center;
  padding: 40px;
}

.messages-empty p {
  font-size: 14px;
  line-height: 1.8;
}

/* === 时间分隔线 === */
.time-divider {
  text-align: center;
  margin: 16px 0;
}

.time-divider span {
  display: inline-block;
  padding: 3px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-light);
}

/* === 消息行 === */
.message-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  max-width: 85%;
}

.message-row.self {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message-row.other {
  margin-right: auto;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-top: 2px;
}

.msg-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.msg-sender {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 4px;
  padding-left: 4px;
}

.msg-bubble {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.message-row.self .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 4px;
}

.message-row.other .msg-bubble {
  background: var(--bg-white);
  color: var(--text);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* === 消息内容 === */
.msg-text {
  padding: 10px 14px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
  cursor: pointer;
}

.msg-text a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.message-row.self .msg-text a { color: #e6f7ff; }

/* 图片消息 */
.msg-image {
  cursor: pointer;
  line-height: 0;
}

.msg-image img {
  max-width: 280px;
  max-height: 280px;
  min-width: 100px;
  min-height: 60px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-lg);
  transition: opacity 0.2s;
}
.msg-image img:hover { opacity: 0.9; }

/* 文件消息 */
.msg-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none !important;
  min-width: 220px;
  max-width: 320px;
  color: inherit;
}

.msg-file-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 10px;
  background: rgba(24,144,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

.message-row.self .msg-file-icon {
  background: rgba(255,255,255,0.15);
}
.message-row.self .msg-file-icon svg { fill: #fff; }

.msg-file-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.msg-file-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-file-size {
  font-size: 12px;
  opacity: 0.7;
}

/* 语音消息 */
.msg-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  min-width: 100px;
}

.msg-voice-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.message-row.other .msg-voice-btn {
  background: var(--primary);
}
.message-row.other .msg-voice-btn svg { fill: #fff; }

.msg-voice-waves {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
}

.msg-voice-waves span {
  display: block;
  width: 3px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.4;
}

.msg-voice-waves.playing span {
  animation: waveAnim 0.6s ease-in-out infinite alternate;
  opacity: 0.8;
}

.msg-voice-waves span:nth-child(1) { height: 6px; }
.msg-voice-waves span:nth-child(2) { height: 12px; animation-delay: 0.1s; }
.msg-voice-waves span:nth-child(3) { height: 8px; animation-delay: 0.2s; }
.msg-voice-waves span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.msg-voice-waves span:nth-child(5) { height: 10px; animation-delay: 0.4s; }
.msg-voice-waves span:nth-child(6) { height: 6px; animation-delay: 0.5s; }

@keyframes waveAnim {
  from { height: 4px; }
  to { height: 16px; }
}

.msg-voice-duration {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
}

/* 视频消息 */
.msg-video {
  line-height: 0;
}

.msg-video video {
  max-width: 320px;
  max-height: 240px;
  border-radius: var(--radius-lg);
  display: block;
}

/* === 消息操作按钮 === */
.msg-actions {
  display: none;
  position: absolute;
  top: -28px;
  right: 0;
  gap: 2px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2px;
  z-index: 10;
}

.message-row.other .msg-actions {
  right: auto;
  left: 0;
}

.msg-bubble:hover .msg-actions { display: flex; }

.msg-actions button {
  height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.msg-actions button:hover { background: var(--bg-hover); }
.msg-actions .btn-del { color: var(--danger); }
.msg-actions .btn-del:hover { background: #fff1f0; }

/* === 消息时间 === */
.msg-time {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
  padding: 0 4px;
}

.message-row.self .msg-time { text-align: right; }

/* === 上传中动画 === */
.loading-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotPulse 1s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ===================================
   输入区域
   =================================== */
.input-area {
  flex-shrink: 0;
  background: var(--bg-white);
  border-top: 1px solid var(--border-light);
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-tools {
  display: flex;
  gap: 2px;
  padding-bottom: 4px;
}

.input-tools .icon-btn {
  color: var(--text-light);
}
.input-tools .icon-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}

#message-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  outline: none;
  resize: none;
  line-height: 1.5;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--bg);
}

#message-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24,144,255,0.08);
  background: var(--bg-white);
}

.send-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.send-btn:hover { background: var(--primary-dark); transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }

/* === 录音指示器 === */
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-white);
}

.recording-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.recording-label {
  color: var(--danger);
  font-weight: 500;
  font-size: 14px;
}

#recording-time {
  font-family: 'SF Mono', 'Consolas', monospace;
  font-size: 16px;
  font-weight: 600;
  flex: 1;
}

.recording-btns {
  display: flex;
  gap: 8px;
}

/* ===================================
   模态框
   =================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close-btn:hover { background: var(--bg-hover); color: var(--text); }

.modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
}

.modal-form-group {
  margin-bottom: 16px;
}

.modal-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.modal-form-group input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s;
  background: var(--bg-white);
}

.modal-form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(24,144,255,0.1);
}

/* 成员列表 */
.member-list {
  max-height: 200px;
  overflow-y: auto;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}

.member-item:last-child { border-bottom: none; }

.member-role {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
}

.member-remove {
  margin-left: auto;
  padding: 2px 8px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  color: var(--danger);
  background: transparent;
  cursor: pointer;
}
.member-remove:hover { background: #fff1f0; }

/* ===================================
   图片预览
   =================================== */
.image-preview {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
}

.preview-toolbar {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 2001;
}

#preview-img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  cursor: default;
  border-radius: var(--radius);
}

/* ===================================
   拖拽上传蒙层
   =================================== */
.drag-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24,144,255,0.08);
  border: 3px dashed var(--primary);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.drag-overlay.show { display: flex; }

.drag-hint {
  text-align: center;
  color: var(--primary);
}

.drag-hint p {
  font-size: 16px;
  margin-top: 12px;
  font-weight: 500;
}

/* ===================================
   Toast通知
   =================================== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
  max-width: 400px;
}

.toast.success { background: #f6ffed; color: #389e0d; border: 1px solid #b7eb8f; }
.toast.error   { background: #fff2f0; color: #cf1322; border: 1px solid #ffa39e; }
.toast.info    { background: #e6f7ff; color: #096dd9; border: 1px solid #91d5ff; }
.toast.warning { background: #fffbe6; color: #d48806; border: 1px solid #ffe58f; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================================
   移动端响应式
   =================================== */
.mobile-only { display: none; }
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
  .mobile-only { display: flex; }
  
  /* 修复移动端高度问题，避免 fixed body 导致消息区无法滑动 */
  html {
    height: 100%;
    min-height: 100%;
  }
  
  body {
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    position: static;
    width: auto;
  }
  
  .page {
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    min-height: 0;
  }
  
  .chat-layout {
    height: 100%;
    min-height: 0;
  }

  .chat-main {
    position: relative;
    height: 100%;
    min-height: 0;
  }
  
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .messages-container {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  
  /* 输入区域固定在屏幕底部，避免被消息区挤出可视范围 */
  .input-area {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  }
  
  /* 录音指示器也固定在底部 */
  .recording-indicator {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 21;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  
  .message-row { max-width: 92%; }

  .msg-image img {
    max-width: 200px;
    max-height: 200px;
  }
  
  .msg-video video {
    max-width: 240px;
  }
  
  .msg-file {
    min-width: 180px;
    max-width: 260px;
  }

  .modal {
    max-width: 100%;
    margin: 0 16px;
    max-height: 85vh;
  }
  
  /* 登录页面适配 */
  .login-container {
    min-height: -webkit-fill-available;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .input-tools {
    gap: 0;
  }
  
  .icon-btn {
    width: 32px;
    height: 32px;
  }
  
  .input-tools svg {
    width: 20px;
    height: 20px;
  }
  
  /* 小屏幕输入框优化 */
  #message-input {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 16px; /* 防止iOS自动缩放 */
  }
  
  .send-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }
}

/* === 搜索 / 多选 / 右键 / 预览切换 === */
.search-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-white);
}
.search-panel input { flex: 1; min-width: 160px; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.search-panel select { height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: #fff; }
.search-results { width: 100%; flex-basis: 100%; max-height: 220px; overflow-y: auto; border-top: 1px solid var(--border-light); background: #fff; }
.search-item { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border-light); }
.search-item:hover { background: var(--bg-hover); }
.search-item-title { font-size: 12px; color: var(--text-secondary); }
.search-item-snippet { font-size: 13px; margin-top: 2px; word-break: break-all; }

.multi-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #e6f7ff;
  border-bottom: 1px solid var(--border);
}
.message-row.selected .msg-bubble { outline: 2px solid var(--primary); }
.message-row.highlight .msg-bubble { animation: flashHl 1.6s ease; }
@keyframes flashHl {
  0%, 100% { box-shadow: none; }
  30% { box-shadow: 0 0 0 4px rgba(24,144,255,0.35); }
}
.msg-text { user-select: text; cursor: text; }

.ctx-menu {
  position: fixed;
  z-index: 4000;
  min-width: 140px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.ctx-menu button:hover { background: var(--bg-hover); }

.preview-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 32px;
  z-index: 2002;
  line-height: 1;
}
.preview-nav:hover { background: rgba(255,255,255,0.35); }
.preview-nav.prev { left: 16px; }
.preview-nav.next { right: 16px; }
#preview-video { max-width: 90%; max-height: 90%; }

.load-older {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 8px 0 4px;
}
.quota-bar {
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.quota-bar-inner { height: 100%; background: var(--primary); }

html.admin-html,
html.admin-html body,
body.admin-page {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-page { display: flex; flex-direction: column; min-height: 100vh; height: auto; overflow: visible; background: var(--bg); }
.admin-top {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.admin-body { padding: 20px; max-width: 1280px; margin: 0 auto; width: 100%; }
.admin-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.admin-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: var(--shadow); }
.admin-card h4 { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.admin-card .num { font-size: 22px; font-weight: 600; }
.admin-section { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.admin-section h3 { margin-bottom: 12px; }
.admin-table-wrap { overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px; border-bottom: 1px solid var(--border-light); text-align: left; vertical-align: middle; }
.admin-table input, .admin-table select { height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 4px; }
.admin-input-sm { width: 88px; }
.admin-unit { color: var(--text-secondary); margin-left: 6px; font-size: 12px; }
.admin-nowrap { white-space: nowrap; }
.admin-snippet { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-empty { color: var(--text-secondary); text-align: center !important; padding: 20px 8px !important; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.admin-filters input, .admin-filters select { min-width: 160px; flex: 1; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; }
.admin-pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--text-secondary); }
.admin-actions { white-space: nowrap; }
.admin-actions .btn { margin-right: 4px; }
.admin-size-row { display: flex; align-items: center; gap: 8px; }
.admin-size-row input { flex: 1; }
.admin-size-row span { color: var(--text-secondary); }
.admin-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.admin-modal[hidden] { display: none !important; }
.admin-modal-card {
  background: #fff;
  border-radius: 10px;
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  padding: 16px 20px 20px;
  box-shadow: var(--shadow);
}
.admin-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.admin-kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; font-size: 13px; }
.admin-kv .k { color: var(--text-secondary); }
.admin-kv .v { word-break: break-all; white-space: pre-wrap; }
.admin-modal-actions { margin-top: 16px; }
