/* wa-multibox v2 —— WhatsApp 网页版观感，零 CDN、零构建。
 * 配色照 WhatsApp Web（浅色主题）：侧栏 #f0f2f5 / 面板白 / 聊天底 #efeae2 /
 * 发出气泡 #d9fdd3 / 主色 #00a884。 */

:root {
  --wa-green: #00a884;
  --wa-green-dark: #008069;
  --wa-teal: #005c4b;
  --bg: #f0f2f5;
  --panel: #ffffff;
  --panel-2: #f5f6f6;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --line: #e9edef;
  --text: #111b21;
  --muted: #667781;
  --muted-2: #8696a0;
  --chat-bg: #efeae2;
  --bubble-out: #d9fdd3;
  --bubble-in: #ffffff;
  --blue: #53bdeb;
  --danger: #ea0038;
  --warn: #a1690a;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --rail-w: 68px;
  --list-w: 360px;
}

* { box-sizing: border-box; }

/* ⚠️ 必须：`hidden` 属性敌不过作者样式里的 display ——
   否则被"隐藏"的浮层会盖住整页吃掉所有点击（页面看起来完全正常但点不动）。 */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", "Helvetica Neue", "PingFang SC",
        "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 auto; height: 48px; padding: 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--wa-green-dark); color: #fff; overflow: hidden;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logo { font-weight: 600; font-size: 15px; white-space: nowrap; flex: 0 0 auto; }
.tag { font-size: 11px; opacity: .8; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: nowrap; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: #ffd166; display: inline-block; }
.conn.up .dot { background: #7ef0c0; }
.conn.down .dot { background: #ff9a8b; }
.who { font-size: 12px; opacity: .9; white-space: nowrap; }

/* ---------------- 三栏骨架 ---------------- */
.app {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr);
  border-top: 1px solid #d1d7db;
  background: var(--bg);
}

/* 账号栏 */
.rail {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 6px;
  min-height: 0;
}
.rail-add {
  flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--wa-green); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.rail-add:hover { background: var(--wa-green-dark); }
.rail-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%;
  padding: 2px 0;
}
.rail-foot { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }

.acc {
  position: relative; width: 46px; height: 46px; flex: 0 0 auto; border: 0; padding: 0;
  background: transparent; cursor: pointer;
}
.acc-face {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: #fff; line-height: 1;
  background: linear-gradient(135deg, hsl(var(--h, 218) 58% 62%), hsl(var(--h, 218) 62% 44%));
  border: 2px solid transparent;
}
.acc.sel .acc-face { border-color: var(--wa-green); }
.acc-state {
  position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--muted-2); box-shadow: 0 0 0 2px var(--panel);
}
.acc-state.s-ready { background: #31a24c; }
.acc-state.s-qr, .acc-state.s-starting, .acc-state.s-reconnecting { background: #e0a800; }
.acc-state.s-error, .acc-state.s-conflict, .acc-state.s-logged_out { background: var(--danger); }

/* 面板通用 */
.panel { background: var(--panel); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.list-panel { border-right: 1px solid var(--line); }

/* 会话/联系人 切换条 */
.list-tabs {
  flex: 0 0 auto; display: flex; gap: 2px; padding: 6px 12px 0; border-bottom: 1px solid var(--line);
}
.list-tabs .tab {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px;
  padding: 7px 12px; border-radius: 8px 8px 0 0; cursor: pointer;
}
.list-tabs .tab.on { color: var(--wa-green-dark); font-weight: 600; box-shadow: inset 0 -2px 0 var(--wa-green); }

.list-head {
  flex: 0 0 auto; height: 60px; padding: 0 14px; display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
}
.list-head-info { min-width: 0; display: flex; flex-direction: column; }
.list-head-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-head-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, hsl(var(--h, 218) 55% 62%), hsl(var(--h, 218) 60% 45%));
  /* 真实头像绝对定位盖在首字母之上；加载失败时 img 被移除，露出首字母色块 */
  position: relative; overflow: hidden;
}
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.me { background: var(--muted-2); }

.list-search {
  flex: 0 0 auto; padding: 8px 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; background: var(--panel);
}
.search-ico { font-size: 12px; color: var(--muted-2); }
.list-search input {
  flex: 1 1 auto; min-width: 0; height: 32px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel-2); font: inherit; font-size: 13px; color: var(--text);
}
.chat-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

