:root {
  --primary: #1f6feb;
  --primary-dark: #1a5fd0;
  --primary-soft: #e8f0fe;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --line: #e7e9ee;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --green: #22a06b;
  --orange: #f59e0b;
  --red: #e5484d;
  --bubble-me: #1f6feb;
  --bubble-them: #ffffff;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- 消息 ---------- */
.msg-list { padding: 8px 14px 14px; }
.tm { text-align: center; color: var(--text-3); font-size: 12px; margin: 14px 0 6px; }
.sys { text-align: center; margin: 10px 0; }
.sys span { display: inline-block; background: rgba(0, 0, 0, .05); color: var(--text-2); font-size: 12px; padding: 3px 10px; border-radius: 10px; max-width: 86%; }
.sys.internal span { background: #fff6e5; color: #9a6a00; }
.sys.internal span::before { content: "内部 · "; opacity: .7; }
.row { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; }
.row.me { flex-direction: row-reverse; }
.row .av {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%;
  color: #fff; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center;
}
.row .body { max-width: min(72%, 560px); display: flex; flex-direction: column; min-width: 0; }
.row.me .body { align-items: flex-end; }
.row .nm { font-size: 12px; color: var(--text-3); margin: 0 2px 3px; }
.row .line { display: flex; align-items: flex-end; gap: 6px; }
.row.me .line { flex-direction: row-reverse; }
.bubble {
  padding: 9px 12px; border-radius: var(--radius); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  background: var(--bubble-them); box-shadow: 0 1px 1px rgba(0, 0, 0, .04); border: 1px solid var(--line);
}
.row.them .bubble { border-top-left-radius: 3px; }
.row.me .bubble { background: var(--bubble-me); color: #fff; border-color: var(--bubble-me); border-top-right-radius: 3px; }
.row.me .bubble a { color: #fff; }
.bubble a { color: var(--primary); }
.bubble.img { padding: 3px; background: #fff !important; border-color: var(--line) !important; }
.bubble.img img { display: block; max-width: 220px; max-height: 260px; border-radius: 7px; cursor: zoom-in; }
.st { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.st.unread { color: var(--primary); }
.st.fail { color: var(--red); cursor: pointer; }
.loadmore { text-align: center; padding: 10px 0 2px; font-size: 12px; color: var(--primary); cursor: pointer; }

/* ---------- 表情 ---------- */
.emoji-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; padding: 8px; max-height: 210px; overflow-y: auto; }
.emo { border: 0; background: none; font-size: 22px; height: 38px; border-radius: 6px; padding: 0; }
.emo:hover { background: var(--bg); }

/* ---------- 弹层 ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: none; align-items: center; justify-content: center; z-index: 1000; cursor: zoom-out; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 4px; }
.toast {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); background: rgba(20, 20, 20, .82); color: #fff;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 1001; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c4c8cf; flex: none; }
.dot.on, .dot.online { background: var(--green); }
.dot.busy { background: var(--red); }
.dot.away { background: var(--orange); }
.typing-dots { display: inline-flex; gap: 3px; margin-left: 4px; vertical-align: middle; }
.typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
