/* LTV Chat — © 2026 letuanvu.com */
:root {
  --primary: #0068ff;
  --primary-2: #0050c8;
  --primary-soft: #e5efff;
  --nav: #0068ff;
  --bg: #ffffff;
  --bg-2: #f3f5f7;
  --bg-3: #e9ecf0;
  --hover: #f1f4f8;
  --active: #e5efff;
  --chat-bg: #eef0f1;
  --text: #081c36;
  --text-2: #4a5568;
  --muted: #7589a3;
  --border: #e1e4ea;
  --bubble-me: #dbebff;
  --bubble: #ffffff;
  --danger: #e53935;
  --success: #12b76a;
  --shadow: 0 6px 24px rgba(10, 30, 60, .14);
  --radius: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --primary: #3d8bff;
  --primary-2: #2f74de;
  --primary-soft: #1d2f4d;
  --nav: #102033;
  --bg: #17191d;
  --bg-2: #202328;
  --bg-3: #2a2e35;
  --hover: #23272d;
  --active: #1d2f4d;
  --chat-bg: #0f1114;
  --text: #e8ecf1;
  --text-2: #b9c2cf;
  --muted: #8794a6;
  --border: #2c3138;
  --bubble-me: #1e3a66;
  --bubble: #23272d;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; } /* không tự phóng chữ khi xoay ngang */
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; /* không kéo giãn / kéo để tải lại cả trang */
}
button, input, textarea, select { font: inherit; color: inherit; }
/* Bỏ độ trễ & phóng to khi chạm hai lần vào nút trên điện thoại */
button, a, label, .conv-item, .user-row, .msg, .nav-btn, .icon-btn { touch-action: manipulation; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--primary); }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* buttons & fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 6px; background: var(--bg-3); font-weight: 600;
  transition: background .15s;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: #fdecec; color: var(--danger); }
:root[data-theme="dark"] .btn.danger { background: #3a1f22; }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background .15s; flex: none; font-size: 20px;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.active { color: var(--primary); background: var(--active); }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 4px; font-weight: 500; }
.field input, .field textarea, .input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); outline: none; transition: border-color .15s;
}
.field textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 70px; }
.field input:focus, .field textarea:focus, .input:focus { border-color: var(--primary); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* avatar */
.av {
  border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; overflow: hidden; position: relative; user-select: none;
  background-size: cover; background-position: center;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av-wrap { position: relative; flex: none; display: inline-flex; }
.av-wrap .on {
  position: absolute; right: 1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--bg);
}

/* ================= AUTH ================= */
#auth {
  height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(135deg, #e8f1ff 0%, #f6f9ff 50%, #e3f0ff 100%);
}
:root[data-theme="dark"] #auth { background: linear-gradient(135deg, #0d1626, #111a2b); }
.auth-card {
  width: 100%; max-width: 400px; background: var(--bg); border-radius: 16px; padding: 32px 28px 20px;
  box-shadow: var(--shadow);
}
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 30px; font-weight: 800; color: var(--primary); }
.auth-logo img { width: 48px; height: 48px; }
.auth-sub { text-align: center; color: var(--muted); margin: 6px 0 22px; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.auth-tabs button { flex: 1; padding: 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.auth-tabs button.active { color: var(--primary); border-color: var(--primary); }
#authForm:not(.register) .reg-only { display: none; }
.copyright { text-align: center; font-size: 12px; color: var(--muted); margin: 18px 0 0; }

/* ================= LAYOUT ================= */
/* --app-h: chiều cao vùng nhìn thấy thật (trừ bàn phím ảo), do app.js cập nhật theo visualViewport */
#app { display: flex; height: 100%; height: var(--app-h, 100dvh); }
#nav {
  width: 64px; background: var(--nav); display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 10px; gap: 4px; flex: none;
}
.nav-avatar { margin-bottom: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.6); }
.nav-btn {
  width: 48px; height: 48px; border-radius: 10px; color: rgba(255,255,255,.85);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.nav-btn svg { width: 26px; height: 26px; }
.nav-btn:hover { background: rgba(255,255,255,.12); }
.nav-btn.active { background: rgba(0,0,0,.18); color: #fff; }
.nav-spacer { flex: 1; }
.badge {
  position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700;
}
.badge:empty { display: none; }
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 8px; right: 8px; }
.badge.dot:empty { display: none; }
.badge.dot.show { display: block; }

#listPane {
  width: 340px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex: none; background: var(--bg);
}
.list-head { display: flex; align-items: center; gap: 4px; padding: 14px 12px 8px; }
.searchbox {
  flex: 1; display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 8px; background: var(--bg-3);
}
.searchbox svg { width: 18px; height: 18px; color: var(--muted); }
.searchbox input { flex: 1; border: 0; outline: 0; background: none; min-width: 0; }
.list-filter { display: flex; gap: 16px; padding: 4px 16px 0; border-bottom: 1px solid var(--border); }
.list-filter button { padding: 8px 0; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.list-filter button.active { color: var(--primary); border-color: var(--primary); }
#listBody { flex: 1; overflow-y: auto; }
.list-section { padding: 12px 16px 6px; font-weight: 700; font-size: 13px; color: var(--text-2); display: flex; align-items: center; justify-content: space-between; }

.conv-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; position: relative; }
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--active); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; align-items: baseline; gap: 6px; }
.conv-name { flex: 1; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--muted); flex: none; }
.conv-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.conv-last { flex: 1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.unread .conv-name, .conv-item.unread .conv-last { font-weight: 700; color: var(--text); }
.conv-unread { background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 0 6px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; }
.conv-flags { display: flex; gap: 2px; color: var(--muted); }
.conv-flags svg { width: 14px; height: 14px; }
.conv-item .row-more { opacity: 0; }
.conv-item:hover .row-more { opacity: 1; }

.empty { padding: 40px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 56px; height: 56px; opacity: .4; display: block; margin: 0 auto 10px; }

.user-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; cursor: pointer; }
.user-row:hover { background: var(--hover); }
.user-row .grow { flex: 1; min-width: 0; }
.user-row .sub { font-size: 12.5px; color: var(--muted); }
.user-row .actions { display: flex; gap: 6px; }
.alpha { padding: 8px 16px 2px; font-weight: 700; color: var(--muted); font-size: 12.5px; }