.chat-row {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.chat-row:hover { background: var(--hover); }
.chat-row.sel { background: var(--active); }
.chat-mid { flex: 1 1 auto; min-width: 0; }
.chat-line1 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--muted-2); flex: 0 0 auto; }
.chat-line2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.chat-prev {
  font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; min-width: 0;
}
.chat-flags { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.pill {
  font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted);
}
.badge {
  background: var(--wa-green); color: #fff; border-radius: 999px; min-width: 19px;
  padding: 0 6px; font-size: 11px; font-weight: 600; text-align: center; line-height: 19px;
}
.empty-list { padding: 22px 16px; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* ---------------- 对话区 ---------------- */
.thread-panel { position: relative; background: var(--chat-bg); }
.thread-head {
  flex: 0 0 auto; height: 60px; padding: 0 12px; display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); z-index: 2;
}
.thread-head-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.thread-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.back { display: none; }

.thread-body { flex: 1 1 auto; min-height: 0; position: relative; }
.thread-scroll {
  position: absolute; inset: 0; overflow-y: auto; padding: 14px 24px 18px;
  /* 极淡的斜纹底，模仿 WhatsApp 的聊天背景，不喧宾夺主 */
  background-image: linear-gradient(135deg, rgba(0,0,0,.012) 25%, transparent 25% 50%,
                    rgba(0,0,0,.012) 50% 75%, transparent 75%);
  background-size: 26px 26px;
}
.thread-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; color: var(--muted);
  background: var(--chat-bg); text-align: center; padding: 24px;
}
.empty-art { font-size: 42px; opacity: .5; }
.thread-empty p { margin: 0; font-size: 14px; }
.dim { color: var(--muted-2); font-size: 12px; }

