/* ========== HP Chat — giao diện kiểu WeChat ========== */
:root {
  --accent: #07C160;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --rail-w: 62px;
  --side-w: 300px;
}
/* 10 template màu */
[data-theme="wechat"] { --accent: #07C160; }
[data-theme="ocean"]  { --accent: #1677FF; }
[data-theme="tea"]    { --accent: #5E8B2E; }
[data-theme="indigo"] { --accent: #5B5BD6; }
[data-theme="violet"] { --accent: #8B5CF6; }
[data-theme="rose"]   { --accent: #E11D74; }
[data-theme="sunset"] { --accent: #F26B1D; }
[data-theme="teal"]   { --accent: #0D9488; }
[data-theme="coffee"] { --accent: #8B5E3C; }
[data-theme="slate"]  { --accent: #475569; }

[data-mode="light"] {
  --bg: #F5F5F5;
  --chat-bg: #F2F2F2;
  --rail: #2E2E2E;
  --rail-fg: #9B9B9B;
  --rail-active: #fff;
  --side: #F7F7F7;
  --side-hover: #ECECEC;
  --side-active: #DEDEDE;
  --panel: #FFFFFF;
  --line: #E3E3E3;
  --fg: #191919;
  --fg-2: #5f5f5f;
  --fg-3: #9a9a9a;
  --bubble: #FFFFFF;
  --bubble-fg: #191919;
  --bubble-me: color-mix(in srgb, var(--accent) 42%, #ffffff);
  --bubble-me-fg: #111;
  --input: #FFFFFF;
  --chip: #EDEDED;
  --shadow: 0 8px 30px rgba(0,0,0,.12);
  --danger: #E5484D;
  --mention-bg: color-mix(in srgb, var(--accent) 16%, transparent);
  --overlay: rgba(0,0,0,.45);
  color-scheme: light;
}
[data-mode="dark"] {
  --bg: #111111;
  --chat-bg: #141414;
  --rail: #1B1B1B;
  --rail-fg: #7c7c7c;
  --rail-active: #fff;
  --side: #1E1E1E;
  --side-hover: #262626;
  --side-active: #303030;
  --panel: #222222;
  --line: #2c2c2c;
  --fg: #E8E8E8;
  --fg-2: #A9A9A9;
  --fg-3: #6f6f6f;
  --bubble: #2A2A2A;
  --bubble-fg: #E8E8E8;
  --bubble-me: color-mix(in srgb, var(--accent) 62%, #1a1a1a);
  --bubble-me-fg: #fff;
  --input: #1A1A1A;
  --chip: #2E2E2E;
  --shadow: 0 10px 40px rgba(0,0,0,.55);
  --danger: #FF6369;
  --mention-bg: color-mix(in srgb, var(--accent) 22%, transparent);
  --overlay: rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: var(--fg); }
a { color: var(--accent); }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--fg) 18%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.boot { height: 100dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--fg-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--input); outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); background: var(--chip); color: var(--fg); font-weight: 500; white-space: nowrap; transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(1.06); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; color: var(--fg-2); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Login ---------- */
.login { height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 25%, transparent), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 34px 30px 26px; box-shadow: var(--shadow); }
.login-logo { width: 58px; height: 58px; border-radius: 15px; background: var(--accent); display: grid; place-items: center; margin: 0 auto 14px; color: #fff; }
.login-logo svg { width: 34px; height: 34px; fill: #fff; stroke: none; }
.login h1 { text-align: center; font-size: 21px; margin: 0 0 4px; }
.login p.sub { text-align: center; color: var(--fg-3); margin: 0 0 24px; font-size: 13px; }
.login .btn.primary { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 20px; margin: 4px 0; }
.login .row { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 10px; }

/* ---------- Shell ---------- */
.app { height: 100dvh; display: grid; grid-template-columns: var(--rail-w) var(--side-w) 1fr; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
.app.admin-mode { grid-template-columns: var(--rail-w) 1fr; }
.rail { background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 22px 0 14px; gap: 6px; }
.rail .me { margin-bottom: 18px; cursor: pointer; }
.rail-btn { position: relative; width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: var(--rail-fg); transition: color .15s, background .15s; }
.rail-btn:hover { color: #d8d8d8; background: rgba(255,255,255,.05); }
.rail-btn.active { color: var(--accent); }
.rail-btn svg.i { width: 23px; height: 23px; }
.rail-spacer { flex: 1; }
.badge { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: #FA5151; color: #fff; font-size: 10.5px; font-weight: 600; line-height: 17px; text-align: center; }
.badge.dot { min-width: 9px; width: 9px; height: 9px; padding: 0; top: 8px; right: 8px; }

/* ---------- Avatar ---------- */
.avatar { position: relative; flex: none; width: 40px; height: 40px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 16px; user-select: none; text-transform: uppercase; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; border-radius: 5px; }
.avatar.xs { width: 22px; height: 22px; font-size: 10px; border-radius: 4px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; border-radius: 8px; }
.avatar .dot-on, .avatar .dot-off { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--side); }
.avatar .dot-on { background: #2BD46A; }
.avatar .dot-off { background: #8a8a8a; }
.avatar.group { background: #CFCFCF; padding: 2px; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; }
[data-mode="dark"] .avatar.group { background: #3a3a3a; }
.avatar.group > span { display: grid; place-items: center; font-size: 10px; border-radius: 2px; color: #fff; width: 100%; height: 100%; min-height: 0; }
.avatar.group.n1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.avatar.group.n2 { grid-template-rows: 1fr; }
.avatar.group.n3 > span:first-child { grid-column: span 2; }

/* ---------- Sidebar ---------- */
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.side-head { padding: 22px 12px 10px; display: flex; gap: 8px; align-items: center; }
.search { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--chip); border-radius: 6px; padding: 0 8px; height: 30px; color: var(--fg-3); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 13px; }
.search svg.i { width: 15px; height: 15px; }
.icon-btn { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--fg-2); background: var(--chip); flex: none; }
.icon-btn:hover { color: var(--fg); filter: brightness(1.08); }
.icon-btn svg.i { width: 18px; height: 18px; }
.side-title { padding: 2px 16px 8px; font-size: 12px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; }
.list { flex: 1; overflow-y: auto; }
.item { display: flex; gap: 11px; padding: 11px 12px; cursor: pointer; align-items: center; position: relative; }
.item:hover { background: var(--side-hover); }
.item.active { background: var(--side-active); }
.item .meta { flex: 1; min-width: 0; }
.item .top { display: flex; align-items: baseline; gap: 6px; }
.item .name { flex: 1; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .time { font-size: 11.5px; color: var(--fg-3); flex: none; }
.item .bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.item .preview { flex: 1; font-size: 12.5px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .preview .at { color: #FA5151; }
.item .muted-ic svg.i { width: 14px; height: 14px; color: var(--fg-3); }
.item .avatar-wrap { position: relative; }
.item .avatar-wrap .badge { top: -6px; right: -6px; }
.item .sub { font-size: 12px; color: var(--fg-3); }
.item .pin-default { font-size: 10.5px; padding: 0 5px; border-radius: 3px; background: var(--mention-bg); color: var(--accent); flex: none; }
/* bộ lọc nhóm / cá nhân, ghim */
.conv-filter { display: flex; gap: 4px; padding: 0 12px 8px; }
.conv-filter button { flex: 1; min-width: 0; white-space: nowrap; font-size: 12.5px; padding: 5px 2px; border-radius: 6px; color: var(--fg-2); background: transparent; display: flex; align-items: center; justify-content: center; gap: 5px; }
.conv-filter button svg.i { width: 14px; height: 14px; flex: none; }
.conv-filter button:hover { background: var(--side-hover); }
.conv-filter button.on { background: var(--chip); color: var(--accent); font-weight: 600; }
.conv-filter button .n { font-size: 10.5px; min-width: 16px; padding: 0 4px; border-radius: 8px; background: #FA5151; color: #fff; font-weight: 600; line-height: 16px; }
.item.pinned { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.item.pinned:hover { background: color-mix(in srgb, var(--accent) 10%, var(--side-hover)); }
.item.pinned.active { background: var(--side-active); }
.item .kind { flex: none; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); align-self: center; }
.item .kind svg.i { width: 11px; height: 11px; stroke-width: 2.4; }
.item .pin-ic { flex: none; color: var(--accent); align-self: center; }
.item .pin-ic svg.i { width: 13px; height: 13px; transform: rotate(35deg); }
.item.viewer { opacity: .82; }
.item .view-tag { font-size: 10.5px; padding: 0 5px; border-radius: 3px; background: var(--chip); color: var(--fg-3); flex: none; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--side); font-size: 13px; color: var(--fg-2); }
.viewer-bar svg.i { width: 18px; height: 18px; color: var(--fg-3); flex: none; }
.viewer-bar span { flex: 1; }
.empty-list { text-align: center; color: var(--fg-3); padding: 40px 20px; font-size: 13px; }

/* ---------- Main / chat ---------- */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--chat-bg); }
.placeholder { flex: 1; display: grid; place-items: center; color: var(--fg-3); text-align: center; }
.placeholder svg { width: 84px; height: 84px; opacity: .25; fill: var(--fg); }
.chat-head { height: 62px; padding: 0 18px 0 22px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: var(--chat-bg); flex: none; }
.chat-head .title { flex: 1; min-width: 0; }
.chat-head .title b { font-size: 16px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .title small { color: var(--fg-3); font-size: 12px; }
.chat-head .title small.on { color: #2BD46A; }
.head-btn { width: 34px; height: 34px; border-radius: 6px; display: grid; place-items: center; color: var(--fg-2); }
.head-btn:hover { background: var(--side-hover); color: var(--fg); }
.back-btn { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 14px 22px 8px; overscroll-behavior: contain; }
.load-more { text-align: center; padding: 6px; color: var(--fg-3); font-size: 12px; }
.sep-time { text-align: center; margin: 14px 0 10px; }
.sep-time span { font-size: 12px; color: var(--fg-3); padding: 2px 8px; border-radius: 4px; }
.sys { text-align: center; margin: 10px 0; }
.sys span { display: inline-block; font-size: 12px; color: var(--fg-3); background: color-mix(in srgb, var(--fg) 6%, transparent); padding: 3px 10px; border-radius: 4px; max-width: 80%; }

.msg { display: flex; gap: 10px; margin: 6px 0 12px; align-items: flex-start; position: relative; }
.msg.me { flex-direction: row-reverse; }
.msg .body { max-width: min(70%, 620px); display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.msg.me .body { align-items: flex-end; }
.msg .sender { font-size: 12px; color: var(--fg-3); margin: -2px 0 3px 2px; }
.bubble { position: relative; padding: 9px 12px; border-radius: 6px; background: var(--bubble); color: var(--bubble-fg); word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 14.5px; line-height: 1.55; max-width: 100%; }
.bubble::before { content: ""; position: absolute; top: 13px; left: -5px; width: 10px; height: 10px; background: inherit; transform: rotate(45deg); border-radius: 1px; }
.msg.me .bubble { background: var(--bubble-me); color: var(--bubble-me-fg); }
.msg.me .bubble::before { left: auto; right: -5px; }
.bubble.mention-me { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }
.bubble code { font-family: var(--mono); font-size: 12.5px; background: color-mix(in srgb, currentColor 12%, transparent); padding: 1px 5px; border-radius: 4px; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.msg:not(.me) .bubble a { color: var(--accent); }
.mention { color: var(--accent); font-weight: 600; }
.msg.me .mention { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; }
.mention.me-tag { background: var(--mention-bg); border-radius: 3px; padding: 0 2px; }
.bubble.media { padding: 0; background: transparent !important; }
.bubble.media::before { display: none; }
.bubble.media img { display: block; max-width: min(280px, 100%); max-height: 300px; border-radius: 6px; cursor: zoom-in; background: var(--chip); min-width: 60px; min-height: 40px; object-fit: cover; }
.file-card { display: flex; gap: 12px; align-items: center; width: 280px; max-width: 100%; padding: 12px; background: var(--bubble); color: var(--bubble-fg); border-radius: 6px; border: 1px solid var(--line); white-space: normal; }
.file-card .fi { width: 42px; height: 48px; border-radius: 4px; display: grid; place-items: center; font-size: 10px; font-weight: 700; color: #fff; flex: none; background: #7a7a7a; position: relative; text-transform: uppercase; }
.file-card .fi::after { content: ""; position: absolute; right: 0; top: 0; border-width: 0 10px 10px 0; border-style: solid; border-color: var(--bubble) color-mix(in srgb, #000 25%, transparent); }
.file-card .fmeta { flex: 1; min-width: 0; }
.file-card .fname { font-size: 13.5px; line-height: 1.35; word-break: break-all; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.file-card .fsize { font-size: 11.5px; color: var(--fg-3); margin-top: 3px; }
.file-card .dl { color: var(--accent); flex: none; padding: 6px; border-radius: 6px; }
.file-card .dl:hover { background: var(--mention-bg); }
.file-card.deleted { opacity: .6; }
.quote { font-size: 12.5px; color: var(--fg-2); background: color-mix(in srgb, var(--fg) 7%, transparent); border-left: 3px solid color-mix(in srgb, var(--fg) 25%, transparent); padding: 4px 8px; border-radius: 3px; margin-bottom: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.msg.me .bubble .quote { color: inherit; opacity: .85; }
.quote-out { margin-top: 4px; max-width: 100%; }
.msg .actions { position: absolute; top: -14px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px; box-shadow: var(--shadow); z-index: 2; }
.msg:not(.me) .actions { left: 52px; }
.msg.me .actions { right: 52px; }
.msg:hover .actions { display: flex; }
.msg .actions button { width: 28px; height: 26px; display: grid; place-items: center; border-radius: 4px; color: var(--fg-2); }
.msg .actions button:hover { background: var(--side-hover); color: var(--fg); }
.msg .actions svg.i { width: 15px; height: 15px; }
.msg .read-tag { font-size: 11px; color: var(--fg-3); margin-top: 3px; }
.msg.pending .bubble { opacity: .65; }
.msg.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.avatar.clickable { cursor: pointer; }

.typing { height: 20px; padding: 0 24px; font-size: 12px; color: var(--fg-3); flex: none; }
.new-pill { position: absolute; right: 26px; bottom: 210px; background: var(--panel); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 16px; padding: 5px 12px; font-size: 12.5px; z-index: 3; }

/* ---------- Composer ---------- */
.composer { border-top: 1px solid var(--line); background: var(--chat-bg); flex: none; display: flex; flex-direction: column; min-height: 168px; max-height: 50vh; }
.toolbar { display: flex; align-items: center; gap: 2px; padding: 6px 14px 0; flex-wrap: wrap; }
.tb { width: 32px; height: 30px; border-radius: 5px; display: grid; place-items: center; color: var(--fg-2); font-weight: 700; font-size: 14px; }
.tb:hover { background: var(--side-hover); color: var(--fg); }
.tb.on { color: var(--accent); background: var(--mention-bg); }
.tb svg.i { width: 19px; height: 19px; }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.editor { flex: 1; min-height: 60px; overflow-y: auto; padding: 6px 20px; outline: none; font-size: 14.5px; line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.editor:empty::before { content: attr(data-placeholder); color: var(--fg-3); pointer-events: none; }
.editor code { font-family: var(--mono); font-size: 13px; background: var(--chip); padding: 1px 4px; border-radius: 4px; }
.editor .mention { background: var(--mention-bg); border-radius: 3px; padding: 0 2px; }
.composer-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 4px 18px 12px; }
.composer-foot .hint { font-size: 11.5px; color: var(--fg-3); margin-right: auto; }
.send-btn { padding: 6px 22px; }
.reply-bar { display: flex; align-items: center; gap: 8px; margin: 8px 18px 0; padding: 6px 10px; background: var(--chip); border-radius: 6px; font-size: 12.5px; color: var(--fg-2); }
.reply-bar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-strip { display: flex; gap: 8px; padding: 10px 18px 0; overflow-x: auto; }
.att { position: relative; width: 74px; flex: none; }
.att .thumb { width: 74px; height: 74px; border-radius: 6px; background: var(--chip); display: grid; place-items: center; overflow: hidden; font-size: 11px; color: var(--fg-2); text-align: center; padding: 4px; word-break: break-all; }
.att .thumb img { width: 100%; height: 100%; object-fit: cover; }
.att .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: #555; color: #fff; display: grid; place-items: center; font-size: 13px; line-height: 1; }
.att .bar { position: absolute; left: 4px; right: 4px; bottom: 4px; height: 4px; border-radius: 2px; background: rgba(0,0,0,.35); overflow: hidden; }
.att .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.att .nm { font-size: 10.5px; color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.drop-overlay { position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 14%, var(--overlay)); border: 2px dashed var(--accent); display: grid; place-items: center; color: #fff; font-size: 18px; font-weight: 600; z-index: 20; pointer-events: none; }

/* ---------- Popups ---------- */
.popup { position: fixed; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); z-index: 60; overflow: hidden; }
.mention-pop { width: 240px; max-height: 260px; overflow-y: auto; padding: 4px; }
.mention-pop .opt { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 5px; cursor: pointer; }
.mention-pop .opt.sel, .mention-pop .opt:hover { background: var(--side-hover); }
.mention-pop .opt small { color: var(--fg-3); margin-left: auto; }
.emoji-pop { width: 312px; padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.emoji-pop button { font-size: 21px; height: 36px; border-radius: 5px; }
.emoji-pop button:hover { background: var(--side-hover); }
.menu { min-width: 180px; padding: 4px; }
.menu button { width: 100%; text-align: left; padding: 8px 10px; border-radius: 5px; display: flex; gap: 8px; align-items: center; }
.menu button:hover { background: var(--side-hover); }
.menu button.danger { color: var(--danger); }

.modal-back { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 80; padding: 16px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { max-width: 640px; }
.modal-head { padding: 16px 20px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.pick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.pick:hover { background: var(--side-hover); }
.pick input { accent-color: var(--accent); width: 16px; height: 16px; }
.pick .avatar .dot-on, .pick .avatar .dot-off { border-color: var(--panel); }
.settings-section { margin-bottom: 22px; }
.settings-section h4 { margin: 0 0 10px; font-size: 13px; color: var(--fg-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.seg { display: inline-flex; background: var(--chip); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { padding: 6px 14px; border-radius: 6px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.15); color: var(--accent); font-weight: 600; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.swatch { border-radius: 10px; padding: 8px 4px 6px; border: 2px solid transparent; display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11.5px; color: var(--fg-2); background: var(--chip); }
.swatch i { width: 30px; height: 30px; border-radius: 50%; display: block; box-shadow: inset 0 0 0 3px rgba(255,255,255,.25); }
.swatch.on { border-color: var(--accent); color: var(--fg); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.toggle-row small { display: block; color: var(--fg-3); font-size: 12px; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--chip); border-radius: 12px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

/* info drawer */
.drawer { position: absolute; top: 62px; right: 0; bottom: 0; width: 300px; background: var(--panel); border-left: 1px solid var(--line); z-index: 15; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slide .18s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.member-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 6px; margin-bottom: 16px; }
.member-grid .mg { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11.5px; color: var(--fg-2); text-align: center; position: relative; cursor: pointer; }
.member-grid .mg span { max-width: 62px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-grid .mg .avatar .dot-on, .member-grid .mg .avatar .dot-off { border-color: var(--panel); }
.member-grid .add { width: 40px; height: 40px; border: 1.5px dashed var(--fg-3); border-radius: 6px; display: grid; place-items: center; color: var(--fg-3); }
.drawer .row-btn { width: 100%; text-align: left; padding: 11px 4px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer .row-btn.danger { color: var(--danger); justify-content: center; }
.drawer .file-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.drawer .file-row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 90; display: flex; flex-direction: column; animation: fade .15s; }
.lightbox .lb-img { flex: 1; display: grid; place-items: center; overflow: auto; padding: 20px; }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 100px); object-fit: contain; }
.lightbox .lb-bar { display: flex; justify-content: center; gap: 10px; padding: 12px; }
.lightbox .lb-bar .btn { background: rgba(255,255,255,.14); color: #fff; }

/* toasts */
.toasts { position: fixed; right: 18px; top: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; padding: 10px 14px; max-width: 340px; font-size: 13px; animation: slide .2s; cursor: default; }
.toast.err { border-left: 3px solid var(--danger); }
.toast.ok { border-left: 3px solid var(--accent); }
.toast.mention { border-left: 3px solid #FA5151; cursor: pointer; }
.toast b { display: block; margin-bottom: 2px; }

/* mentions list */
.mention-item .meta .preview { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mention-item.unread .name::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #FA5151; margin-left: 6px; vertical-align: middle; }

/* ---------- Admin ---------- */
.admin { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); overflow: hidden; }
.admin-head { padding: 18px 26px 0; border-bottom: 1px solid var(--line); background: var(--side); }
.admin-head h2 { margin: 0 0 12px; font-size: 19px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs button { padding: 9px 14px; border-bottom: 2px solid transparent; color: var(--fg-2); display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tabs svg.i { width: 17px; height: 17px; }
.admin-body { flex: 1; overflow: auto; padding: 20px 26px 40px; }
.toolbar-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-row .input { width: auto; min-width: 160px; padding: 7px 10px; }
.toolbar-row .grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--fg-2); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: color-mix(in srgb, var(--fg) 3%, transparent); }
table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: color-mix(in srgb, var(--fg) 3%, transparent); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t .nowrap { white-space: nowrap; }
table.t .mono { font-family: var(--mono); font-size: 12px; }
table.t .muted { color: var(--fg-3); }
table.t input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.ucell { display: flex; gap: 10px; align-items: center; }
.ucell .avatar .dot-on, .ucell .avatar .dot-off { border-color: var(--panel); }
.ucell small { display: block; color: var(--fg-3); font-size: 12px; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 10px; background: var(--chip); color: var(--fg-2); white-space: nowrap; }
.tag.green { background: color-mix(in srgb, #2BD46A 18%, transparent); color: #1fa956; }
[data-mode="dark"] .tag.green { color: #4fe08a; }
.tag.red { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.tag.accent { background: var(--mention-bg); color: var(--accent); }
.tag.amber { background: color-mix(in srgb, #F5A524 18%, transparent); color: #c98207; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions button { width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--fg-2); }
.row-actions button:hover { background: var(--side-hover); color: var(--fg); }
.row-actions button.danger:hover { color: var(--danger); }
.row-actions svg.i { width: 16px; height: 16px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px; color: var(--fg-3); font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--fg-3); display: flex; align-items: center; gap: 6px; }
.stat .k svg.i { width: 15px; height: 15px; }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--fg-3); margin-top: 2px; }
.meter { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.meter i.warn { background: #F5A524; }
.meter i.crit { background: var(--danger); }
.section-title { font-size: 14px; font-weight: 600; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.thumb-sm { width: 36px; height: 36px; border-radius: 5px; object-fit: cover; background: var(--chip); display: block; }
.ext-sm { width: 36px; height: 36px; border-radius: 5px; background: var(--chip); display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: var(--fg-2); text-transform: uppercase; }
.alert { padding: 12px 14px; border-radius: 8px; background: color-mix(in srgb, #F5A524 12%, transparent); color: var(--fg-2); font-size: 13px; margin-bottom: 14px; }
.alert code { font-family: var(--mono); font-size: 12px; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .app, .app.admin-mode { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 56px; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 0 6px; gap: 0; order: 2; }
  .rail .me, .rail-spacer, .rail .desk-only { display: none; }
  .side { grid-row: 1; border-right: 0; }
  .main { grid-row: 1 / span 2; grid-column: 1; position: fixed; inset: 0; z-index: 30; transform: translateX(100%); transition: transform .2s ease; }
  .app.chat-open .main { transform: none; }
  .admin { grid-row: 1; }
  .back-btn { display: grid; }
  .chat-head { padding: 0 10px; }
  .messages { padding: 10px 12px; }
  .msg .body { max-width: 78%; }
  .drawer { width: 100%; }
  .composer { min-height: 0; }
  .editor { min-height: 44px; max-height: 30vh; padding: 6px 14px; }
  .composer-foot .hint { display: none; }
  .admin-body { padding: 14px; }
  .admin-head { padding: 14px 14px 0; }
  .swatches { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .new-pill { bottom: 170px; }
  .toasts { left: 12px; right: 12px; top: 12px; }
  .toast { max-width: none; }
}

/* ---------- Avatar ảnh ---------- */
.avatar { overflow: visible; }
.avatar > img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.avatar.group > span { overflow: hidden; }
.avatar.group > span > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.xl { width: 84px; height: 84px; font-size: 32px; border-radius: 12px; }
.avatar-edit { position: relative; cursor: pointer; flex: none; }
.avatar-edit > span { position: absolute; right: -6px; bottom: -6px; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; border: 2px solid var(--panel); }
.avatar-edit > span svg.i { width: 15px; height: 15px; }
.enc-tag { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: var(--fg-3); }
.enc-tag svg.i { width: 13px; height: 13px; }
.chat-head .title b { display: inline; }
.chat-head .title small { display: block; }
.join-call { margin-right: 4px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); } }

/* ---------- Cuộc gọi ---------- */
.call { position: fixed; inset: 0; z-index: 95; background: #0b0b0c; color: #fff; display: flex; flex-direction: column; animation: fade .15s; }
.call-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.call-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.call-title b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.call-status { font-size: 12.5px; color: #9a9a9a; font-variant-numeric: tabular-nums; }
.call-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #ddd; background: rgba(255,255,255,.08); }
.call-ic:hover { background: rgba(255,255,255,.16); }
.call-grid { flex: 1; min-height: 0; display: grid; gap: 8px; padding: 0 12px; grid-template-columns: repeat(var(--cols, 1), 1fr); grid-auto-rows: 1fr; position: relative; }
.call-grid[data-n="1"] { --cols: 1; }
.call-grid[data-n="2"], .call-grid[data-n="3"], .call-grid[data-n="4"] { --cols: 2; }
.call-grid[data-n="5"], .call-grid[data-n="6"], .call-grid[data-n="7"], .call-grid[data-n="8"], .call-grid[data-n="9"] { --cols: 3; }
.tile { position: relative; background: #1c1c1e; border-radius: 12px; overflow: hidden; min-height: 0; display: grid; place-items: center; }
.tile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; background: #000; }
.tile.has-video video { opacity: 1; }
.tile.has-video .tile-av { visibility: hidden; }
.tile.mirror video { transform: scaleX(-1); }
.tile-av { display: grid; place-items: center; }
.tile-name { position: absolute; left: 10px; bottom: 10px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; background: rgba(0,0,0,.5); padding: 3px 9px; border-radius: 6px; max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-name .mic-off { color: #ff6369; display: inline-flex; }
.tile-name svg.i { width: 14px; height: 14px; }
.tile-state { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; color: #bbb; background: rgba(0,0,0,.45); padding: 2px 10px; border-radius: 10px; display: none; }
.tile.connecting .tile-state { display: block; }
.tile.connecting .tile-av { animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; } }
/* 1-1: video người kia toàn màn hình, mình ở góc */
.call.duo .call-grid { display: block; }
.call.duo .tile:not(.me) { position: absolute; inset: 0 12px; }
.call.duo .tile.me { position: absolute; right: 24px; bottom: 14px; width: min(26%, 240px); aspect-ratio: 4 / 3; z-index: 2; box-shadow: 0 6px 24px rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.12); }
.call.duo .tile.me .avatar.xl { width: 48px; height: 48px; font-size: 18px; }
.call-ctrls { display: flex; justify-content: center; gap: 16px; padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); }
.call-btn { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff; transition: background .15s, transform .1s; }
.call-btn:hover { background: rgba(255,255,255,.24); }
.call-btn:active { transform: scale(.94); }
.call-btn svg.i { width: 23px; height: 23px; }
.call-btn.off { background: #fff; color: #111; }
.call-btn.active { background: var(--accent); }
.call-btn.hang { background: #E5484D; }
.call-btn.hang:hover { background: #f05a5f; }
.call-btn.accept { background: #2BB673; }
.call-btn.accept:hover { background: #33c97f; }
/* thu nhỏ */
.call.min { inset: auto 18px 18px auto; width: 340px; height: 250px; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.6); overflow: hidden; }
.call.min .call-head { padding: 8px 10px; }
.call.min .call-title b { font-size: 13px; }
.call.min .call-ic { width: 30px; height: 30px; }
.call.min .call-grid { padding: 0 6px; gap: 4px; }
.call.min .tile-name { font-size: 11px; left: 5px; bottom: 5px; padding: 1px 6px; }
.call.min .avatar.xl { width: 44px; height: 44px; font-size: 17px; }
.call.min.duo .tile:not(.me) { inset: 0 6px; }
.call.min.duo .tile.me { right: 12px; bottom: 6px; width: 34%; }
.call.min .call-ctrls { padding: 8px; gap: 10px; }
.call.min .call-btn { width: 38px; height: 38px; }
.call.min .call-btn svg.i { width: 18px; height: 18px; }
/* cuộc gọi đến */
.call-incoming { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 98; display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: #1f1f22; color: #fff; border-radius: 16px; box-shadow: 0 14px 50px rgba(0,0,0,.55); width: min(440px, calc(100vw - 24px)); animation: drop .25s ease; }
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }
.call-incoming .ci-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.call-incoming .ci-text span { font-size: 12.5px; color: #aaa; }
.call-incoming .ci-btns { display: flex; gap: 10px; }
.call-incoming .call-btn { width: 46px; height: 46px; }
.call-incoming .avatar { animation: ringpulse 1.4s ease-in-out infinite; }
@keyframes ringpulse { 50% { box-shadow: 0 0 0 7px rgba(43,182,115,.3); } }
@media (max-width: 768px) {
  .call.min { width: 210px; height: 170px; right: 10px; bottom: 66px; }
  .call.duo .tile.me { width: 32%; right: 18px; bottom: 10px; aspect-ratio: 3 / 4; }
  .call-grid[data-n="3"], .call-grid[data-n="4"] { --cols: 2; }
  .call-grid[data-n="5"], .call-grid[data-n="6"], .call-grid[data-n="7"], .call-grid[data-n="8"], .call-grid[data-n="9"] { --cols: 2; }
  .call-ctrls { gap: 12px; }
}

/* LiveKit: người đang nói, phòng đông, trạng thái mạng */
.tile.speaking { box-shadow: 0 0 0 3px var(--accent), 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent); }
.tile.screen video { object-fit: contain; }
.call.crowd .call-grid { grid-auto-rows: 150px; overflow-y: auto; align-content: start; padding-bottom: 6px; }
@media (max-width: 768px) { .call.crowd .call-grid { grid-auto-rows: 120px; } }
.call.crowd .avatar.xl { width: 52px; height: 52px; font-size: 20px; }
.call.crowd .tile-name { font-size: 12px; }
.call-count { font-size: 12.5px; color: #9a9a9a; }
.call-net { margin: 0 12px 8px; padding: 6px 12px; border-radius: 8px; background: rgba(245,165,36,.18); color: #f5c169; font-size: 13px; text-align: center; }
.audio-unlock { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; padding: 12px 22px; font-size: 15px; }
.call-btn:disabled { opacity: .45; cursor: default; }

/* màn hình đen khi gọi (áp tai / bỏ túi) */
.pocket { position: fixed; inset: 0; z-index: 200; background: #000; display: grid; place-items: end center; padding-bottom: 18vh; touch-action: none; user-select: none; -webkit-user-select: none; }
.pocket-hint { color: #333; font-size: 13px; transition: color .3s; }
.pocket.pressing .pocket-hint { color: #888; }

/* chất lượng mạng trên ô */
.q-bars { display: inline-flex; align-items: flex-end; gap: 1px; height: 11px; margin-right: 2px; }
.q-bars i { width: 3px; background: rgba(255,255,255,.25); border-radius: 1px; }
.q-bars i:nth-child(1) { height: 4px; } .q-bars i:nth-child(2) { height: 7px; } .q-bars i:nth-child(3) { height: 11px; }
.q-bars[data-q="3"] i { background: #2BD46A; }
.q-bars[data-q="2"] i:nth-child(-n+2) { background: #F5C542; }
.q-bars[data-q="1"] i:nth-child(1) { background: #FF6369; }
/* bảng cài đặt âm thanh */
.call-panel { position: absolute; right: 14px; top: 64px; bottom: 96px; width: min(360px, calc(100% - 28px)); background: #1c1c1e; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; z-index: 6; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.6); color: #eee; }
.cp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px 16px; }
.cp-body { overflow-y: auto; padding: 4px 16px 16px; }
.cp-label { display: block; font-size: 12px; color: #9a9a9a; margin: 12px 0 6px; }
.call-panel .input { background: #111; color: #eee; border-color: #333; width: 100%; }
.cp-meter { position: relative; height: 10px; border-radius: 5px; background: #333; overflow: hidden; }
.cp-meter i { position: absolute; left: 0; top: 0; bottom: 0; background: #2BD46A; transition: width .05s linear; }
.cp-meter b { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; opacity: .8; }
.cp-meter.clip i { background: #FF6369; }
.cp-warn { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(255,99,105,.14); color: #ffb3b6; font-size: 12.5px; line-height: 1.45; }
.cp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; cursor: pointer; font-size: 14px; }
.cp-row small { display: block; color: #8a8a8a; font-size: 12px; }
.cp-sep { height: 1px; background: rgba(255,255,255,.08); margin: 12px 0 4px; }
.cp-stats { font-size: 12.5px; line-height: 1.7; color: #ccc; font-variant-numeric: tabular-nums; }
.cp-tip { margin-top: 10px; font-size: 12px; color: #8a8a8a; line-height: 1.5; }
@media (max-width: 768px) { .call-panel { top: 56px; bottom: 90px; right: 8px; width: calc(100% - 16px); } }

/* avatar + danh sách thành viên ở đầu khung chat */
.chat-head .head-avatar { cursor: pointer; flex: none; }
.chat-head .head-avatar .dot-on, .chat-head .head-avatar .dot-off { border-color: var(--chat-bg); }
.sub-link { color: inherit; font-size: inherit; padding: 0; border-radius: 3px; }
.sub-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.sub-link.on { color: #2BD46A; }
.member-pop { width: 290px; max-height: min(440px, 70vh); display: flex; flex-direction: column; }
.ml-head { padding: 10px 14px 6px; font-size: 12px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; }
.ml-search { padding: 0 10px 6px; }
.ml-search .input { padding: 6px 10px; }
.ml-list { overflow-y: auto; padding: 2px 4px 6px; }
.ml-row { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 6px; }
.ml-row.clickable { cursor: pointer; }
.ml-row.clickable:hover { background: var(--side-hover); }
.ml-row .avatar .dot-on, .ml-row .avatar .dot-off { border-color: var(--panel); }
.ml-meta { min-width: 0; flex: 1; }
.ml-name { font-size: 13.5px; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-sub { font-size: 11.5px; color: var(--fg-3); }
.ml-sub.on { color: #2BD46A; }
@media (max-width: 768px) { .member-pop { width: calc(100vw - 24px); } }

/* ---------- thả cảm xúc ---------- */
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -6px; position: relative; z-index: 1; padding: 0 6px; }
.msg.me .reacts { justify-content: flex-end; }
.react-chip { display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(0,0,0,.15); font-size: 12px; color: var(--fg-2); line-height: 1; }
.react-chip .e { font-size: 13px; }
.react-chip.mine { border-color: color-mix(in srgb, var(--accent) 60%, transparent); background: var(--mention-bg); color: var(--accent); font-weight: 600; }
.react-chip:hover { filter: brightness(1.1); }
.react-total { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 11px; font-size: 11.5px; color: var(--fg-3); cursor: pointer; }
.react-total:hover { color: var(--fg); text-decoration: underline; }
.msg .actions .react-btn { font-size: 17px; line-height: 1; color: var(--fg-2); }
.msg .actions .react-btn:hover { color: #FA5151; }
.react-pop { display: flex; gap: 2px; padding: 4px 6px; border-radius: 22px; }
.react-pop .rp-e { font-size: 24px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; transition: transform .12s ease, background .12s; }
.react-pop .rp-e:hover { transform: scale(1.3) translateY(-3px); }
.react-pop .rp-e.on { background: var(--mention-bg); }
.react-pop-in .react-chip { animation: rpop .3s ease; }
@keyframes rpop { 0% { transform: scale(.4); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
