:root {
  --bg: #0d1117;
  --bg-2: #151b24;
  --bg-3: #1c2431;
  --line: #263041;
  --text: #e6edf6;
  --muted: #8b98ab;
  --accent: #4aa8ff;
  --accent-2: #2f7fd6;
  --bubble-me: #2563eb;
  --bubble-other: #1e2733;
  --ok: #35c07a;
  --warn: #ef6b6b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; }
input, textarea {
  font: inherit; color: var(--text); background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 10px; outline: none; padding: 9px 12px;
}
input:focus, textarea:focus { border-color: var(--accent); }
.ghost { background: transparent; color: var(--muted); font-size: 16px; padding: 6px 8px; }
.ghost:hover { color: var(--text); background: var(--bg-3); }

/* ── 登录 ── */
.login { height: 100%; display: grid; place-items: center; background: radial-gradient(1200px 600px at 50% -10%, #17304d, var(--bg)); }
.login-card { width: 320px; padding: 32px 28px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; display: grid; gap: 12px; }
.logo { font-size: 44px; text-align: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 22px; letter-spacing: 2px; }
.login-card .sub { margin: 0 0 6px; text-align: center; color: var(--muted); font-size: 12px; }
.login-card label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.login-card button { margin-top: 8px; padding: 11px; background: var(--accent); color: #04121f; font-weight: 600; }
.login-card button:hover { background: #63b4ff; }

/* 密码框右侧的显示/隐藏按钮 */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 38px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 14px;
  color: var(--muted); padding: 4px 8px; border-radius: 6px; line-height: 1;
  margin-top: 0 !important;
}
.pw-eye:hover { color: var(--text); background: transparent; }
.pw-eye.on { color: var(--accent); }

/* 记住登录那一行 */
.remember-row { display: flex !important; align-items: center; justify-content: space-between; gap: 8px; }
.remember-row .rem-left { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 12px; }
.remember-row input[type=checkbox] { width: 14px; height: 14px; }
.remember-row select {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); font: inherit; font-size: 12px; padding: 4px 8px;
}

/* 设置面板里的纯文本行 */
.blines { font-size: 13px; color: var(--text); padding: 2px 0; }
.beline { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px solid #1c2431; font-size: 12px; }
.belines-name { color: var(--text); }

/* 找回密码的弹层 */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.72); }
.modal.hidden { display: none; }
.modal-card {
  width: 340px; max-width: 92vw; padding: 26px 24px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 18px; display: grid; gap: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.modal-card h2 { margin: 0; font-size: 17px; text-align: center; }
.modal-card .sub { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
.modal-card input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.modal-card input:focus { border-color: #39678f; }
.modal-card button {
  margin-top: 4px; padding: 10px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--accent); color: #04121f; font-weight: 600; font-size: 13px;
}
.modal-card button.link { background: transparent; color: var(--muted); font-weight: 400; margin-top: 0; }
.modal-card button.link:hover { color: var(--text); }
.modal-card button:disabled { opacity: .55; cursor: not-allowed; }
.err { color: var(--warn); font-size: 12px; min-height: 16px; margin: 0; text-align: center; }
.link { background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 2px; }
.link:hover { color: var(--accent); }

/* ── 布局 ── */
/* 侧栏宽度可变：--sidebar-w 由拖拽或 localStorage 决定。
   隐藏时左右两栏合并成一栏，分隔条也一起收起来。 */
.app {
  height: 100%; display: grid;
  grid-template-columns: var(--sidebar-w, 288px) 1fr;
}
body.sidebar-hidden .app { grid-template-columns: 1fr; }
body.sidebar-hidden .sidebar,
body.sidebar-hidden .sidebar-resizer { display: none; }
.sidebar-resizer {
  position: absolute; top: 0; bottom: 0; left: calc(var(--sidebar-w, 288px) - 3px);
  width: 6px; cursor: col-resize; z-index: 6;
}
.sidebar-resizer:hover, .sidebar-resizer.dragging { background: rgba(88,166,255,.35); }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; position: relative; }
.me { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.me .name { font-weight: 600; }
.me .uid { font-size: 11px; color: var(--muted); }
/* 注意：原来这里是 `.me button { margin-left: auto }`——三个按钮各自抢空隙，
   把名字区挤到只剩 17px，名字被压成竖排。改成让名字区自己把按钮顶到右边。 */
.me button { margin-left: 0; flex: none; }
.me-info { margin-right: auto; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  background: linear-gradient(135deg, #2a6fb8, #1d4267); color: #dbeaff;
}
/* 有头像图时铺满整个方块（背景图方式，圆形/圆角由容器裁） */
.avatar.has-img {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
}
.avatar.clickable { cursor: pointer; }
.avatar.clickable:hover { filter: brightness(1.12); }
.search { padding: 10px 12px; display: flex; gap: 8px; align-items: center; }
.search input { width: 100%; flex: 1; }
.friend-btn { position: relative; padding: 8px 6px; font-size: 15px; }
.friend-btn .badge { position: absolute; top: -2px; right: -4px; font-size: 9px; min-width: 15px; height: 15px; }

/* 群公告条 */
/* 群公告条：展开显示三行，收起只留一行提示 */
.announce-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: #17222f; border-bottom: 1px solid var(--line);
  font-size: 12px; color: #a8c6e8;
}
.announce-bar.hidden { display: none; }
.ann-icon { flex: none; font-size: 13px; }
.ann-label {
  flex: none; color: var(--accent); font-weight: 600; font-size: 11px;
  border: 1px solid #2f5a80; border-radius: 5px; padding: 1px 6px;
}
.ann-text {
  flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.ann-text.expanded { -webkit-line-clamp: unset; max-height: 200px; overflow-y: auto; }
.ann-bar.collapsed .ann-text, .announce-bar.collapsed .ann-text { display: none; }
.announce-bar.collapsed .ann-label::after { content: '（点击展开）'; font-weight: 400; opacity: .7; }
.ann-toggle {
  flex: none; background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 11px; padding: 3px 9px; border-radius: 6px; cursor: pointer;
}
.ann-toggle:hover { border-color: var(--accent); color: var(--accent); }
.title-wrap { min-width: 0; }

/* 右侧抽屉 */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px; max-width: 92vw; z-index: 20;
  background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(0,0,0,.45);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 19; }
.drawer.wide { width: 600px; max-width: 96vw; }

/* 聊天记录 */
.rec-conv { font-size: 13px; color: var(--muted); }
.rec-search input {
  width: 100%; background: var(--bg-3); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.rec-search input:focus { border-color: #39678f; }
.rec-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.rec-tab {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 5px 9px; border-radius: 7px; display: flex; align-items: center; gap: 4px;
}
.rec-tab:hover { background: var(--bg-3); color: var(--text); }
.rec-tab.active { background: #23405c; color: #9ecbff; }
.rec-count { font-size: 10px; opacity: .7; }
.rec-list { display: flex; flex-direction: column; gap: 2px; }
.rec-day {
  font-size: 11px; color: var(--muted); padding: 12px 2px 6px;
  border-bottom: 1px solid #1c2431; margin-bottom: 4px;
}
.rec-row { display: flex; gap: 9px; padding: 8px 4px; border-radius: 8px; cursor: pointer; }
.rec-row:hover { background: var(--bg-3); }
.rec-row .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; flex: none; }
.rec-main { min-width: 0; flex: 1; }
.rec-head { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted); }
.rec-nick { color: #9ecbff; }
.rec-tag { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #23405c; color: #9ecbff; }
.rec-body { font-size: 13px; color: var(--text); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; padding: 6px 0; }
.rec-cell {
  aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--bg-3);
  display: grid; place-items: center; cursor: pointer;
}
.rec-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rec-ph { color: var(--muted); font-size: 12px; }
.rec-file {
  display: flex; gap: 10px; align-items: center; padding: 9px 6px;
  border-bottom: 1px solid #1c2431; cursor: pointer; border-radius: 8px;
}
.rec-file:hover { background: var(--bg-3); }
.rec-empty { padding: 28px 0; text-align: center; color: var(--muted); font-size: 13px; }
.rec-filter { display: flex; align-items: center; gap: 8px; }
.rec-filter-box { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rec-filter-box input[type=date] {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; color: var(--text); font: inherit; font-size: 12px;
}
.rec-filter-label { font-size: 11px; color: var(--muted); }
.rec-filter-on { font-size: 11px; color: var(--accent); }
.rec-more { align-self: center; margin-top: 8px; }

/* 消息右键菜单 */
.ctx-menu {
  position: fixed; z-index: 40; background: #1b2330; border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; min-width: 132px; box-shadow: 0 12px 34px rgba(0,0,0,.55);
}
.ctx-item {
  display: block; width: 100%; text-align: left; background: transparent; border: none;
  color: var(--text); font-size: 13px; padding: 8px 12px; border-radius: 7px; cursor: pointer;
}
.ctx-item:hover { background: #26313f; }

/* 多选模式：每条消息左侧出现勾选圈，底部换成操作栏 */
body.select-mode .msg { cursor: pointer; padding-left: 26px; position: relative; }
body.select-mode .msg:hover { background: rgba(88,166,255,.06); }
body.select-mode .msg::before {
  content: '○'; position: absolute; left: 2px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: #6b7a8d; line-height: 1;
}
body.select-mode .msg.selected::before { content: '◉'; color: var(--accent); }
body.select-mode .msg.selected .bubble { outline: 1px solid rgba(88,166,255,.65); }
body.select-mode .msg .tools { display: none; }
body.select-mode .composer { display: none; }

.select-bar {
  display: flex; align-items: center; gap: 10px; padding: 11px 16px;
  border-top: 1px solid var(--line); background: #1d2c3d; font-size: 13px;
}
.select-bar.hidden { display: none; }
.select-bar .sb-actions { margin-left: auto; display: flex; gap: 6px; }
.select-bar .dbtn { padding: 6px 14px; }

/* 截图框选（仿 QQ）：拖选后保留选区，四角/四边可调整，底部工具条确认 */
.crop-overlay { position: fixed; inset: 0; z-index: 50; cursor: crosshair; user-select: none; overflow: hidden; }
.crop-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; }
/* 四块遮罩把选区以外压暗（比整屏半透明更能看清选了什么），不能挡鼠标 */
.crop-shade { position: absolute; background: rgba(0,0,0,.55); pointer-events: none; }
.crop-box {
  position: absolute; border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 0 0 100vmax rgba(0,0,0,0);
  cursor: move;
}
.crop-box.hidden { display: none; }
/* 8 个控制点：四角 + 四边中点 */
.crop-handle {
  position: absolute; width: 9px; height: 9px; margin: -5px;
  background: var(--accent); border: 1px solid #fff; border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.crop-h-nw { left: 0; top: 0; cursor: nwse-resize; }
.crop-h-n  { left: 50%; top: 0; cursor: ns-resize; }
.crop-h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.crop-h-e  { left: 100%; top: 50%; cursor: ew-resize; }
.crop-h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.crop-h-s  { left: 50%; top: 100%; cursor: ns-resize; }
.crop-h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.crop-h-w  { left: 0; top: 50%; cursor: ew-resize; }
/* 选区下方的操作条 */
.crop-toolbar {
  position: absolute; display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 9px;
  background: rgba(21,27,36,.94); border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0,0,0,.45); z-index: 2;
}
.crop-toolbar.hidden { display: none; }
.crop-size { font-size: 12px; color: var(--muted); padding: 0 4px; min-width: 74px; }
.crop-tbtn {
  height: 26px; padding: 0 12px; border-radius: 7px; font-size: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
}
.crop-tbtn:hover { border-color: var(--accent-2); }
.crop-tbtn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.crop-tbtn.primary:hover { background: var(--accent); border-color: var(--accent); }
.crop-hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 12px; background: rgba(0,0,0,.65); padding: 7px 14px;
  border-radius: 8px; pointer-events: none; white-space: nowrap;
}
.dsec { display: flex; flex-direction: column; gap: 8px; }
.dsec-title { font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.drow { display: flex; gap: 8px; align-items: center; }
.drow input[type=text], .drow input:not([type]) {
  flex: 1; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--text);
}
.dsec textarea {
  width: 100%; min-height: 64px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; color: var(--text); resize: vertical; font: inherit; font-size: 13px;
}
.dbtn {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; white-space: nowrap;
}
.dbtn:hover { border-color: var(--accent); color: var(--accent); }
.dbtn.primary { background: var(--accent); color: #04121f; border-color: transparent; font-weight: 600; }
.dbtn.danger:hover { border-color: var(--warn); color: var(--warn); }
.dbtn:disabled { opacity: .45; }
.member-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #1c2431; }
.member-row .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.member-row .mname { flex: 1; min-width: 0; }
.member-row .mname b { font-weight: 500; font-size: 13px; }
.member-row .mmeta { font-size: 10px; color: var(--muted); }
.member-row .mops { display: flex; gap: 4px; }
.member-row .mops button { font-size: 11px; padding: 3px 7px; }
.tag { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #23405c; color: #9ecbff; margin-left: 4px; }
.tag.owner { background: #4a3a12; color: #ffcc66; }
.tag.muted { background: #4a1f1f; color: #ff9d9d; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.switch input { width: 16px; height: 16px; }
.conv-list { list-style: none; margin: 0; padding: 4px 8px 8px; overflow-y: auto; flex: 1; }
.conv-list li {
  display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 12px; cursor: pointer;
}
.conv-list li:hover { background: var(--bg-3); }
.conv-list li.active { background: #1b3550; }
.conv-list .cname { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-list .clast { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-list .cmeta { min-width: 0; flex: 1; }
/* 两行布局：上排「昵称 … 时间」，下排「最后一条 … 未读角标」 */
.conv-list .ctop { display: flex; align-items: baseline; gap: 6px; }
.conv-list .cbot { display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.conv-list .ctime {
  flex: none; margin-left: auto; font-size: 10px; color: #6b7a8d;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.conv-list li.active .ctime { color: #8fa9c4; }
.conv-list .cbot .clast { flex: 1; min-width: 0; }
.conv-list .cbot .badge { flex: none; }
.badge { background: var(--warn); color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; }
.badge.soft { width: 8px; height: 8px; min-width: 8px; padding: 0; background: #5a6b7d; }

/* 会话列表的标记与拖拽 */
.cname { display: flex; align-items: center; gap: 4px; min-width: 0; }
.cflag { font-size: 10px; opacity: .85; flex: none; }
.cflag.star { filter: drop-shadow(0 0 3px rgba(255,200,80,.6)); }
.conv-list li.pinned { background: rgba(88,166,255,.05); }
.conv-list li.muted .clast { opacity: .55; }
.conv-list li.dragging { opacity: .4; }
.conv-list li.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.conv-list li.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.conv-list li[draggable="true"] { cursor: grab; }
.conv-list li[draggable="true"]:active { cursor: grabbing; }

/* Emoji 选择器 */
.panel-tabs { display: flex; gap: 4px; }
.pt-tab {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 5px 10px; border-radius: 7px;
}
.pt-tab:hover { background: var(--bg-3); color: var(--text); }
.pt-tab.active { background: #23405c; color: #9ecbff; }
.emoji-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px; padding: 6px 4px; max-height: 210px; overflow-y: auto;
}
.emoji-cell {
  background: transparent; border: none; cursor: pointer; font-size: 20px;
  line-height: 1; padding: 5px 0; border-radius: 7px;
}
.emoji-cell:hover { background: var(--bg-3); }

/* @ 提及候选 */
.mention-panel {
  position: absolute; z-index: 25; background: #1b2330; border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; min-width: 180px; max-height: 220px; overflow-y: auto;
  box-shadow: 0 12px 34px rgba(0,0,0,.55);
}
.mention-panel.hidden { display: none; }
.mention-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--text);
}
.mention-item:hover, .mention-item.active { background: #26313f; }
.mention-item .avatar { width: 22px; height: 22px; border-radius: 7px; font-size: 10px; }
.msg .bubble.at-me { box-shadow: 0 0 0 1px var(--warn); }
.at-tag { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: var(--warn); color: #fff; margin-right: 5px; }

/* 机器人控制台 */
.bline { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.burl { display: flex; align-items: center; gap: 8px; }
.burl code {
  flex: 1; min-width: 0; background: var(--bg-3); border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font-size: 11px; color: var(--accent); overflow-x: auto; white-space: nowrap;
}
.warnline { color: #d9a13a !important; }
.bselect {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); padding: 7px 10px; font: inherit; font-size: 13px;
}
.bevents { display: flex; flex-direction: column; gap: 1px; max-height: 190px; overflow-y: auto; }
.bevent {
  display: flex; gap: 8px; font-size: 11px; padding: 4px 6px; border-radius: 5px;
  font-family: Consolas, ui-monospace, monospace;
}
.bevent .bet { color: var(--muted); flex: none; }
.bevent .beb { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bevent.error { background: rgba(220,80,80,.12); }
.bevent.error .beb { color: #ff9d9d; }
.bevent.connect, .bevent.disconnect { background: rgba(88,166,255,.08); }
.bcaps { display: flex; flex-direction: column; gap: 1px; max-height: 220px; overflow-y: auto; }
.bcap { display: flex; align-items: baseline; gap: 8px; font-size: 11px; padding: 3px 6px; }
.bcap code { color: var(--text); }
.bcap.ok .bcaps-status { color: var(--ok); }
.bcap.degraded .bcaps-status { color: #d9a13a; }
.bcap.unsupported .bcaps-status { color: var(--warn); }
.bcaps-status { flex: none; width: 12px; }
.bcaps-note { color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 侧栏视图切换（消息 / 联系人）── */
.side-tabs { display: flex; gap: 2px; padding: 8px 10px 0; }
.side-tab {
  flex: 1; background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; padding: 7px 0 8px; border-radius: 8px 8px 0 0;
  position: relative; display: flex; align-items: center; justify-content: center; gap: 5px;
  border-bottom: 2px solid transparent;
}
.side-tab:hover { color: var(--text); background: #161d27; }
.side-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.side-tab .badge { position: static; }

.side-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* 联系人的两个快捷入口 */
.contact-rows { display: flex; flex-direction: column; gap: 1px; padding: 2px 8px 8px; }
.contact-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: var(--text); font-size: 13px; padding: 9px 10px; border-radius: 8px; text-align: left;
}
.contact-row:hover { background: var(--bg-3); }
.cr-icon {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  background: #26313f; border-radius: 8px; font-size: 14px;
}
.cr-label { flex: 1; }
.cr-arrow { color: var(--muted); font-size: 15px; }

/* 好友 / 群聊 二级标签 */
.contact-tabs { display: flex; gap: 4px; padding: 0 10px 6px; }
.ct-tab {
  flex: 1; background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 12px; padding: 6px 0; border-radius: 7px;
}
.ct-tab:hover { background: var(--bg-3); color: var(--text); }
.ct-tab.active { background: #23405c; color: #9ecbff; }

.contact-list { flex: 1; overflow-y: auto; list-style: none; padding: 0 6px 8px; margin: 0; }
.contact-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px;
  border-radius: 9px; cursor: pointer;
}
.contact-item:hover { background: var(--bg-3); }
.contact-item .avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; flex: none; }
.ci-main { min-width: 0; flex: 1; }
.ci-name { font-size: 13px; display: flex; align-items: center; gap: 5px; }
.ci-sub { font-size: 11px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-group-title { font-size: 10px; color: var(--muted); letter-spacing: .5px; padding: 10px 9px 4px; }
.contact-empty { padding: 24px 10px; text-align: center; color: var(--muted); font-size: 12px; }
.contact-group-head {
  display: flex; align-items: center; gap: 6px; padding: 8px 9px 4px;
  font-size: 11px; color: var(--muted); cursor: pointer; user-select: none;
}
.contact-group-head:hover { color: var(--text); }
.cgh-arrow { font-size: 9px; width: 10px; }
.cgh-name { flex: 1; }
.cgh-count { font-size: 10px; opacity: .7; }
.msg-hit-head {
  font-size: 10px; color: var(--muted); letter-spacing: .5px;
  padding: 10px 10px 4px !important; cursor: default !important;
  border-top: 1px solid var(--line); margin-top: 4px;
}
.msg-hit-head:hover { background: transparent !important; }
.msg-hit { flex-direction: column; align-items: stretch !important; gap: 2px !important; }
.mh-top { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); }
.mh-conv { color: #9ecbff; }
.mh-time { margin-left: auto; }
.mh-tag { font-size: 9px; padding: 1px 5px; border-radius: 4px; background: #3a3320; color: #d9c27a; }
.mh-body { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mh-body mark { background: #4a3a12; color: #ffd479; border-radius: 3px; padding: 0 1px; }
@keyframes flashHit { 0%,100% { background: transparent; } 30% { background: #2b4a6b; } }
.msg.flash .bubble { animation: flashHit 1.8s ease; }
.side-foot { display: flex; gap: 8px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.dot.on { background: var(--ok); }

/* ── 聊天区 ── */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head { display: flex; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.chat-head .title { font-weight: 600; }
.chat-head .hint { font-size: 11px; color: var(--muted); }
.head-actions { margin-left: auto; display: flex; gap: 4px; }
.messages { flex: 1; overflow-y: auto; padding: 18px 22px 8px; display: flex; flex-direction: column; gap: 12px; }
.messages > :first-child { margin-top: auto; }
.time-divider { align-self: center; font-size: 11px; color: var(--muted); opacity: .75; padding: 2px 10px; }
.typing { height: 16px; padding: 0 24px; font-size: 11px; color: var(--muted); }

.msg { display: flex; gap: 10px; max-width: min(680px, 76%); }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .bubble { background: var(--bubble-other); padding: 8px 12px; border-radius: var(--radius); word-break: break-word; white-space: pre-wrap; }
.msg.me .bubble { background: var(--bubble-me); }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msg .body { min-width: 0; }
.quote {
  display: block; font-size: 11px; color: #9ecbff; background: rgba(255,255,255,.06);
  border-left: 2px solid #4a7fb5; border-radius: 4px; padding: 4px 8px; margin-bottom: 5px;
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.quote:hover { background: rgba(255,255,255,.12); }
.quote.missing { color: var(--muted); border-left-color: var(--line); cursor: default; }
.msg .bubble.recalled { background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 12px; font-style: italic; padding: 4px 10px; }
.msg.me .bubble.recalled { background: transparent; color: var(--muted); }
.msg.me .bubble.recalled { background: transparent; color: var(--muted); }
.bubble.plain { background: transparent !important; padding: 0 !important; }
.bubble.encrypted::after { content: '🔐'; font-size: 9px; margin-left: 6px; opacity: .55; vertical-align: text-bottom; }

/* 端到端加密 */
.lock-badge { font-size: 14px; }
.lock-badge.off { opacity: .5; }
.lock-badge.locked { color: #d9c27a; }
.lock-badge.on { color: var(--ok); }
.lock-badge.alert { color: #fff !important; background: var(--warn) !important; animation: recPulse 1.4s infinite; }

/* 公钥变更告警 */
.keychange { border: 1px solid var(--warn); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: #2a1f1f; }
.kc-name { font-size: 13px; color: var(--text); }
.kc-fp { font-family: Consolas, ui-monospace, monospace; font-size: 11px; letter-spacing: .5px; word-break: break-all; }
.kc-fp.old { color: var(--muted); text-decoration: line-through; }
.kc-fp.new { color: #ff9d9d; }
.e2e-fp {
  font-family: Consolas, ui-monospace, monospace; font-size: 13px; letter-spacing: 1px;
  color: var(--accent); background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; word-break: break-all;
}
.msg img.media { max-width: 260px; max-height: 260px; border-radius: 10px; display: block; }
.msg .media-expired {
  display: inline-block; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 10px;
  background: var(--bg-3); color: var(--muted); font-size: 12px;
}
.msg .media-loading {
  display: inline-block; padding: 10px 14px; border-radius: 10px;
  background: var(--bg-3); color: var(--muted); font-size: 12px;
}

/* 文件消息卡片 */
.file-card {
  display: flex; align-items: center; gap: 10px; min-width: 190px; max-width: 260px;
  padding: 9px 12px; background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; text-decoration: none; color: var(--text); cursor: pointer;
  transition: border-color .12s;
}
.file-card:hover { border-color: var(--accent); }
.file-icon {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  background: #26313f; border-radius: 8px; font-size: 17px;
}
.file-meta { min-width: 0; }
.file-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg .quote { font-size: 11px; color: #a8c6e8; border-left: 3px solid #3d6c9c; padding-left: 8px; margin-bottom: 4px; opacity: .9; }
.msg.system { align-self: center; max-width: 90%; }
.msg.system .bubble { background: transparent; color: var(--muted); font-size: 11px; padding: 2px 8px; text-align: center; }
.msg .tools { display: flex; gap: 2px; opacity: 0; }
.msg:hover .tools { opacity: 1; }
.msg .tools button { background: transparent; color: var(--muted); font-size: 12px; padding: 2px 5px; }
.msg .tools button:hover { color: var(--text); }
.msg .sticker-img { width: 120px; height: 120px; object-fit: contain; }

/* 限流放行卡片 */
.rl-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.rl-actions button {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 10px; font-size: 12px;
}
.rl-actions button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.rl-actions button.rl-deny:hover:not(:disabled) { border-color: var(--warn); color: var(--warn); }
.rl-actions button:disabled { opacity: .45; cursor: default; }
.rl-note { margin-top: 6px; font-size: 11px; color: var(--muted); }

.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--bg-3); border-left: 3px solid var(--accent); border-radius: 8px; font-size: 12px; color: var(--muted); }
.reply-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); background: var(--bg-2); }

/* 输入区：一个带边框的盒子，上面是输入框，下面是工具栏 + 发送（照 QQ 的摆法） */
/* 输入区：工具栏在上、输入框在下、发送按钮浮在右下角。
   工具栏放上面是有原因的：安卓弹出软键盘时，底部那一行会被键盘顶出去，
   输入框的可视高度被压缩。放上面，键盘弹出时输入框紧贴键盘上沿。 */
.composer-box {
  position: relative; display: flex; flex-direction: column; background: #1b2330;
  border: 1px solid #2b3646; border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: #39678f; box-shadow: 0 0 0 2px rgba(57,103,143,.18); }
.composer textarea {
  border: none; background: transparent; padding: 2px 78px 9px 12px;
  resize: none; max-height: 140px; min-height: 30px; line-height: 1.5;
  font: inherit; font-size: 14px; color: var(--text); outline: none;
}
.composer-bar { position: absolute; right: 6px; bottom: 6px; display: flex; align-items: center; }
.toolbar { display: flex; align-items: center; gap: 1px; padding: 5px 8px 0; min-width: 0; }
.tool {
  background: transparent; border: none; color: #8b98a9; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 4px 7px; border-radius: 7px;
  transition: background .12s, color .12s;
}
.tool:hover { background: #26313f; color: #fff; }
.tool.recording { color: #fff; background: var(--warn); animation: recPulse 1.2s infinite; }
.mute-hint { font-size: 11px; color: var(--warn); margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-bar #send {
  background: var(--accent); color: #04121f; font-weight: 600;
  border: none; border-radius: 8px; padding: 6px 16px; font-size: 13px; cursor: pointer;
}
.composer-bar #send:hover { background: #63b4ff; }
.composer-bar #send:disabled { background: #26313f; color: var(--muted); cursor: not-allowed; }

/* 拖文件到窗口时盖一层提示 */
.drop-hint {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(13, 17, 23, .82); border: 3px dashed var(--accent);
  color: var(--accent); font-size: 16px; pointer-events: none;
}
@keyframes recPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.voice-dur { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--muted); vertical-align: middle; }

/* 自定义语音条：播放键 + 波形 + 时长 */
.voice-msg {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 18px; padding: 7px 14px 7px 7px; min-width: 200px;
}
.msg.me .voice-msg { background: #23405c; border-color: transparent; }
.vplay {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #04121f; font-size: 12px; display: grid; place-items: center;
  line-height: 1; padding: 0;
}
.vplay:hover { background: #63b4ff; }
.vwave { cursor: pointer; display: block; }
.vdur { font-size: 11px; color: var(--muted); flex: none; min-width: 26px; text-align: right; }
.msg.me .vdur { color: #b9d4ee; }
.vtrans {
  flex: none; background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-size: 10px; padding: 3px 7px; border-radius: 6px; cursor: pointer;
}
.vtrans:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.vtrans:disabled { opacity: .5; }
.vtext {
  margin-top: 5px; font-size: 12px; color: var(--muted); line-height: 1.5;
  border-left: 2px solid var(--line); padding-left: 8px; white-space: pre-wrap;
}

/* ── 表情面板 ── */
.panel { position: fixed; right: 18px; bottom: 86px; width: 320px; max-height: 380px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 10px; overflow-y: auto; }
.sticker-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--bg-3); border-radius: 10px; cursor: pointer; padding: 4px; }
.panel-add { text-align: center; padding: 10px; font-size: 12px; color: var(--accent); cursor: pointer; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #23303f; color: #dfe9f5; padding: 9px 18px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; font-size: 13px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: absolute; inset: 0; z-index: 5; }
  .app.chatting .sidebar { display: none; }
  .chat { height: 100%; }
  .chat-head { padding: 10px 12px; gap: 4px; }
  .messages { padding: 12px 12px 4px; gap: 10px; }
  .msg { max-width: 86%; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); gap: 8px; }
  .composer button { padding: 0 16px; }
  .panel { left: 10px; right: 10px; bottom: 78px; width: auto; }
  /* 移动端安全区：刘海与手势条 */
  .me { padding-top: calc(14px + env(safe-area-inset-top)); }
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
}

/* 显隐侧栏的按钮：一个在侧栏里（收起），一个在聊天头部（展开），互斥显示 */
body:not(.sidebar-hidden) #showSidebar { display: none; }
body.sidebar-hidden #hideSidebar { display: none; }
.me-info { min-width: 0; flex: 1 1 auto; }
.me .name, .me .uid { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 头像右侧塞了三个小按钮，把它们的占位压到最小，否则名字会被挤成竖排 */
.me > button.ghost { padding: 0 5px; font-size: 13px; flex: none; }
.me .avatar { flex: none; }
#btnBotConsole { font-size: 14px; }
#showSidebar { font-size: 17px; padding: 0 8px; }
#hideSidebar { font-size: 13px; padding: 0 6px; opacity: .6; }
#hideSidebar:hover { opacity: 1; }

/* 返回按钮只在移动端出现 */
.back { display: none; font-size: 26px; line-height: 1; padding: 0 6px 6px; }
@media (max-width: 760px) { .back { display: block; } }


/* ═══════════════════════════════════════════════════════════════════════════
 * 手机端功能取舍（body.is-mobile 由 app.js 按 UA / 宽度打上）
 *
 * 判断依据是"这个能力在触屏 WebView 里有没有意义"，不是"能不能实现"：
 *   · 截图：桌面端是抓整屏再框选，手机上 getDisplayMedia 要么不支持要么体验很差，
 *           而且系统自带截屏 —— 直接藏掉，别给一个点了报错的按钮。
 *   · 侧边栏拖宽：手机是一次只显示一栏的布局，宽度由 CSS 决定，拖拽手柄没意义。
 *   · 机器人控制台：那是给电脑上管桥接用的，手机上不该出现。
 * ═══════════════════════════════════════════════════════════════════════════ */
body.is-mobile #btnShot,
body.is-mobile .sidebar-resizer,
body.is-mobile #btnBotConsole {
  display: none !important;
}
/* 手机端输入区按钮稍大一点，手指点得准 */
body.is-mobile .tool {
  min-width: 34px;
  height: 34px;
  font-size: 17px;
}
body.is-mobile .encrypt-toggle {
  height: 32px;
  padding: 0 10px;
}
body.is-mobile #bar .main,
body.is-mobile #send {
  min-width: 56px;
  height: 34px;
}

/* ── 多账号切换（长按头像打开）───────────────────────────────────────── */
.acct-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px; border-radius: 10px; cursor: pointer;
}
.acct-row:hover { background: rgba(120, 170, 255, 0.08); }
.acct-row.on { background: rgba(120, 170, 255, 0.10); cursor: default; }
.acct-av {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  background: linear-gradient(135deg, #2a6fb8, #1d4267); color: #dbeaff;
  background-size: cover; background-position: center; background-repeat: no-repeat;
}
.acct-info { flex: 1; min-width: 0; }
.acct-nick { font-size: 14px; color: var(--fg, #e6edf7); }
.acct-sub { font-size: 11px; color: #5d6b7d; margin-top: 2px; }
.acct-cur {
  font-size: 11px; color: #7fb3ff; border: 1px solid rgba(127, 179, 255, 0.4);
  border-radius: 8px; padding: 2px 7px; flex: none;
}

/* 机器人无响应提示条 + 页脚状态警示色 */
.bot-notice {
  margin: 0 12px 6px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  background: rgba(255, 176, 32, .12);
  border: 1px solid rgba(255, 176, 32, .35);
  color: #ffb020;
}
#botState.warn { color: #ffb020; }


/* 资料卡上的「当前模型」：本地兜底时高亮，一眼看出它现在扛不扛得住上游宕机 */
.pc-model {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: #8b949e;
}
.pc-model.local {
  color: #ffb020;
}


/* 会话标题下的模型标注：本地兜底时高亮 */
.chat-hint.local-model,
#chatHint.local-model {
  color: #ffb020;
}