.day { text-align: center; margin: 12px 0 10px; }
.day span {
  background: #fff; color: var(--muted); font-size: 12px; padding: 5px 12px;
  border-radius: 8px; box-shadow: 0 1px 1px rgba(11,20,26,.08);
}
.msg { display: flex; margin-bottom: 3px; }
.msg.out { justify-content: flex-end; }
.bubble {
  position: relative; max-width: min(680px, 78%); background: var(--bubble-in);
  border-radius: 8px; padding: 6px 9px 6px 9px; box-shadow: 0 1px 1px rgba(11,20,26,.09);
}
.msg.out .bubble { background: var(--bubble-out); }
.bubble .text { white-space: pre-wrap; word-break: break-word; font-size: 14.2px; }
.bubble.sys { background: #ffeecd; color: var(--warn); font-style: italic; font-size: 13px; }
.quote {
  border-left: 3px solid var(--wa-green); background: rgba(0,0,0,.045);
  border-radius: 4px; padding: 4px 7px; margin-bottom: 4px; font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  margin-top: 2px; font-size: 11px; color: var(--muted-2);
}
.meta .ticks { color: var(--muted-2); letter-spacing: -1px; }
.meta .ticks.read { color: var(--blue); }
.msg-sender { font-size: 12px; font-weight: 600; margin-bottom: 2px; color: #3b6fb0; }

.media-img { max-width: 100%; max-height: 340px; border-radius: 6px; display: block; cursor: zoom-in; }
.media-video-wrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.media-video {
  max-width: 100%; max-height: 320px; width: auto; height: auto;
  border-radius: 8px; display: block; background: #000;
}
.media-badge {
  /* 放右上角：原生控件条的时间在右下，会和角标重叠 */
  position: absolute; right: 6px; top: 6px; background: rgba(0,0,0,.62); color: #fff;
  font-size: 11px; padding: 2px 6px; border-radius: 4px; line-height: 1.5; pointer-events: none;
}
.media-audio { width: 260px; max-width: 100%; }
.media-sticker { max-width: 150px; max-height: 150px; display: block; }
.doc {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px;
  background: rgba(0,0,0,.04); text-decoration: none; color: inherit; min-width: 200px;
}
.doc.pending { cursor: pointer; }
.doc.pending:hover { background: rgba(0,0,0,.08); }
.doc .doc-ico { font-size: 20px; }
.doc .doc-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc .doc-size { font-size: 11px; color: var(--muted); }
.media-pending {
  font-size: 12px; color: var(--muted); background: rgba(0,0,0,.04);
  border-radius: 6px; padding: 8px 10px; display: inline-block;
}

.load-more { text-align: center; margin: 8px 0; }
.load-more button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 5px 14px; font-size: 12px; cursor: pointer;
}

/* 输入区 */
.composer {
  flex: 0 0 auto; background: var(--panel-2); border-top: 1px solid var(--line);
  padding: 8px 14px 10px; display: flex; flex-direction: column; gap: 6px;
  /*
   * ⚠️ 必须 relative：附件菜单与表情面板是 `position:absolute; bottom:100%`，
   * 靠这一行定位到"输入区正上方"。
   * 没有它，绝对定位会退回到最近的有定位祖先 `.thread-panel`，
   * bottom:100% 就变成"整个对话面板顶端之上" —— 表现为浮层跑到页面顶部。
   */
  position: relative;
}
.reply-bar {
  display: flex; align-items: center; gap: 8px; background: #fff; border-left: 3px solid var(--wa-green);
  border-radius: 6px; padding: 6px 8px;
}
.reply-text { flex: 1 1 auto; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
#composer-input {
  flex: 1 1 auto; min-width: 0; max-height: 140px; resize: none; padding: 10px 12px;
  border: 0; border-radius: 10px; background: #fff; font: inherit; font-size: 14px;
  color: var(--text); box-shadow: 0 1px 1px rgba(11,20,26,.06);
}
#composer-input:disabled { background: #eceff1; color: var(--muted-2); }
.composer-hint { font-size: 11px; color: var(--muted); min-height: 14px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.icon { width: 36px; height: 36px; padding: 0; font-size: 15px; }
/* 图标/单字按钮必须显式给宽高，否则只有一个字形时会比旁边的多字按钮矮一截 */
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: rgba(11,20,26,.06); color: var(--text); }
.btn.primary { background: var(--wa-green); border-color: var(--wa-green); color: #fff; }
.btn.primary:hover { background: var(--wa-green-dark); }
.btn.danger { color: var(--danger); border-color: #f6cdd6; }
.btn.send {
  width: 40px; height: 40px; padding: 0; border-radius: 50%; flex: 0 0 auto;
  background: var(--wa-green); border-color: var(--wa-green); color: #fff;
}
.btn.send .send-ico { font-size: 15px; line-height: 1; }
.btn.send:disabled { opacity: .5; cursor: default; }
.btn:disabled { opacity: .5; cursor: default; }

/* 覆盖层（未运行 / 待扫码 / 已登出） */
.overlay {
  position: absolute; inset: 60px 0 0 0; z-index: 5;
  background: var(--chat-bg); display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: #fff; border-radius: var(--r-lg); box-shadow: 0 2px 12px rgba(11,20,26,.12);
  padding: 26px 28px; text-align: center; max-width: 460px;
}
.overlay-card h2 { margin: 0 0 8px; font-size: 17px; }
.overlay-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.overlay-card img.qr { width: 300px; height: 300px; image-rendering: pixelated; border-radius: 8px; }
.overlay-card .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.overlay-card .mini { font-size: 11px; color: var(--muted-2); margin-top: 10px; line-height: 1.6; }

/* 灯箱：**按需创建、关闭时移除** —— 常驻的全屏浮层一旦状态同步错就会吃掉全页点击 */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(11,20,26,.86);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox .lb-close {
  position: absolute; top: 14px; right: 16px; width: 40px; height: 40px; border: 0;
  border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 18px; cursor: pointer;
}
.lightbox .lb-orig {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  color: #fff; text-decoration: none; font-size: 13px; background: rgba(255,255,255,.16);
  padding: 7px 14px; border-radius: 999px;
}

/* ---------------- 右键菜单 ---------------- */
.ctx-menu {
  position: fixed; z-index: 70; min-width: 186px;
  background: #fff; border-radius: var(--r); padding: 6px;
  box-shadow: 0 8px 28px rgba(11,20,26,.26);
}
.ctx-title { font-size: 13.5px; font-weight: 600; padding: 4px 9px 1px; }
.ctx-sub { font-size: 11px; color: var(--muted); padding: 0 9px 4px; }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.ctx-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 7px 9px; border-radius: 6px; font: inherit; font-size: 13.5px; cursor: pointer;
  color: var(--text); white-space: nowrap;
}
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu button.danger:hover { background: #fdecec; }

/* ---------------- 标签 ---------------- */
.tag-bar {
  flex: 0 0 auto; display: flex; gap: 5px; padding: 7px 12px; overflow-x: auto;
  border-bottom: 1px solid var(--line); background: var(--panel);
  scrollbar-width: thin;
}
.tag-filter {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  border-radius: 999px; padding: 3px 9px; font: inherit; font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.tag-filter i { font-style: normal; font-size: 10px; opacity: .7; }
.tag-filter.on { background: var(--wa-green); border-color: var(--wa-green); color: #fff; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.tag-chip.on { background: var(--wa-green); border-color: var(--wa-green); color: #fff; }
.pill.tag { background: #e7f3ee; color: var(--wa-green-dark); }

/* ---------------- 通用输入框 ---------------- */
.input {
  height: 34px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: var(--r-sm); font: inherit; background: #fff; color: var(--text);
}
.input:focus { outline: none; border-color: var(--wa-green); }

/* 账号名称编辑行（账号设置里） */
.acc-name-row { display: flex; gap: 8px; margin: 6px 0 4px; }
.acc-name-row .input { flex: 1 1 auto; min-width: 0; }
.acc-name-row .btn { flex: 0 0 auto; }

/* ---------------- 8 位配对码（iPhone 扫码失败时的通道） ---------------- */
.pair-box {
  margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--panel-2);
}
.pair-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.pair-box .row { margin-top: 8px; gap: 8px; }
.pair-box input {
  flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; background: #fff;
}
.pair-box input:focus { outline: none; border-color: var(--wa-green); }
.pair-err { margin-top: 8px; color: var(--danger); font-size: 12.5px; }
.pair-code-box { margin-top: 12px; text-align: center; }
.pair-code-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 34px; font-weight: 700; letter-spacing: 8px; color: var(--wa-green-dark);
  background: #fff; border: 1px dashed var(--wa-green); border-radius: var(--r);
  padding: 12px 8px 12px 16px; margin-bottom: 8px; user-select: all;
}

/* 对话框（新建/联系人） */
.dlg {
  position: fixed; inset: 0; z-index: 45; background: rgba(11,20,26,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.dlg-card {
  background: #fff; border-radius: var(--r-lg); width: 460px; max-width: 100%;
  max-height: 92vh; overflow-y: auto; padding: 20px 22px;
  box-shadow: 0 10px 40px rgba(11,20,26,.3);
}
.dlg-card h2 { margin: 0 0 4px; font-size: 16px; }
.dlg-card .dlg-sub { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 0 0 14px; }
.dlg-field { margin-bottom: 12px; }
.dlg-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.dlg-field input, .dlg-field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 10px; font: inherit; font-size: 14px; background: var(--panel-2);
}
.dlg-field textarea { resize: vertical; min-height: 64px; }
.dlg-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dlg-check {
  font-size: 12.5px; margin: 6px 0 0; padding: 7px 10px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted); display: none;
}
.dlg-check.show { display: block; }
.dlg-check.ok { background: #e7f8f0; color: #0b6b4f; }
.dlg-check.bad { background: #fdecec; color: #a4232a; }
.dlg-quota {
  font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line);
  padding-top: 10px; margin-top: 14px; line-height: 1.7;
}
.dlg-quota .warn { color: #a4232a; font-weight: 600; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.dlg-note { font-size: 11.5px; color: var(--muted-2); line-height: 1.7; margin-top: 10px; }

/* ---------------- 自媒体输入区 ---------------- */

/* 附件菜单 */
.attach-menu {
  /* left 对齐 📎 按钮（composer 内边距 14px）；bottom:100% = 输入区正上方 */
  position: absolute; bottom: 100%; left: 14px; margin-bottom: 8px; z-index: 20;
  background: #fff; border-radius: var(--r); box-shadow: 0 4px 18px rgba(11,20,26,.22);
  padding: 6px; min-width: 150px; display: flex; flex-direction: column; gap: 2px;
}
.attach-menu button {
  display: flex; align-items: center; gap: 8px; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 6px; font: inherit; font-size: 13.5px; cursor: pointer;
  color: var(--text); text-align: left;
}
.attach-menu button:hover { background: var(--hover); }
.attach-menu .ico { font-size: 15px; width: 20px; text-align: center; }

/* 待发送的附件预览条 */
.attach-preview {
  display: flex; gap: 10px; align-items: flex-start; background: #fff;
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px;
}
.attach-preview .pv-thumb {
  width: 52px; height: 52px; border-radius: 6px; object-fit: cover; flex: 0 0 auto;
  background: var(--panel-2); display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.attach-preview .pv-mid { flex: 1 1 auto; min-width: 0; }
.attach-preview .pv-name {
  font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.attach-preview .pv-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 4px 0;
  font: inherit; font-size: 13.5px; background: transparent;
}
.attach-preview .pv-input:focus { outline: none; border-bottom-color: var(--wa-green); }
.attach-preview .pv-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.attach-preview .pv-hint { font-size: 11px; color: var(--muted-2); margin-top: 3px; }
.attach-progress { height: 3px; background: var(--panel-2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.attach-progress i { display: block; height: 100%; background: var(--wa-green); width: 0; transition: width .2s; }

/* 表情面板 */
.emoji-panel {
  /* left 对齐 😀 按钮（14 + 36 + 8 = 58） */
  position: absolute; bottom: 100%; left: 58px; right: 8px; margin-bottom: 8px; z-index: 20;
  background: #fff; border-radius: var(--r); box-shadow: 0 4px 18px rgba(11,20,26,.22);
  padding: 8px; max-height: 260px; display: flex; flex-direction: column; gap: 6px;
}
.emoji-panel input {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px;
}
.emoji-grid {
  overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 2px; align-content: start;
}
.emoji-grid button {
  border: 0; background: transparent; font-size: 19px; line-height: 1; padding: 5px 0;
  cursor: pointer; border-radius: 6px;
}
.emoji-grid button:hover { background: var(--hover); }

/* 贴图库 */
.sticker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px;
  max-height: 260px; overflow-y: auto; padding: 4px;
}
.sticker-grid button {
  border: 0; background: var(--panel-2); border-radius: 8px; padding: 4px; cursor: pointer;
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.sticker-grid img { max-width: 100%; max-height: 100%; }
.sticker-grid .empty { grid-column: 1/-1; text-align: center; color: var(--muted); font-size: 12px; padding: 14px 0; }

/* 语音条 */
.voice-note { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.voice-note .vn-play {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--wa-green);
  color: #fff; cursor: pointer; font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.voice-note .vn-wave { flex: 1 1 auto; display: flex; align-items: center; gap: 2px; height: 22px; }
.voice-note .vn-wave i {
  display: block; width: 2px; border-radius: 1px; background: rgba(17,27,33,.28);
  height: var(--h, 40%);
}
.voice-note.playing .vn-wave i { background: var(--wa-green); }
.voice-note .vn-dur { font-size: 11px; color: var(--muted); flex: 0 0 auto; min-width: 32px; text-align: right; }
.voice-note audio { display: none; }

/* 录音状态 */
.rec-live {
  display: flex; align-items: center; gap: 8px; color: var(--danger); font-size: 13px;
  padding: 0 4px; white-space: nowrap;
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: recpulse 1s infinite; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.btn.rec { width: 40px; height: 40px; padding: 0; border-radius: 50%; flex: 0 0 auto; font-size: 16px; }
.btn.rec.on { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 消息里的媒体操作条 */
.media-actions { display: flex; gap: 4px; margin-top: 3px; justify-content: flex-end; }
.media-actions button {
  border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer;
  padding: 2px 4px; border-radius: 4px;
}
.media-actions button:hover { background: rgba(0,0,0,.06); color: var(--text); }

/* 提示 */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #111b21; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 3px 12px rgba(11,20,26,.3); max-width: 340px;
}
.toast.err { background: #b42318; }
.toast.ok { background: #0b6b4f; }

/* 登录页 */
.login-body {
  margin: 0; min-height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #00a884 0%, #005c4b 100%); padding: 20px;
}
.login-card {
  background: #fff; border-radius: var(--r-lg); padding: 28px; width: 340px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 6px; font-size: 17px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login-card input { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; }
.login-card button {
  height: 38px; border: 0; border-radius: var(--r-sm); background: var(--wa-green);
  color: #fff; font-size: 14px; cursor: pointer;
}
.login-err { margin: 0; color: var(--danger); font-size: 12px; }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 1100px) {
  :root { --list-w: 300px; }
}
/*
 * 窄屏：**不隐藏任何栏**，改成"列表/对话二选一"的滑屏（WhatsApp 手机端就是这样）。
 * 隐藏栏位会让对应功能彻底不可达，所以用 .show-thread 在两者间切换，靠返回按钮回去。
 */
@media (max-width: 820px) {
  :root { --list-w: 1fr; }
  body { overflow: hidden; }
  .app { grid-template-columns: var(--rail-w) 1fr; }
  .thread-panel { display: none; }
  .app.show-thread .list-panel { display: none; }
  .app.show-thread .thread-panel { display: flex; }
  .back { display: inline-flex; }
  .thread-scroll { padding: 12px 12px 16px; }
  .bubble { max-width: 88%; }
}
