/* ===== Talk Mobile · 暗色主题（与桌面端一致） ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg-0: #0a0d1f;
  --bg-1: #0f1226;
  --bg-2: #161a3a;
  --bg-3: #1d2348;
  --line: rgba(255,255,255,0.07);
  --line-strong: rgba(255,255,255,0.12);
  --text: #e9ecff;
  --text-dim: #a4abcf;
  --text-mute: #6e75a3;
  --accent: #7c8cff;
  --accent-2: #b06bff;
  --accent-grad: linear-gradient(135deg, #7c8cff 0%, #b06bff 100%);
  --danger: #ff6b8a;
  --success: #4ade80;
  --radius: 14px;
  --radius-sm: 10px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
html, body {
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
body {
  background:
    radial-gradient(800px 500px at 0% 0%, rgba(124,140,255,0.15), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(176,107,255,0.15), transparent 60%);
}
button { font: inherit; color: inherit; background: transparent; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* ===== Screens ===== */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  padding-top: var(--sat);
  transition: transform .22s ease, opacity .22s ease;
}
.screen.active { display: flex; }
.screen.slide-in { animation: slideInRight .22s ease; }
@keyframes slideInRight { from { transform: translateX(30%); opacity: .4; } to { transform: none; opacity: 1; } }

/* ===== Auth ===== */
#screen-auth { align-items: center; justify-content: center; }
.auth-wrap {
  width: 92%; max-width: 400px;
  padding: 28px 22px;
  background: linear-gradient(180deg, rgba(29,35,72,0.6), rgba(15,18,38,0.7));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
}
.auth-hero { text-align: center; margin-bottom: 18px; }
.auth-hero h1 { font-size: 26px; margin-top: 10px; }
.auth-hero p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }
.auth-tabs { display: flex; background: rgba(0,0,0,0.25); border-radius: 10px; padding: 4px; margin-bottom: 16px; }
.auth-tab { flex: 1; padding: 9px 0; border-radius: 7px; color: var(--text-dim); font-size: 14px; }
.auth-tab.active { background: var(--accent-grad); color: white; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 12px; color: var(--text-dim); }
.field input {
  height: 42px; padding: 0 12px;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  outline: none; font-size: 15px;
}
.field input:focus { border-color: var(--accent); }
.auth-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-bottom: 6px; }
.btn {
  height: 42px; padding: 0 16px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 14px;
}
.btn.primary { background: var(--accent-grad); color: white; }
.btn.full { width: 100%; }
.btn:active { transform: scale(0.98); }

/* ===== Top bar ===== */
.topbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(10,13,31,0.7);
}
.me { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.me-info { min-width: 0; }
.me-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 11px; color: var(--success); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-grad); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; position: relative; flex-shrink: 0;
}
.icon-btn:active { background: rgba(255,255,255,0.07); }
.badge {
  position: absolute; top: 3px; right: 3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger); color: white;
  border-radius: 8px; font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.chat-titles { flex: 1; min-width: 0; line-height: 1.25; }
.chat-title { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 11px; color: var(--text-mute); }

/* ===== Chat list ===== */
.list-wrap { flex: 1; overflow-y: auto; padding: 6px 8px; }
.list-wrap .empty { padding: 50px 20px; text-align: center; color: var(--text-mute); font-size: 13px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; border-radius: 12px; cursor: pointer;
}
.list-item:active { background: rgba(255,255,255,0.05); }
.list-item .info { flex: 1; min-width: 0; }
.list-item .name { font-size: 15px; font-weight: 500; }
.list-item .preview { font-size: 12px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.list-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--text-mute); }
.unread {
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent-grad); color: white;
  border-radius: 9px; font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.row-btn { padding: 8px 12px; font-size: 12px; height: 32px; border-radius: 8px; background: rgba(124,140,255,0.15); color: var(--text); }