/* main */
#mainPane { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--chat-bg); }
.welcome { margin: auto; text-align: center; max-width: 440px; padding: 24px; }
.welcome img { width: 110px; height: 110px; margin-bottom: 12px; }
.welcome h2 { font-weight: 400; margin: 0 0 8px; }
.welcome p { color: var(--muted); }

#chat { display: flex; flex-direction: column; height: 100%; position: relative; min-height: 0; }
.chat-head {
  height: 64px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; background: var(--bg);
  border-bottom: 1px solid var(--border); flex: none;
}
.chat-head-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.chat-head-info .t { font-weight: 600; font-size: 16px; }
.chat-head-info .s { font-size: 12.5px; color: var(--muted); }
.chat-head-actions { display: flex; gap: 2px; }

.pin-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.pin-bar svg { color: var(--primary); width: 18px; }
.pin-bar .pc { flex: 1; min-width: 0; }
.pin-bar .pc b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }

.messages { flex: 1; overflow-y: auto; padding: 12px 16px 6px; min-height: 0; overscroll-behavior: contain; }
.load-more { text-align: center; color: var(--muted); font-size: 12px; padding: 6px; }
.day-sep { text-align: center; margin: 14px 0 8px; }
.day-sep span { background: rgba(0,0,0,.28); color: #fff; font-size: 11.5px; padding: 3px 10px; border-radius: 10px; }
:root[data-theme="dark"] .day-sep span { background: rgba(255,255,255,.12); }
.sys { text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px auto; max-width: 80%; }
.sys span { background: var(--bg); padding: 4px 12px; border-radius: 12px; display: inline-block; }

.msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 2px; position: relative; }
.msg.first { margin-top: 10px; }
.msg.me { flex-direction: row-reverse; }
.msg .av-slot { width: 32px; flex: none; align-self: flex-start; }
.msg.me .av-slot { display: none; }
.msg-col { max-width: min(560px, 72%); display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.msg.me .msg-col { align-items: flex-end; }
.msg-sender { font-size: 12px; color: var(--muted); margin: 0 0 2px 4px; }
.bubble {
  background: var(--bubble); border-radius: 12px; padding: 8px 12px; position: relative; word-wrap: break-word;
  overflow-wrap: anywhere; box-shadow: 0 1px 1px rgba(0,0,0,.06); max-width: 100%; white-space: pre-wrap;
}
.msg.me .bubble { background: var(--bubble-me); }
.msg.flash .bubble { animation: flash 1.4s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--primary); } 100% { box-shadow: none; } }
.bubble.media { padding: 4px; background: var(--bubble); }
.bubble.bare { background: none !important; box-shadow: none; padding: 0; }
.bubble .meta { font-size: 11px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.bubble.media .meta { padding: 0 6px 2px; }
.bubble .fwd { font-size: 11.5px; color: var(--muted); font-style: italic; margin-bottom: 3px; display: flex; gap: 4px; align-items: center; }
.bubble .fwd svg { width: 13px; height: 13px; }
.recalled { color: var(--muted); font-style: italic; }
.quote {
  border-left: 3px solid var(--primary); padding: 4px 8px; margin-bottom: 6px; border-radius: 4px; background: rgba(0,104,255,.07);
  font-size: 12.5px; cursor: pointer; white-space: normal;
}
.quote b { display: block; font-size: 12px; }
.quote span { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* Kích thước cố định theo px/vw (không dùng %) để khung bong bóng co theo ảnh thay vì giãn theo kích thước gốc của ảnh */
.m-img { max-width: min(320px, 62vw); max-height: 360px; width: auto; height: auto; border-radius: 9px; display: block; cursor: zoom-in; background: var(--bg-3); min-width: 60px; min-height: 60px; object-fit: cover; }
.m-video { max-width: min(360px, 66vw); max-height: 360px; border-radius: 9px; display: block; background: #000; }
.m-audio { width: 260px; max-width: 100%; height: 40px; display: block; }
.sticker { font-size: 72px; line-height: 1.1; }
.emoji-only { font-size: 38px; line-height: 1.2; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 320px; text-decoration: none; color: inherit; }
.file-card .fi { width: 40px; height: 48px; border-radius: 6px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; text-transform: uppercase; flex: none; }
.file-card .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fs { font-size: 12px; color: var(--muted); }
.call-card { display: flex; align-items: center; gap: 10px; min-width: 200px; white-space: normal; }
.call-card .ci { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.call-card .ci.missed { background: #fdecec; color: var(--danger); }
.call-card .cb { margin-top: 6px; }
.reactions {
  display: flex; gap: 2px; align-items: center; background: var(--bg); border-radius: 10px; padding: 1px 6px;
  font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.15); margin-top: -8px; position: relative; z-index: 1; cursor: pointer;
  align-self: flex-end; margin-right: 6px;
}
.msg.me .reactions { align-self: flex-start; margin-left: 6px; margin-right: 0; }
.reactions small { color: var(--muted); margin-left: 3px; }
.seen { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 2px; align-items: center; }
.seen .av { border: 1px solid var(--bg); }
.msg-actions {
  display: none; align-items: center; gap: 2px; align-self: center; background: var(--bg); border-radius: 8px;
  padding: 2px; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.msg-actions .icon-btn { width: 28px; height: 28px; }
.msg-actions svg { width: 17px; height: 17px; }
.msg:hover .msg-actions, .msg.menu-open .msg-actions { display: flex; }
@media (hover: none) { .msg:hover .msg-actions { display: none; } .msg.menu-open .msg-actions { display: flex; } }

.scroll-down {
  position: absolute; right: 22px; bottom: 140px; width: 40px; height: 40px; border-radius: 50%; background: var(--bg);
  box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; color: var(--primary); z-index: 5;
}
.scroll-down b { position: absolute; top: -6px; right: -4px; background: var(--danger); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 5px; }
.scroll-down b:empty { display: none; }
.typing-bar { height: 20px; padding: 0 18px; font-size: 12px; color: var(--muted); font-style: italic; flex: none; }

.composer { background: var(--bg); border-top: 1px solid var(--border); flex: none; position: relative; padding-bottom: env(safe-area-inset-bottom); }
.composer-tools { display: flex; gap: 2px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.composer-row { display: flex; align-items: flex-end; gap: 4px; padding: 8px 8px 8px 14px; }
#input {
  flex: 1; border: 0; outline: 0; resize: none; background: none; max-height: 140px; line-height: 1.45; padding: 8px 0;
  min-height: calc(1.45em + 16px); /* luôn đủ cao cho 1 dòng chữ, kể cả khi bị đo lúc đang ẩn */
  font-size: 15px;
}
.icon-btn.send { color: var(--primary); display: none; }
.composer.has-text .icon-btn.send { display: inline-flex; }
.composer.has-text #btnQuickLike { display: none; }
.reply-bar, .upload-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.reply-bar .rb { flex: 1; min-width: 0; border-left: 3px solid var(--primary); padding-left: 8px; }
.reply-bar .rb b { display: block; font-size: 12px; }
.upload-progress { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-3); overflow: hidden; }
.upload-progress i { display: block; height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.record-bar { position: absolute; inset: 0; background: var(--bg); display: flex; align-items: center; gap: 12px; padding: 0 16px; z-index: 3; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.rec-label { flex: 1; color: var(--muted); }
@keyframes pulse { 50% { opacity: .3; } }
.blocked-bar { position: absolute; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; gap: 12px; z-index: 4; color: var(--muted); padding: 8px; text-align: center; }
.drop-zone {
  position: absolute; inset: 70px 12px 12px; border: 3px dashed var(--primary); border-radius: 16px; background: rgba(0,104,255,.08);
  display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--primary); font-weight: 600; z-index: 20; pointer-events: none;
}

/* info pane */
#infoPane { width: 340px; border-left: 1px solid var(--border); background: var(--bg); overflow-y: auto; flex: none; }
.info-head { height: 64px; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; border-bottom: 1px solid var(--border); position: relative; }
.info-head .icon-btn { position: absolute; left: 10px; }
.info-profile { text-align: center; padding: 20px 16px 14px; }
.info-profile .nm { font-size: 17px; font-weight: 600; margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.info-quick { display: flex; justify-content: center; gap: 22px; padding: 4px 16px 16px; }
.info-quick button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); width: 64px; }
.info-quick button span.ic { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-3); display: flex; align-items: center; justify-content: center; }
.info-quick button span.ic svg { width: 19px; height: 19px; }
.info-sec { border-top: 8px solid var(--bg-2); padding: 12px 16px; }
.info-sec h4 { margin: 0 0 10px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.media-grid > * { aspect-ratio: 1; width: 100%; object-fit: cover; border-radius: 6px; cursor: pointer; background: var(--bg-3); }
.info-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.info-row:hover { color: var(--primary); }
.info-row.danger { color: var(--danger); }
.info-row svg { width: 20px; height: 20px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.member-row .grow { flex: 1; min-width: 0; }
.role-tag { font-size: 11px; color: var(--muted); }
.search-result { padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.search-result:hover { color: var(--primary); }
.search-result mark { background: #ffe58a; color: inherit; border-radius: 2px; }

/* timeline */
#timeline { flex: 1; overflow-y: auto; }
.feed { max-width: 620px; margin: 0 auto; padding: 16px 12px 40px; }
.card { background: var(--bg); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.post-composer textarea { width: 100%; border: 0; outline: 0; resize: none; background: none; font-size: 15px; min-height: 60px; }
.post-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.post-head .grow { flex: 1; }
.post-head .nm { font-weight: 600; }
.post-head .tm { font-size: 12px; color: var(--muted); }
.post-content { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 10px; font-size: 15px; }
.post-images { display: grid; gap: 4px; margin: 0 -16px 10px; }
.post-images.n1 { grid-template-columns: 1fr; }
.post-images.n2, .post-images.n4 { grid-template-columns: 1fr 1fr; }
.post-images.n3, .post-images.nmany { grid-template-columns: 1fr 1fr 1fr; }
.post-images img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; display: block; }
.post-images.n1 img { aspect-ratio: auto; max-height: 520px; }
.post-stats { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 4px 0 8px; border-bottom: 1px solid var(--border); }
.post-actions { display: flex; padding-top: 6px; }
.post-actions button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px; border-radius: 6px; color: var(--text-2); font-weight: 600; }
.post-actions button:hover { background: var(--hover); }
.post-actions button.liked { color: var(--danger); }
.post-actions svg { width: 19px; height: 19px; }
.comments { margin-top: 8px; }
.comment { display: flex; gap: 8px; margin-top: 8px; }
.comment .cb { background: var(--bg-2); border-radius: 12px; padding: 6px 12px; font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .cb b { display: block; font-size: 12.5px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.comment-form input { flex: 1; height: 36px; border-radius: 18px; border: 1px solid var(--border); padding: 0 14px; background: var(--bg-2); outline: 0; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.thumbs .th { position: relative; width: 80px; height: 80px; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.thumbs .th button { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; }

/* trang cá nhân */
#profile { position: absolute; inset: 0; z-index: 15; overflow-y: auto; background: var(--chat-bg); container-type: inline-size; }
.pf-top { background: var(--bg); box-shadow: 0 1px 2px rgba(0,0,0,.06); position: relative; }
.pf-back { position: absolute; top: 12px; left: 12px; z-index: 3; background: rgba(0,0,0,.4); color: #fff; border-radius: 50%; }
.pf-back:hover { background: rgba(0,0,0,.6); }
.pf-cover {
  height: 260px; max-width: 980px; margin: 0 auto; position: relative; border-radius: 0 0 14px 14px;
  background: linear-gradient(135deg, #5b9cff, #0068ff 55%, #0044aa) center / cover no-repeat;
}
.pf-cover[data-pf] { cursor: zoom-in; }
.pf-cover-btn { position: absolute; right: 14px; bottom: 14px; background: rgba(255,255,255,.92); color: #111; }
.pf-cover-btn svg { width: 18px; height: 18px; }
.pf-head { max-width: 980px; margin: 0 auto; text-align: center; padding: 0 16px 14px; }
.pf-av { display: inline-block; margin-top: -72px; position: relative; z-index: 2; cursor: pointer; }
.pf-av > .av { border: 5px solid var(--bg); box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.pf-av .cam { width: 36px; height: 36px; bottom: 8px; right: 8px; }
.pf-name { font-size: 26px; font-weight: 800; margin-top: 6px; }
.pf-bio { color: var(--text-2); margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pf-bio a, .pf-meta a { text-decoration: none; color: inherit; }
.pf-bio a { color: var(--primary); }
.pf-meta { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.pf-meta b { color: var(--text); }
.pf-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.pf-actions .btn svg { width: 18px; height: 18px; }
.pf-tabs { display: flex; gap: 2px; max-width: 980px; margin: 0 auto; padding: 0 12px; border-top: 1px solid var(--border); overflow-x: auto; }
.pf-tabs button { padding: 12px 16px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.pf-tabs button:hover { color: var(--text); }
.pf-tabs button.active { color: var(--primary); border-color: var(--primary); }
.pf-body { max-width: 980px; margin: 16px auto 0; padding: 0 12px 40px; display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.pf-side { position: sticky; top: 12px; }
.pf-side .card h4, .pf-main .card h4 { margin: 0 0 10px; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.pf-side .card h4 a { font-size: 13px; font-weight: 500; color: var(--primary); text-decoration: none; }
.pf-info { display: flex; gap: 10px; align-items: center; padding: 6px 0; color: var(--text-2); }
.pf-info svg { width: 20px; height: 20px; color: var(--muted); }
.pf-friends { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.pf-friend { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; text-align: center; min-width: 0; }
.pf-friend span { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.pf-friend:hover span { color: var(--primary); }
.pf-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.pf-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: zoom-in; display: block; background: var(--bg-3); }
.pf-photos.big { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.pf-friend-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.pf-friend-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; min-width: 0; }
.pf-friend-card:hover { background: var(--hover); }
.pf-main .post-composer, .pf-main .post { margin-bottom: 12px; }
@container (max-width: 860px) {
  .pf-body { grid-template-columns: 1fr; }
  .pf-side { position: static; }
  .pf-cover { height: 200px; border-radius: 0; }
}

/* ===== tính năng soạn tin mở rộng ===== */
.composer-tools { overflow-x: auto; scrollbar-width: none; }
.composer-tools::-webkit-scrollbar { display: none; }
/* định dạng văn bản */
.bubble b { font-weight: 700; }
.bubble code { background: rgba(0,0,0,.07); border-radius: 4px; padding: 1px 5px; font-family: Consolas, monospace; font-size: 13px; }
:root[data-theme="dark"] .bubble code { background: rgba(255,255,255,.1); }
.f-big { font-size: 1.35em; font-weight: 600; }
.f-red { color: #e53935; } .f-orange { color: #fb8c00; } .f-green { color: #2e9d48; } .f-blue { color: #1e88e5; } .f-purple { color: #8e24aa; }
.f-list { margin: 2px 0; padding-left: 22px; white-space: normal; }
.format-bar { display: flex; align-items: center; gap: 2px; padding: 4px 10px 6px; flex-wrap: wrap; }
.format-bar button { min-width: 32px; height: 30px; border-radius: 6px; font-size: 15px; color: var(--text-2); }
.format-bar button:hover { background: var(--hover); }
.fmt-hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.color-pick { display: flex; gap: 8px; padding: 8px 12px; }
.color-pick button { width: 26px; height: 26px; border-radius: 50%; }
/* tin quan trọng / khẩn cấp */
.priority-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
.priority-bar svg { width: 18px; height: 18px; }
.priority-bar span { flex: 1; }
.priority-bar.important { background: #fff4e5; color: #b45f00; }
.priority-bar.urgent { background: #fdecec; color: #c62828; }
:root[data-theme="dark"] .priority-bar.important { background: #3a2a14; color: #ffb35c; }
:root[data-theme="dark"] .priority-bar.urgent { background: #3a1f22; color: #ff8a80; }
.prio { display: flex; width: fit-content; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; border-radius: 10px; padding: 1px 8px 1px 4px; margin-bottom: 4px; }
.prio svg { width: 14px; height: 14px; }
.prio.important { background: #fff1de; color: #c66a00; }
.prio.urgent { background: #e53935; color: #fff; }
.msg.p-important .bubble { box-shadow: 0 0 0 2px #fb8c00; }
.msg.p-urgent .bubble { box-shadow: 0 0 0 2px #e53935; }
/* nhắc hẹn */
.rem-card { display: flex; gap: 10px; align-items: center; min-width: 220px; cursor: pointer; white-space: normal; }
.rc-ic { width: 40px; height: 40px; border-radius: 50%; background: #fff1de; color: #fb8c00; display: flex; align-items: center; justify-content: center; flex: none; }
.rem-card.due .rc-ic { background: #e53935; color: #fff; animation: pulse 1s 3; }
.rc-k { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.rc-t { font-weight: 700; }
.rc-s { font-size: 12.5px; color: var(--text-2); }
.rem-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.rem-row > svg { color: #fb8c00; width: 20px; height: 20px; }
.rem-row .grow { flex: 1; min-width: 0; }
.info-sec h4 .btn svg { width: 16px; height: 16px; }
/* phân loại */
.lbl-tag { color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 4px; padding: 0 5px; line-height: 16px; white-space: nowrap; flex: none; }
.chip-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.chip-row button { padding: 4px 12px; border-radius: 14px; background: var(--bg-3); font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip-row button.active { background: var(--primary); color: #fff; }
/* danh thiếp */
.contact-card { width: 260px; max-width: 100%; white-space: normal; }
.cc-top { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.cc-name { font-weight: 700; font-size: 15px; }
.cc-phone { font-size: 13px; color: var(--text-2); }
.cc-actions { display: flex; gap: 6px; margin-top: 10px; }
.cc-actions .btn { flex: 1; }
.cc-actions svg { width: 15px; height: 15px; }
.cc-foot, .bk-foot { font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 10px; padding-top: 6px; }
/* sticker */
.sticker-panel { width: 360px; }
.sp-search { padding: 8px 10px 0; }
.sp-body { height: 300px; overflow-y: auto; padding: 0 4px; }
.sticker-panel .emoji-grid { max-height: none; overflow: visible; }
.sp-sec { font-weight: 700; font-size: 13px; padding: 10px 10px 0; }
.sp-packs { display: flex; gap: 2px; padding: 4px 6px; border-top: 1px solid var(--border); overflow-x: auto; }
.sp-packs button { width: 40px; height: 36px; border-radius: 8px; font-size: 22px; flex: none; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.sp-packs button:hover { background: var(--hover); }
.sticker { animation: pop .3s; }
/* tin nhắn nhanh + ngân hàng */
.quick-panel { width: 360px; padding: 0; }
.qp-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.qp-head a { color: var(--primary); font-weight: 600; text-decoration: none; }
.qp-list { max-height: 300px; overflow-y: auto; }
.qp-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 8px 14px; text-align: left; }
.qp-item:hover, .bk-item:hover { background: var(--hover); }
.qp-item b { color: var(--primary); font-size: 12.5px; }
.qp-item span { font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qp-hint { font-size: 12px; color: var(--muted); padding: 8px 14px; border-top: 1px solid var(--border); }
.qm-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.qm-row .qm-k { width: 120px; flex: none; }
.qm-row .qm-t { flex: 1; height: auto; padding: 8px 10px; resize: vertical; }
.bk-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 14px; }
.bk-logo { width: 38px; height: 38px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.tag-def { background: var(--bg-3); color: var(--text-2); font-size: 11px; border-radius: 4px; padding: 0 6px; font-weight: 600; }
.bm-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.bank-card { width: 300px; max-width: 100%; white-space: normal; }
.bk-head { display: flex; align-items: center; gap: 6px; color: var(--primary); margin-bottom: 8px; }
.bk-head svg { width: 18px; height: 18px; }
.bk-body { display: flex; gap: 12px; align-items: center; }
.bk-qr { width: 104px; height: 104px; background: #fff; border-radius: 8px; padding: 4px; cursor: zoom-in; flex: none; }
.bk-no { font-size: 17px; font-weight: 800; letter-spacing: .5px; word-break: break-all; }
.bk-holder { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.bank-card .btn svg { width: 15px; height: 15px; }
.lightbox .lb-body img[src*="vietqr"] { background: #fff; padding: 16px; border-radius: 12px; width: min(380px, 86vw); }
/* trình chụp & chú thích ảnh */
.ie { position: fixed; inset: 0; z-index: 1150; background: rgba(10,14,20,.92); display: flex; align-items: center; justify-content: center; }
.ie-stage { max-width: calc(100vw - 120px); max-height: calc(100vh - 110px); display: flex; }
.ie-stage canvas { max-width: calc(100vw - 120px); max-height: calc(100vh - 110px); cursor: crosshair; box-shadow: 0 6px 30px rgba(0,0,0,.6); touch-action: none; }
.ie-tools { position: fixed; right: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; background: #1f2329; border-radius: 10px; padding: 4px; gap: 2px; }
.ie-tools button, .ie-actions button { width: 42px; height: 42px; border-radius: 8px; color: #e8ecf1; display: flex; align-items: center; justify-content: center; }
.ie-tools button:hover, .ie-actions button:hover { background: rgba(255,255,255,.1); }
.ie-tools button.active { background: #3d8bff; color: #fff; }
.ie-color { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ie-color input { width: 26px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }
.ie-actions { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; background: #1f2329; border-radius: 10px; padding: 4px; }
.ie-actions .ie-send { width: auto; padding: 0 16px; gap: 6px; background: #12b76a; color: #fff; font-weight: 700; }
.ie-actions .ie-send:hover { background: #0e9b59; }
.ie-hint { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); color: #c8d3e3; font-size: 13px; background: rgba(0,0,0,.4); padding: 6px 14px; border-radius: 16px; }

/* quảng cáo */
.ad-tag { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 6px; vertical-align: 1px; }
.ad-banner { display: flex; align-items: center; gap: 10px; margin: 8px 10px; padding: 8px 6px 8px 8px; border-radius: 10px; background: var(--bg-2); cursor: pointer; }
.ad-banner:hover { background: var(--hover); }
.ab-img { width: 52px; height: 52px; border-radius: 8px; background: var(--bg-3) center / cover no-repeat; flex: none; }
.ab-b { flex: 1; min-width: 0; }
.ab-t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-d { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-x { width: 26px; height: 26px; }
.ab-x svg { width: 16px; height: 16px; }
.ad-card-tl { cursor: pointer; }
.ad-tl-img { aspect-ratio: 16 / 7; margin: 0 -16px 10px; background: var(--bg-3) center / cover no-repeat; }
.ad-tl-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ad-pop-img { aspect-ratio: 16 / 9; border-radius: 10px; background: var(--bg-3) center / cover no-repeat; cursor: pointer; }

/* popup menu & pickers */
.popup {
  position: fixed; z-index: 1000; background: var(--bg); border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0;
  min-width: 190px; max-width: calc(100vw - 16px); border: 1px solid var(--border);
}
.popup .mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 16px; text-align: left; font-size: 14px; }
.popup .mi:hover { background: var(--hover); }
.popup .mi.danger { color: var(--danger); }
.popup .mi svg { width: 18px; height: 18px; color: var(--muted); }
.popup .mi.danger svg { color: var(--danger); }
.popup .sep { height: 1px; background: var(--border); margin: 4px 0; }
.react-pick { display: flex; gap: 2px; padding: 4px 8px; }
.react-pick button { font-size: 26px; width: 40px; height: 40px; border-radius: 50%; transition: transform .12s; }
.react-pick button:hover { transform: scale(1.25); background: var(--hover); }
.emoji-panel { width: 340px; padding: 0; }
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); }
.emoji-tabs button { flex: 1; padding: 8px; font-weight: 600; color: var(--muted); font-size: 13px; }
.emoji-tabs button.active { color: var(--primary); box-shadow: inset 0 -2px var(--primary); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; max-height: 260px; overflow-y: auto; }
.emoji-grid button { font-size: 24px; height: 38px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-grid.stickers { grid-template-columns: repeat(4, 1fr); }
.emoji-grid.stickers button { font-size: 50px; height: 72px; }

/* modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--bg); border-radius: 12px; width: 100%; max-width: 440px; max-height: calc(var(--app-h, 100dvh) - 32px); display: flex; flex-direction: column;
  box-shadow: var(--shadow); animation: pop .18s;
}
.modal.wide { max-width: 520px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 16px; }
.modal-head .t { flex: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.pick-list { max-height: 340px; overflow-y: auto; margin: 0 -18px; }
.pick-list label { display: flex; align-items: center; gap: 12px; padding: 8px 18px; cursor: pointer; }
.pick-list label:hover { background: var(--hover); }
.pick-list input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { background: var(--primary-soft); color: var(--primary); border-radius: 14px; padding: 3px 10px; font-size: 12.5px; }
.profile-cover { height: 140px; margin: -16px -18px 0; background: linear-gradient(135deg, #5b9cff, #0068ff 60%, #0044aa); border-radius: 0; }
.profile-main { text-align: center; margin-top: -48px; }
.profile-main .av { border: 4px solid var(--bg); }
.profile-main .nm { font-size: 20px; font-weight: 700; margin-top: 6px; }
.profile-main .bio { color: var(--text-2); margin-top: 4px; }
.profile-actions { display: flex; gap: 8px; justify-content: center; margin: 16px 0 6px; flex-wrap: wrap; }
.kv { display: flex; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv span:first-child { width: 120px; color: var(--muted); }
.settings-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.settings-row .grow { flex: 1; }
.switch { width: 40px; height: 22px; border-radius: 11px; background: var(--bg-3); position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch.on { background: var(--primary); }
.switch.on::after { left: 20px; }
.avatar-edit { position: relative; display: inline-block; cursor: pointer; }
.avatar-edit .cam { position: absolute; bottom: 2px; right: 2px; width: 30px; height: 30px; border-radius: 50%; background: var(--bg-3); display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); }
.avatar-edit .cam svg { width: 16px; height: 16px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 1100; display: flex; align-items: center; justify-content: center; }
.lb-body img, .lb-body video { max-width: 88vw; max-height: 86vh; display: block; }
.lb-bar { position: absolute; top: 10px; right: 12px; left: 12px; display: flex; align-items: center; gap: 6px; justify-content: flex-end; color: #fff; z-index: 2; }
.lb-count { margin-right: auto; font-size: 14px; opacity: .85; }
.lb-bar .icon-btn { color: #fff; }
.lb-bar .icon-btn:hover { background: rgba(255,255,255,.15); }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; display: flex; align-items: center; justify-content: center; z-index: 2; }
.lb-nav:hover { background: rgba(255,255,255,.28); }
.lb-prev { left: 16px; } .lb-next { right: 16px; }

/* album nhiều ảnh trong một tin nhắn: mỗi hàng lấp kín chiều ngang, ô theo tỉ lệ ảnh */
.album { width: min(440px, 72vw); display: flex; flex-direction: column; gap: 2px; border-radius: 12px; overflow: hidden; }
.al-row { display: flex; gap: 2px; width: 100%; }
.al-item { position: relative; cursor: zoom-in; background: var(--bg-3); overflow: hidden; min-width: 0; }
.al-item img, .al-item video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.al-item:hover::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.08); }

/* ảnh / video / album hiển thị trực tiếp trên nền chat, không bọc bong bóng */
.bubble.bare-media { background: none !important; box-shadow: none; padding: 0; display: flex; flex-direction: column; align-items: flex-start; }
.msg.me .bubble.bare-media { align-items: flex-end; }
.bubble.bare-media .m-img, .bubble.bare-media .m-video { border-radius: 12px; }
.bubble.bare-media .meta { padding: 1px 8px; margin-top: 4px; border-radius: 10px; background: rgba(0,0,0,.22); color: #fff; font-size: 11px; width: fit-content; }
:root[data-theme="dark"] .bubble.bare-media .meta { background: rgba(255,255,255,.14); }
.al-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px; text-shadow: 0 1px 6px rgba(0,0,0,.6); pointer-events: none; }
.al-more { position: absolute; inset: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* toasts */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 1200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(20, 28, 40, .92); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow); animation: pop .2s; max-width: 90vw; }
.toast.err { background: #c62828; }

/* call */
#callRoot { position: fixed; inset: 0; z-index: 1050; background: #0b1220; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0b1220; }
.call-local { position: absolute; right: 16px; top: 16px; width: 180px; max-width: 32vw; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: #222; box-shadow: 0 4px 16px rgba(0,0,0,.5); transform: scaleX(-1); z-index: 2; }
.call-info { position: relative; z-index: 2; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.call-info .nm { font-size: 24px; font-weight: 600; }
.call-info .st { color: rgba(255,255,255,.75); }
#callRoot.video-on .call-info { position: absolute; top: 24px; left: 24px; align-items: flex-start; }
#callRoot.video-on .call-info .av { display: none; }
.call-ring .av { animation: ring 1.6s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(61,139,255,.6); } 70% { box-shadow: 0 0 0 28px rgba(61,139,255,0); } 100% { box-shadow: 0 0 0 0 rgba(61,139,255,0); } }
.call-controls { position: absolute; bottom: 48px; left: 0; right: 0; display: flex; justify-content: center; gap: 22px; z-index: 3; }
.call-controls button { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-controls button.off { background: #fff; color: #111; }
.call-controls button.end { background: #e53935; }
.call-controls button.accept { background: #12b76a; }
.call-controls svg { width: 28px; height: 28px; }

.mobile-only { display: none !important; }

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  #infoPane { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow); }
}
@media (max-width: 768px) {
  #app { flex-direction: column-reverse; }
  #nav {
    width: 100%; height: calc(56px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; padding: 0 0 env(safe-area-inset-bottom);
    background: var(--bg); border-top: 1px solid var(--border);
  }
  .nav-avatar { order: 10; margin: 0; border-color: var(--border); }
  .nav-spacer, #navCloud { display: none; }
  .nav-btn { color: var(--muted); }
  .nav-btn.active { background: none; color: var(--primary); }
  .nav-btn:hover { background: none; }
  #listPane { width: 100%; flex: 1; border: 0; min-height: 0; }
  #mainPane { display: none; }
  body.in-main #mainPane { display: flex; position: fixed; inset: 0; z-index: 40; }
  body.in-main #nav { display: none; }
  body.in-main #listPane { display: none; }
  body.tab-timeline #listPane { display: none; }
  body.tab-timeline #mainPane { display: flex; flex: 1; min-height: 0; position: static; }
  body.in-profile #mainPane { display: flex; position: fixed; inset: 0; z-index: 45; }
  body.in-profile #nav { display: none; }
  .pf-cover { height: 170px; }
  .pf-av > .av { width: 110px !important; height: 110px !important; }
  .pf-name { font-size: 22px; }
  .mobile-only { display: inline-flex !important; }
  #infoPane { position: fixed; inset: 0; width: 100%; z-index: 60; }
  .msg-col { max-width: 80%; }
  .chat-head { padding: 0 6px; }
  .call-local { width: 110px; }
  .scroll-down { bottom: 130px; }

  /* ---- Ổn định giao diện khi bàn phím bật lên ---- */
  /* Safari iPhone tự phóng to trang khi chạm ô nhập có chữ < 16px → mọi ô nhập dùng 16px trên điện thoại. */
  input, textarea, select { font-size: 16px !important; }
  /* Khóa trang ứng dụng tại chỗ: bàn phím không đẩy/cuộn cả trang lên. */
  body.chat-page { position: fixed; left: 0; right: 0; top: var(--app-top, 0px); width: 100%; height: var(--app-h, 100dvh); }
  /* Các màn hình phủ kín (chat, trang cá nhân, thông tin) cao đúng phần màn hình còn lại phía trên bàn phím. */
  body.in-main #mainPane, body.in-profile #mainPane, #infoPane { top: var(--app-top, 0px); bottom: auto; height: var(--app-h, 100dvh); }
  #auth { height: var(--app-h, 100dvh); overflow-y: auto; }
  .messages { overscroll-behavior: contain; }
}
