/* bobo 主题样式 */
:root {
  --bg: #0e1621;
  --bg-secondary: #17212b;
  --bg-tertiary: #242f3d;
  --bg-hover: #202b36;
  --accent: #3390ec;
  --accent-hover: #4a9ff0;
  --accent-2: #3390ec;
  --text: #f5f5f5;
  --text-secondary: #708499;
  --text-hint: #6c7883;
  --border: #0e1621;
  --danger: #e53935;
  --bubble-in: rgba(255,255,255,0.09);
  --bubble-out: #2b5278;
  --bubble-out-meta: #6fb2e8;
  --bubble-in-meta: rgba(255,255,255,0.55);
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --sidebar-w: 320px;
  --header-h: 56px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f4f5;
  --bg-hover: #f0f0f1;
  --accent: #3390ec;
  --accent-hover: #2f88e0;
  --text: #000000;
  --text-secondary: #707579;
  --text-hint: #999;
  --border: #e6e6e6;
  --bubble-in: #ffffff;
  --bubble-out: #effdde;
  --bubble-out-meta: #71a14e;
  --bubble-in-meta: #a4adb5;
  --shadow: 0 1px 2px rgba(0,0,0,.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

/* ---------- 认证视图 ---------- */
.auth-view {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1f3a5f 0%, #0e1621 100%);
  padding: 20px;
}
:root[data-theme="light"] .auth-view { background: linear-gradient(135deg, #e7f1fa 0%, #fff 100%); }
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg-secondary);
  border-radius: 14px; padding: 32px 28px; box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.auth-logo { font-size: 56px; text-align: center; margin-bottom: 8px; }
.auth-title { text-align: center; font-size: 28px; margin-bottom: 24px; color: var(--accent); }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 10px; border-radius: 8px; background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 600; }
.auth-tab.active { background: var(--accent); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input {
  padding: 13px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-tertiary); color: var(--text); font-size: 15px; outline: none;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-form input::placeholder { color: var(--text-hint); }
#register-fields { display: flex; flex-direction: column; gap: 12px; }

/* ---------- 按钮 ---------- */
.btn-primary { padding: 10px 18px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.wide { width: 100%; padding: 13px; margin-top: 8px; }
.btn-secondary { padding: 10px 16px; border-radius: 8px; background: var(--bg-tertiary); color: var(--text); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px;
  display: flex; align-items: center; justify-content: center; color: var(--text-secondary);
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.send-btn { background: var(--accent); color: #fff; }
.icon-btn.send-btn:hover { background: var(--accent-hover); }
.icon-btn.send-btn.disabled { opacity: .5; cursor: default; }

/* ---------- 主布局 ---------- */
.app-view { display: flex; height: 100vh; }

/* 侧栏 */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100%;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-header {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px 0 12px;
}
.sidebar-actions { display: flex; gap: 2px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px; overflow: hidden;
  background: var(--accent); user-select: none; position: relative;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 54px; height: 54px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.sidebar-search { padding: 6px 10px; margin-bottom: 4px; }
.sidebar-search input {
  width: 100%; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-tertiary); color: var(--text); outline: none; font-size: 14px;
}
.sidebar-search input::placeholder { color: var(--text-hint); }

/* 聊天列表 */
.chat-list { flex: 1; overflow-y: auto; }
.chat-item {
  display: flex; gap: 12px; padding: 8px 12px; align-items: center; cursor: pointer;
  transition: background .12s;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--accent); }
.chat-item.active .chat-title, .chat-item.active .chat-preview, .chat-item.active .chat-time, .chat-item.active .chat-badge { color: #fff; }
.chat-item-main { flex: 1; min-width: 0; }
.chat-item-row { display: flex; justify-content: space-between; align-items: baseline; }
.chat-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 12px; color: var(--text-hint); flex-shrink: 0; }
.chat-preview {
  font-size: 13.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; justify-content: space-between; align-items: center; margin-top: 2px;
}
.chat-badge {
  background: var(--accent); color: #fff; border-radius: 50%; min-width: 20px; height: 20px;
  font-size: 12px; display: flex; align-items: center; justify-content: center; padding: 0 5px; flex-shrink: 0;
}
.premium-star { color: gold; font-size: 12px; }

/* 主面板 */
.main-pane { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-secondary); gap: 10px;
}
.empty-illustration { font-size: 80px; opacity: .3; }
.empty-state h2 { color: var(--text); }
.empty-state p { color: var(--text-hint); font-size: 14px; }

/* 聊天视图 */
.chat-view { flex: 1; display: flex; flex-direction: column; height: 100%; }
.chat-header {
  height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px 0 8px; background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header-peer { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.chat-header-peer .avatar { width: 42px; height: 42px; }
.chat-header-peer > div:not(.avatar) { min-width: 0; }
.chat-header-title { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-sub { font-size: 12.5px; color: var(--text-secondary); }
.chat-header-actions { display: flex; gap: 4px; }

/* 消息区 */
.messages {
  flex: 1; overflow-y: auto; padding: 16px 10px; display: flex; flex-direction: column;
  gap: 0; background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='40' cy='40' r='1.5' fill='%23242830'/%3E%3C/svg%3E");
}
:root[data-theme="light"] .messages { background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='40' cy='40' r='1.5' fill='%23e6e6e6'/%3E%3C/svg%3E"); }
.msg-date {
  align-self: center; font-size: 12px; color: var(--text-hint); padding: 6px 12px;
  margin: 10px 0; background: var(--bg-secondary); border-radius: 14px; position: relative; z-index: 1;
}
.msg-row { display: flex; align-items: flex-end; margin: 1px 0; }
.msg-row.out { justify-content: flex-end; }
.msg-avatar { margin-right: 8px; width: 34px; height: 34px; flex-shrink: 0; margin-bottom: 2px; }
.msg-avatar img, .msg-avatar span {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; display: flex;
  align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
}
.bubble {
  max-width: 78%; padding: 7px 12px 6px; border-radius: 16px; background: var(--bubble-in);
  box-shadow: var(--shadow); position: relative; font-size: 15px; line-height: 1.35; word-wrap: break-word;
  white-space: pre-wrap;
}
.msg-row.out .bubble { background: var(--bubble-out); }
.bubble.tailed-in { border-bottom-left-radius: 16px; }
.bubble.tailed-out { border-bottom-right-radius: 6px; }
/* 分组：第一条衔接圆角，最后一条带小尾巴 */
.msg-row.grouped.in .bubble { border-top-left-radius: 8px; border-top-right-radius: 16px; }
.msg-row.grouped.out .bubble { border-top-right-radius: 8px; border-top-left-radius: 16px; }
/* Telegram 式圆角尾巴：在气泡角上画一个小圆角凸起 */
.bubble.bubble-tail {
  border-bottom-left-radius: 12px;
}
.msg-row.out .bubble.bubble-tail { border-bottom-right-radius: 12px; }
.bubble.bubble-tail::after {
  content: ''; position: absolute; bottom: 0; width: 10px; height: 16px; background: transparent;
}
/* 入站尾巴：左侧，圆角朝左下，颜色同气泡 */
.msg-row.in .bubble.bubble-tail::after {
  left: -10px;
  background: var(--bubble-in);
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
  border-bottom-left-radius: 12px;
}
/* 出站尾巴：右侧 */
.msg-row.out .bubble.bubble-tail::after {
  right: -10px;
  background: var(--bubble-out);
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-bottom-right-radius: 12px;
}
.msg-row.grouped { margin-top: -1px; }
/* 分组中间消息不显示尾巴，由最后一条显示 */
.msg-row.grouped:not(.last) .bubble { border-bottom-left-radius: 16px; border-bottom-right-radius: 16px; }
.bubble .bubble-content { margin-bottom: 2px; }
.bubble .bubble-content img, .bubble .bubble-content video {
  max-width: 320px; max-height: 320px; border-radius: 10px; display: block; margin: 4px 0; cursor: pointer;
}
.bubble .bubble-content img.thumb { max-width: 240px; }
.bubble video { width: 300px; }
.bubble .file-wrap {
  display: flex; gap: 10px; align-items: center; padding: 6px; background: var(--bg-tertiary); border-radius: 10px; cursor: pointer;
}
.msg-meta {
  display: flex; align-items: center; gap: 3px; font-size: 11.5px; color: var(--bubble-in-meta);
  justify-content: flex-end; margin-top: 3px; user-select: none; position: relative; z-index: 1;
}
.msg-row.out .msg-meta { color: var(--bubble-out-meta); }
.checks { font-size: 13px; vertical-align: middle; }
.msg-actions { position: absolute; top: -14px; }
.bubble.editing { outline: 2px solid var(--accent); }
.quote {
  border-left: 3px solid var(--accent); padding: 4px 8px; margin-bottom: 6px; border-radius: 4px;
  background: var(--bg-tertiary); font-size: 13px; cursor: pointer;
}
.quote .q-title { font-weight: 600; color: var(--accent); }
.quote .q-body { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing-indicator { font-size: 12px; color: var(--text-hint); padding: 4px; display: flex; gap: 6px; align-items: center; }
.typing-dots span { animation: blink 1.4s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100% { opacity: .2; } 40% { opacity: 1; } }

/* 输入区 */
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 10px; background: var(--bg-secondary);
  border-top: 1px solid var(--border); flex-shrink: 0; min-height: 56px;
}

/* 引用回复条 */
.reply-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--bg-secondary);
  border-left: 3px solid var(--accent); flex-shrink: 0;
}
.reply-bar .reply-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-bar .reply-name { font-size: 13px; font-weight: 600; color: var(--accent); }
.reply-bar .reply-text { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 转发目标选择 */
.forward-list .pick-item { padding: 10px 16px; }
.composer-input {
  flex: 1; padding: 12px 14px; border-radius: 20px; background: var(--bg-tertiary);
  outline: none; font-size: 15px; max-height: 160px; overflow-y: auto; white-space: pre-wrap;
  min-height: 44px; max-width: 100%; word-break: break-word;
}
.composer-input:empty::before { content: attr(data-ph); color: var(--text-hint); }

/* ---------- 模态 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 420px; max-height: 85vh; background: var(--bg-secondary);
  border-radius: 14px; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { flex: 1; text-align: center; }
.modal > input, .modal > select { margin: 12px 16px 4px; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text); outline: none; }
.modal > select { width: calc(100% - 32px); }
.modal-list { overflow-y: auto; max-height: 320px; padding: 8px 0; }
.pick-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; cursor: pointer;
}
.pick-item:hover { background: var(--bg-hover); }
.pick-item .pick-check { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-hint); }
.pick-item.selected .pick-check { background: var(--accent); border-color: var(--accent); }
.chat-info-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.info-row { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--bg-tertiary); border-radius: 10px; }
.info-row .info-label { color: var(--text-secondary); font-size: 13px; }
.member-controls { display:flex; gap:5px; margin-left:auto; }
.member-controls button { border:0; border-radius:5px; padding:5px 7px; color:var(--text-secondary); background:var(--bg-secondary); cursor:pointer; font-size:11px; }
.member-controls button:hover { color:var(--text-primary); background:var(--bg-hover); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-tertiary); color: var(--text); padding: 12px 20px; border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4); z-index: 200; opacity: 0; transition: all .25s; font-size: 14px;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .sidebar { width: 100%; min-width: 100%; border-right: none; }
  .app-view.show-chat .sidebar { display: none; }
  .app-view:not(.show-chat) .main-pane { display: none; }
  .main-pane { width: 100%; }
  .bubble { max-width: 82%; }
  .bubble .bubble-content img, .bubble .bubble-content video { max-width: 100%; }
  .bubble video { width: 100%; }
  .auth-card { padding: 24px 20px; }
  /* 手机端：私聊不显示对端头像（贴近 Telegram），群组/频道仍显示 */
  .messages[data-chat-type="private"] .msg-avatar { display: none; }
  .messages[data-chat-type="private"] .msg-row.in { margin-left: 0; }
  .msg-avatar { margin-right: 6px; width: 30px; height: 30px; }
  .msg-avatar img, .msg-avatar span { width: 30px; height: 30px; font-size: 13px; }
}
/* 滚动条 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

/* ---------- 表情面板 ---------- */
.emoji-panel {
  position: absolute; bottom: 60px; right: 12px; width: 320px; max-width: calc(100% - 24px);
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.4); z-index: 90; padding: 10px;
  max-height: 240px; overflow-y: auto; display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.emoji-panel .emoji-cell {
  font-size: 24px; padding: 6px; text-align: center; cursor: pointer; border-radius: 8px;
}
.emoji-panel .emoji-cell:hover { background: var(--bg-hover); }
.emoji-grid { grid-column:1 / -1; display:grid; grid-template-columns:repeat(8, 1fr); gap:4px; }
.emoji-grid .emoji-cell { width:100%; border:0; }
.sticker-grid { grid-column:1 / -1; display:grid; grid-template-columns:repeat(4, 1fr); gap:10px; padding-top:12px; }
.sticker-cell { aspect-ratio:1; border-radius:10px; background:var(--bg-tertiary); font-size:44px; }
.sticker-cell:hover { background:var(--bg-hover); }
.gif-note { grid-column:1 / -1; color:var(--text-secondary); padding:12px 2px 8px; font-size:13px; }
.gif-grid { grid-column:1 / -1; display:grid; grid-template-columns:repeat(2, 1fr); gap:10px; }
.gif-cell { padding:0; border-radius:8px; overflow:hidden; background:var(--bg-tertiary); aspect-ratio:1.35; }
.gif-cell img { display:block; width:100%; height:100%; object-fit:cover; }
.emoji-drawer-head, .emoji-search, .emoji-categories { grid-column:1 / -1; }
.emoji-drawer-head { display:flex; align-items:center; justify-content:space-around; border-bottom:1px solid var(--border); margin:-10px -10px 0; padding:0 8px; }
.emoji-tab { padding:14px 12px 11px; color:var(--text-secondary); font-size:14px; }
.emoji-tab.active { color:var(--accent); box-shadow:inset 0 -2px var(--accent); }
.emoji-search { background:var(--bg-tertiary); color:var(--text-hint); border-radius:18px; padding:9px 12px; margin-top:8px; font-size:13px; }
.emoji-categories { color:var(--text-secondary); font-size:20px; padding:6px 3px; border-bottom:1px solid var(--border); }
.chat-view { position: relative; }

/* ---------- 个人资料 ---------- */
.profile-body { padding: 20px 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.profile-avatar { width: 96px; height: 96px; border-radius: 50%; font-size: 38px; display: flex; align-items: center; justify-content: center; color:#fff; background: var(--accent); overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.field-label { align-self: flex-start; font-size: 12px; color: var(--text-hint); margin: 8px 4px 2px; }
.profile-body input { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text); outline: none; }
#btn-change-avatar { margin-top: 4px; }

/* 频道/群组横幅图标 */
.chat-header-sub .group-badge { display:inline-block; padding:2px 8px; border-radius:6px; background:var(--accent-2); color:#fff; font-size:11px; }

/* 聊天信息管理操作区 */
.chat-info-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.chat-info-actions .btn-secondary, .chat-info-actions .btn-danger { padding: 11px; border-radius: 8px; width: 100%; }
.chat-info-actions .btn-danger { background: var(--danger); color: #fff; }
#new-group-create:disabled { opacity: .6; cursor: not-allowed; }

/* 贴纸/大表情突出显示 */
.msg-row .bubble.sticker-bubble { background: transparent; box-shadow:none; padding:4px; }
.sticker-img { font-size: 96px; display:block; }

/* 贴纸大表情 */
.sticker-big { font-size: 58px; line-height: 1; }

/* 返回按钮：桌面隐藏，移动端显示（基础规则需在媒体查询之前，移动端以更高优先级覆盖） */
.back-btn { display: none; }
html[data-mobile="1"] .back-btn { display: flex; }

/* 消息进入动画 */
.msg-row { animation: msgIn .18s ease-out; }
@keyframes msgIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: none; } }

/* 关注/不关注聊天的未读序号动画 */
.chat-badge { animation: badgePop .2s ease-out; }
@keyframes badgePop { from { transform: scale(.6); } to { transform: scale(1); } }

/* Telegram Desktop inspired application shell */
:root {
  --sidebar-w: 360px;
  --accent: #5288c1;
  --accent-hover: #6496ca;
  --bg: #0f1720;
  --bg-secondary: #17212b;
  --bg-tertiary: #242f3d;
  --border: rgba(255,255,255,.07);
  --bubble-out: #2b5278;
}
:root[data-theme="light"] {
  --bg: #dfe6ec;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f3f5;
  --border: #e7e9eb;
  --bubble-out: #e5f5cf;
  --bubble-out-meta: #6c9d54;
}
.auth-view { background: #17212b; }
.auth-card { max-width: 360px; padding: 40px 30px 34px; border-radius: 10px; box-shadow: 0 10px 48px rgba(0,0,0,.35); }
.auth-logo { width: 78px; height: 78px; margin: 0 auto 18px; border-radius: 50%; background: var(--accent); display:flex; align-items:center; justify-content:center; color:#fff; transform: rotate(-28deg); }
.auth-logo span { font-size: 40px; margin-left: 6px; }
.auth-title { margin-bottom: 6px; color: var(--text); font-weight: 700; }
.auth-caption { color: var(--text-secondary); text-align:center; font-size:14px; margin-bottom: 28px; }
.auth-tabs { border-bottom: 1px solid var(--border); gap: 0; }
.auth-tab { border-radius: 0; background: transparent; padding: 11px; }
.auth-tab.active { background: transparent; color: var(--accent); box-shadow: inset 0 -2px var(--accent); }

.sidebar { position:relative; box-shadow: 1px 0 0 var(--border); border:0; z-index:5; }
.sidebar-header { padding: 0 8px; gap: 4px; }
.bobo-wordmark { color:var(--text); font-size:17px; font-weight:650; flex:1; letter-spacing:0; }
.sidebar-actions { margin-left:auto; }
.sidebar-header .icon-btn { width:40px; height:40px; font-size:21px; }
.menu-trigger { font-size:20px !important; }
.main-menu { position:absolute; top:52px; left:8px; z-index:50; width:270px; padding:8px; background:var(--bg-secondary); border:1px solid var(--border); border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.28); }
.main-menu button { width:100%; min-height:42px; display:flex; align-items:center; gap:17px; padding:8px 12px; text-align:left; color:var(--text); font-size:15px; border-radius:5px; }
.main-menu button:hover { background:var(--bg-hover); }
.main-menu button i.menu-switch { width:36px; height:20px; margin-left:auto; border-radius:12px; background:var(--bg-tertiary); position:relative; }
.main-menu button i.menu-switch::after { content:''; position:absolute; width:16px; height:16px; top:2px; left:2px; border-radius:50%; background:#94a5b4; transition:transform .18s,background .18s; }
.main-menu button i.menu-switch.on { background:var(--accent); }
.main-menu button i.menu-switch.on::after { transform:translateX(16px); background:#fff; }
.main-menu .menu-profile { height:70px; margin-bottom:5px; border-bottom:1px solid var(--border); padding:6px 5px 12px; }
.menu-profile .avatar { width:44px; height:44px; }
.menu-profile b,.menu-profile small { display:block; }
.menu-profile small { color:var(--text-secondary); margin-top:3px; font-size:12px; }
.sidebar-search { position:relative; padding:4px 12px 8px; margin:0; }
.sidebar-search input { height:38px; padding:8px 14px 8px 38px; border-radius:8px; border:0; background:var(--bg-tertiary); }
.search-mark { position:absolute; z-index:1; top:11px; left:24px; font-size:23px; color:var(--text-hint); line-height:1; }
.chat-filters { display:flex; gap:20px; padding:0 20px; height:36px; border-bottom:1px solid var(--border); }
.chat-filter { position:relative; color:var(--text-secondary); font-size:14px; min-width:34px; }
.chat-filter.active { color:var(--accent); font-weight:600; }
.chat-filter.active::after { content:''; position:absolute; bottom:0; height:2px; background:var(--accent); left:0; right:0; }
.chat-list { padding:3px 0 80px; }
.chat-item { min-height:70px; gap:11px; padding:8px 14px; }
.chat-item:hover { background:var(--bg-hover); }
.chat-item.active { background:rgba(82,136,193,.22); }
.chat-item.active .chat-title,.chat-item.active .chat-preview,.chat-item.active .chat-time { color:var(--text); }
.chat-item .avatar { width:52px; height:52px; font-size:18px; }
.chat-title { font-size:15px; font-weight:650; }
.chat-preview { font-size:13.5px; margin-top:4px; }
.chat-time { font-size:12px; color:var(--text-secondary); }
.chat-badge { min-width:19px; height:19px; background:var(--accent); font-size:11px; }
.new-message-fab { position:absolute; right:18px; bottom:20px; width:54px; height:54px; border-radius:50%; background:var(--accent); color:#fff; font-size:25px; box-shadow:0 3px 9px rgba(0,0,0,.32); z-index:4; }
.new-message-fab:hover { background:var(--accent-hover); }
.search-results { position:absolute; top:106px; right:8px; left:8px; max-height:55vh; overflow:auto; z-index:20; background:var(--bg-secondary); border:1px solid var(--border); box-shadow:0 8px 26px rgba(0,0,0,.28); border-radius:8px; }
.search-result-title { padding:11px 14px 5px; color:var(--text-secondary); font-size:12px; text-transform:uppercase; }
.search-result { display:block; width:100%; padding:10px 14px; text-align:left; color:var(--text); }
.search-result:hover { background:var(--bg-hover); }
.search-result b { display:block; font-size:14px; margin-bottom:3px; }
.search-result span { display:block; color:var(--text-secondary); font-size:13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

.main-pane { background:#101820; }
:root[data-theme="light"] .main-pane { background:#e7edf1; }
.empty-state { position:relative; color:var(--text-secondary); }
.empty-state::before { content:'Bobo Messenger'; padding:9px 15px; border-radius:18px; background:rgba(0,0,0,.26); color:#fff; font-size:14px; }
.empty-illustration,.empty-state h2,.empty-state p { display:none; }
.chat-header { height:60px; padding:0 13px; background:var(--bg-secondary); }
.chat-header-peer .avatar { width:42px; height:42px; }
.chat-header-title { font-weight:650; }
.chat-header-sub { color:var(--accent); }
.messages { padding:18px max(16px, 8vw); background-color:#0f1720; }
:root[data-theme="light"] .messages { background-color:#dce5eb; }
.msg-row { flex:0 0 auto; align-self:stretch; }
.bubble { flex:0 0 auto; align-self:flex-end; width:auto; height:auto; min-height:0; max-width:min(520px, 68%); border-radius:10px; padding:6px 9px 4px; font-size:14px; line-height:1.34; }
.bubble { color:#f4f8fc; }
:root[data-theme="light"] .bubble { color:#202a33; }
.bubble { white-space:normal; }
.bubble .bubble-content { color:inherit; white-space:pre-wrap; }
.msg-row { margin:2px 0; }
.msg-avatar { width:36px; height:36px; }
.msg-avatar img,.msg-avatar span { width:36px; height:36px; }
.msg-date { background:rgba(24,37,48,.72); color:#fff; box-shadow:0 1px 2px rgba(0,0,0,.15); border-radius:12px; }
:root[data-theme="light"] .msg-date { background:rgba(96,116,130,.74); color:#fff; }
.msg-meta { font-size:10.5px; margin-top:2px; }
.composer { gap:6px; padding:8px max(14px, 8vw); min-height:62px; background:var(--bg-secondary); }
.composer-input { min-height:42px; padding:11px 14px; border-radius:8px; background:var(--bg-tertiary); }
.icon-btn.send-btn { width:42px; height:42px; }
.message-reactions { display:flex; flex-wrap:wrap; gap:4px; margin:5px 0 -3px; }
.reaction { border:1px solid rgba(82,136,193,.28); border-radius:12px; padding:2px 7px; background:rgba(82,136,193,.1); color:var(--text); font-size:12px; line-height:17px; }
.reaction.mine { background:rgba(82,136,193,.35); border-color:var(--accent); }
.reaction-picker { display:flex; gap:5px; padding:7px; position:fixed; z-index:302; background:var(--bg-secondary); border:1px solid var(--border); border-radius:10px; box-shadow:0 4px 20px rgba(0,0,0,.35); }
.reaction-picker button { padding:4px; font-size:20px; border-radius:6px; }
.reaction-picker button:hover { background:var(--bg-hover); }
.msg-context-menu .menu-item:hover { background:var(--bg-hover); }

@media (max-width:760px) {
  :root { --sidebar-w:100%; }
  .sidebar-header { height:56px; }
  .chat-filters { height:34px; }
  .messages { padding:12px 9px; }
  .composer { padding:7px 8px; }
  .new-message-fab { bottom:17px; right:17px; }
  .main-menu { left:7px; top:50px; }
}

@media (min-width:1000px) {
  :root { --sidebar-w:clamp(360px, 23.5vw, 452px); }
  .sidebar { width:var(--sidebar-w); min-width:var(--sidebar-w); }
  .messages { padding-left:clamp(22px, 7vw, 150px); padding-right:clamp(22px, 7vw, 150px); }
}
@media (min-width:1100px) {
  .emoji-panel { top:0; right:0; bottom:0; width:490px; max-width:490px; max-height:none; overflow-y:auto; border:0; border-left:1px solid var(--border); border-radius:0; box-shadow:-8px 0 24px rgba(0,0,0,.18); padding:0 18px 18px; grid-template-columns:repeat(9, 1fr); gap:2px; }
  .emoji-drawer-head { margin:0 -18px; padding:0 22px; }
  .emoji-search { margin-top:14px; }
  .emoji-panel .emoji-cell { font-size:25px; padding:7px 4px; }
  .emoji-grid { grid-template-columns:repeat(9, 1fr); }
}