.row-btn.primary { background: var(--accent-grad); color: #fff; }
.row-btn:disabled { opacity: .5; }
.list-hint { font-size: 11px; color: var(--text-mute); }

/* ===== Bottom tabs ===== */
.bottom-tabs {
  display: flex; flex-shrink: 0;
  border-top: 1px solid var(--line);
  background: rgba(10,13,31,0.85);
  padding-bottom: var(--sab);
}
.btab { flex: 1; padding: 13px 0; font-size: 13px; color: var(--text-mute); }
.btab.active { color: var(--text); background: rgba(124,140,255,0.10); }

/* ===== Messages ===== */
.messages {
  flex: 1; overflow-y: auto; padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { display: flex; gap: 8px; max-width: 86%; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { width: 32px; height: 32px; font-size: 12px; }
.bubble {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line-strong);
  border-radius: 14px 14px 14px 4px;
  padding: 9px 12px;
  font-size: 15px; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: anywhere;
  white-space: pre-wrap;
  user-select: text; -webkit-user-select: text;
}
.msg.me .bubble { background: var(--accent-grad); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.bubble .sender { font-size: 11px; color: var(--text-mute); margin-bottom: 2px; }
.msg.me .bubble .sender { color: rgba(255,255,255,0.85); }
.bubble .time { display: block; font-size: 10px; color: var(--text-mute); margin-top: 4px; }
.msg.me .bubble .time { color: rgba(255,255,255,0.7); }
.msg-text .bubble { white-space: pre-wrap; }
.msg-image .bubble { padding: 3px; background: transparent; border: none; }
.msg-image .bubble img { max-width: 220px; max-height: 260px; border-radius: 10px; }
.msg-file .bubble { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.file-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-grad); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 10px; flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-info .fname { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info .fsize { font-size: 11px; color: var(--text-mute); }
.msg.me .file-info .fsize { color: rgba(255,255,255,0.7); }
.msg-recalled .bubble { background: transparent !important; border: 1px dashed var(--line-strong); opacity: .6; }
.msg-recalled .recalled-text { font-size: 12px; color: var(--text-mute); font-style: italic; }

/* voice bubble */
.msg-voice .bubble {
  display: flex; align-items: center; gap: 10px;
  min-width: 110px; cursor: pointer; padding: 10px 12px;
}
.voice-play {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 12px; position: relative;
}
.voice-waves { display: flex; align-items: center; gap: 2px; height: 16px; flex: 1; }
.voice-waves i { display: block; width: 3px; border-radius: 2px; background: currentColor; opacity: .55; height: 6px; }
.msg-voice.playing .voice-waves i { animation: vw 0.9s ease-in-out infinite; }
.msg-voice.playing .voice-waves i:nth-child(2n) { animation-delay: .15s; }
.msg-voice.playing .voice-waves i:nth-child(3n) { animation-delay: .3s; }
@keyframes vw { 0%,100% { height: 4px; opacity: .4; } 50% { height: 14px; opacity: 1; } }
.voice-dur { font-size: 12px; opacity: .85; flex-shrink: 0; }

/* ===== Composer ===== */
.composer {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px calc(8px + var(--sab));
  border-top: 1px solid var(--line);
  background: rgba(10,13,31,0.8);
}
.composer textarea {
  flex: 1; min-height: 40px; max-height: 110px;
  padding: 9px 12px;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  outline: none; resize: none; font-size: 15px; line-height: 1.45;
}
.btn.send { padding: 0 14px; height: 40px; font-size: 13px; }
.recording-bar {
  flex: 1; display: flex; align-items: center; gap: 8px;
  min-height: 40px;
  background: rgba(255,107,138,0.08);
  border: 1px solid rgba(255,107,138,0.35);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rp 1.1s infinite; flex-shrink: 0; }
@keyframes rp { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.rec-time { font-weight: 600; font-size: 14px; color: var(--danger); flex-shrink: 0; }
.rec-hint { flex: 1; font-size: 12px; color: var(--text-dim); }
.rec-cancel { color: var(--text-dim); }

/* ===== Emoji panel ===== */
.emoji-panel {
  position: absolute; left: 0; right: 0; bottom: calc(64px + var(--sab));
  height: 280px;
  background: var(--bg-2);
  border-top: 1px solid var(--line-strong);
  display: flex; flex-direction: column;
  z-index: 60;
}
.emoji-tabs { display: flex; padding: 6px 10px 4px; border-bottom: 1px solid var(--line); }
.emoji-tab { flex: 1; height: 32px; font-size: 18px; opacity: .5; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.emoji-tab.active { background: rgba(124,140,255,0.18); opacity: 1; }
.emoji-grid {
  flex: 1; overflow-y: auto;
  display: grid; grid-template-columns: repeat(8, 1fr);
  gap: 2px; padding: 8px; align-content: start;
}
.emoji-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 22px; border-radius: 6px;
}
.emoji-cell:active { background: rgba(124,140,255,0.2); }

/* ===== Bottom sheet ===== */
.sheet-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 78vh;
  background: var(--bg-2);
  border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: var(--sab);
  animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet header h3 { font-size: 15px; }
.sheet-body { padding: 14px 16px; overflow-y: auto; }
.req-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; background: rgba(0,0,0,0.2);
  border-radius: 10px; margin-bottom: 8px;
}
.req-card .name { flex: 1; font-size: 13px; }
.req-card .actions { display: flex; gap: 6px; }
.friend-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 8px; border-radius: 10px;
}
.friend-row .avatar { width: 34px; height: 34px; font-size: 12px; }
.friend-row .name { flex: 1; font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-inline { display: flex; gap: 8px; margin-bottom: 10px; }
.search-inline input {
  flex: 1; height: 38px; padding: 0 12px;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px; outline: none;
}

/* ===== 大气弹层（创建群组 / 群成员） ===== */
.sheet.modal-sheet { border-radius: 22px 22px 0 0; }
.modal-sheet .sheet-body { padding: 18px 20px calc(20px + var(--sab, 0px)); }
.cg-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 0 4px; }
.cg-hero .cg-icon {
  width: 68px; height: 68px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff;
  background: linear-gradient(135deg, #7c8cff, #b06bff);
  box-shadow: 0 10px 28px rgba(124, 140, 255, 0.35);
}
.cg-hero .cg-name-tip { font-size: 14px; font-weight: 600; }
.cg-hero .cg-sub { font-size: 12px; color: rgba(255,255,255,0.55); }
.cg-name {
  width: 100%; height: 50px; padding: 0 18px; margin-top: 16px;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 14px;
  outline: none; font-size: 15px; text-align: center;
}
.cg-name:focus { border-color: #7c8cff; box-shadow: 0 0 0 3px rgba(124,140,255,0.18); }
.cg-btn {
  width: 100%; height: 50px; margin-top: 16px;
  border: none; border-radius: 14px; font-size: 15px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #7c8cff, #b06bff);
  box-shadow: 0 6px 18px rgba(124,140,255,0.3);
}
.cg-btn:active { transform: scale(0.98); }
.cg-hint { margin-top: 12px; text-align: center; font-size: 12px; color: rgba(255,255,255,0.5); }

/* 添加好友大面板 */
.af-search { display: flex; gap: 10px; margin-top: 16px; }
.af-search input {
  flex: 1; height: 50px; padding: 0 18px;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 14px;
  outline: none; font-size: 15px;
}
.af-search input:focus { border-color: #7c8cff; box-shadow: 0 0 0 3px rgba(124,140,255,0.18); }
.af-search .af-search-btn {
  width: 84px; height: 50px; border: none; border-radius: 14px;
  font-size: 14px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #7c8cff, #b06bff);
  box-shadow: 0 6px 18px rgba(124,140,255,0.3);
}
.af-search .af-search-btn:active { transform: scale(0.98); }
.af-results { margin-top: 12px; max-height: 42vh; overflow-y: auto; }

/* 应用内图片查看器 */
#img-viewer {
  position: fixed; inset: 0; z-index: 999; display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.92); cursor: zoom-out;
}
#img-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.gi-members { margin: 6px 0 14px; }
.gi-member { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 12px; }
.gi-member .avatar { width: 36px; height: 36px; font-size: 13px; }
.gi-member .nm { flex: 1; font-size: 14px; }
.gi-member .nm small { display: block; color: rgba(255,255,255,0.45); font-size: 11px; }
.gi-section-title { font-size: 12px; color: rgba(255,255,255,0.5); margin: 14px 0 8px; letter-spacing: 1px; }
.gi-invite-row { display: flex; gap: 8px; }
.gi-invite-row input {
  flex: 1; height: 42px; padding: 0 14px;
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 12px; outline: none;
}
.gi-invite-row input:focus { border-color: #7c8cff; }
.gi-results { margin-top: 10px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: rgba(29,35,72,0.95); border: 1px solid var(--line-strong);
  color: var(--text); padding: 10px 18px; border-radius: 22px;
  font-size: 13px; z-index: 300; max-width: 80vw; text-align: center;
  transition: opacity .25s;
}
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }
