/* ===================== KHUNG CHAT (.ch-) ===================== */
.ch { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--bg); position: relative; }
.ch__body { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.ch__composer[hidden], .ch__selbar[hidden] { display: none; }
.ch__selbar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--bg-elev); }
.ch__selcount { font-weight: 700; }
.ch__selspacer { flex: 1; }
.ch__selclose { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); }
.ch__selclose:hover { background: var(--hover); }
.ch__composer-fail { padding: 14px; text-align: center; color: var(--danger); }

/* ---------- Đầu ---------- */
.ch-header { display: flex; align-items: center; gap: 6px; height: 64px; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--bg-elev); flex: none; }
.ch-header__back { display: none; }
.ch-header__who { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 4px 8px 4px 4px; border-radius: var(--r-md); text-align: left; }
.ch-header__who:hover { background: var(--hover); }
.ch-header__txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ch-header__txt b { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-header__txt small { color: var(--text-3); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-header__txt small.is-typing { color: var(--accent); }
.ch-header__spacer { flex: 1; }
.ch-header .is-on { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 760px) { .ch-header__back { display: inline-flex; } }

/* ---------- Tin ghim ---------- */
.ch-pinbar { display: flex; align-items: center; gap: 4px; padding: 6px 10px; background: var(--bg-elev); border-bottom: 1px solid var(--border); }
.ch-pinbar__body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; padding: 4px 6px; border-radius: var(--r-sm); }
.ch-pinbar__body:hover { background: var(--hover); }
.ch-pinbar__ic { color: var(--accent); display: inline-flex; }
.ch-pinbar__txt { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); line-height: 1.3; }
.ch-pinbar__txt b { color: var(--accent); font-size: var(--fs-xs); }
.ch-pinbar__txt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ch-pinbar__x { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--text-3); }
.ch-pinbar__x:hover { background: var(--hover); color: var(--text); }

/* ---------- Tìm trong chat ---------- */
.ch-search { background: var(--bg-elev); border-bottom: 1px solid var(--border); }
.ch-search__bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; color: var(--text-3); }
.ch-search__input { flex: 1; min-width: 0; height: 36px; border: 0; outline: 0; background: transparent; color: var(--text); }
.ch-search__info { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.ch-search__btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); }
.ch-search__btn:hover { background: var(--hover); }
.ch-search__list { max-height: 220px; overflow-y: auto; border-top: 1px solid var(--border); }
.ch-search__item { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; padding: 8px 14px; text-align: left; }
.ch-search__item:hover, .ch-search__item.is-active { background: var(--accent-soft); }
.ch-search__item span { grid-column: 1 / -1; color: var(--text-2); font-size: var(--fs-sm); }
.ch-search__item small { color: var(--text-3); }

/* ---------- Vùng cuộn ---------- */
.ch-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 0 6px; scroll-behavior: auto; }
.ch-list { display: flex; flex-direction: column; padding: 0 clamp(10px, 3vw, 28px); min-height: 100%; justify-content: flex-end; }
.ch-day { display: flex; justify-content: center; margin: 14px 0 8px; } /* không dùng sticky: các thanh ngày cùng một cha sẽ chồng lên nhau khi cuộn */
.ch-day span { padding: 3px 12px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); background: var(--chat-bg); letter-spacing: .02em; }
.ch-older { display: flex; justify-content: center; padding: 8px; }
.ch-older__btn { color: var(--accent); font-weight: 600; font-size: var(--fs-sm); padding: 6px 14px; border-radius: var(--r-pill); }
.ch-older__btn:hover { background: var(--accent-soft); }

.ch-jump { position: absolute; right: 18px; bottom: 14px; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); z-index: 5; color: var(--text-2); }
.ch-jump:hover { color: var(--accent); }
.ch-jump__n { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; font-size: 11px; font-weight: 700; display: grid; place-items: center; color: var(--accent-text); background: var(--accent); }
.ch-jump__n[hidden] { display: none; }

.ch-typing { display: flex; align-items: center; gap: 8px; padding: 2px 22px 6px; font-size: var(--fs-xs); color: var(--text-3); }
.ch-typing[hidden] { display: none; }
.ch-typing__dots { display: inline-flex; gap: 3px; }
.ch-typing__dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: ch-dot 1s infinite; }
.ch-typing__dots i:nth-child(2) { animation-delay: .15s; } .ch-typing__dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ch-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ---------- Tin nhắn ---------- */
.ch-msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 14px; position: relative; max-width: 100%; border-radius: var(--r-md); }
.ch-msg.is-cont { margin-top: 2px; }
.ch-msg.is-me .ch-msg__main:has(.ch-bubble--recalled), .ch-msg .ch-bubble--recalled { font-size: 14px; }
.ch-msg.is-me { justify-content: flex-end; }
.ch-msg--system { justify-content: center; margin: 12px 0; }
.ch-system { padding: 4px 12px; border-radius: var(--r-pill); font-size: var(--fs-xs); color: var(--text-2); background: var(--surface-2); text-align: center; }
.ch-msg__main { display: flex; flex-direction: column; min-width: 0; max-width: min(72%, 560px); align-items: flex-start; }
.ch-msg.is-me .ch-msg__main { align-items: flex-end; }
.ch-msg__av, .ch-msg__gap { width: 32px; flex: none; cursor: pointer; }
.ch-msg.is-flash { animation: ch-flash 2s var(--ease); }
@keyframes ch-flash { 0%, 60% { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 6px transparent; } }
.ch-msg.is-selected { background: var(--accent-soft); box-shadow: 0 0 0 4px var(--accent-soft); }
.ch-select { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; color: var(--accent-text); flex: none; align-self: center; }
.ch-select.is-on { background: var(--accent); border-color: var(--accent); }

/* Bong bóng kiểu Messenger / iMessage: bo tròn lớn, phẳng, tin của mình màu nhấn đậm chữ trắng, tin người khác xám nhạt.
   Tin liền nhau cùng người gửi được gom nhóm: chỉ góc đầu/cuối nhóm bo tròn hẳn, các góc nối giữa các tin chỉ bo nhẹ. */
.ch-bubble { --br: 20px; --bs: 5px; position: relative; padding: 9px 14px 8px; border-radius: var(--br); background: var(--bubble-other); color: var(--bubble-other-text); box-shadow: none; overflow-wrap: anywhere; word-break: break-word; max-width: 100%; font-size: 15.5px; }
.ch-msg.is-me .ch-bubble { background: var(--bubble-me); color: var(--bubble-me-text); box-shadow: 0 1px 2px hsl(var(--accent-h) 60% 30% / .25); }
.ch-msg.is-other.is-cont .ch-bubble { border-top-left-radius: var(--bs); }
.ch-msg.is-me.is-cont .ch-bubble { border-top-right-radius: var(--bs); }
.ch-msg.is-other:not(.is-last) .ch-bubble { border-bottom-left-radius: var(--bs); }
.ch-msg.is-me:not(.is-last) .ch-bubble { border-bottom-right-radius: var(--bs); }
.ch-bubble--sticker, .ch-bubble--image, .ch-bubble--video, .ch-bubble--emoji { background: transparent !important; box-shadow: none !important; padding: 2px; }
.ch-bubble--sticker .ch-meta, .ch-bubble--image .ch-meta, .ch-bubble--video .ch-meta, .ch-bubble--emoji .ch-meta { color: var(--text-3); }
.ch-bubble--image:has(.ch-text), .ch-bubble--video:has(.ch-text) { background: var(--bubble-other) !important; padding: 4px 4px 7px; }
.ch-msg.is-me .ch-bubble--image:has(.ch-text), .ch-msg.is-me .ch-bubble--video:has(.ch-text) { background: var(--bubble-me) !important; color: var(--bubble-me-text); }
.ch-bubble--image .ch-text, .ch-bubble--video .ch-text { padding: 7px 10px 0; }
.ch-bubble--emoji .ch-text { font-size: 44px; line-height: 1.15; padding: 0 4px; }
.ch-meta.ch-meta--quiet { display: none; }
/* Cỡ chữ và độ dễ đọc */
.ch-text { font-size: inherit; letter-spacing: .005em; }
.ch-msg.is-me .ch-bubble a, .ch-msg.is-me .ch-bubble .ch-linkcard { color: #fff; }
.ch-bubble--recalled { background: transparent !important; border: 1px dashed var(--border-strong); box-shadow: none; color: var(--text-3) !important; }
.ch-recalled { display: inline-flex; align-items: center; gap: 6px; font-style: italic; font-size: var(--fs-sm); }
.ch-text { white-space: pre-wrap; line-height: 1.45; }
.ch-text a, .ch-linkcard { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ch-mention { font-weight: 700; color: var(--accent); }
.ch-msg.is-me .ch-mention { color: inherit; text-decoration: underline; }
.ch-sender { font-size: var(--fs-xs); font-weight: 700; color: var(--accent); margin-bottom: 2px; cursor: pointer; }
.ch-forwarded { display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); opacity: .75; margin-bottom: 3px; }
.ch-sticker { font-size: 76px; line-height: 1.1; padding: 4px 8px; }
.ch-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 2px; font-size: 11px; opacity: .72; line-height: 1; }
.ch-meta__state.is-read { color: #4fc3f7; opacity: 1; }
.ch-msg.is-me .ch-meta__state.is-read { color: #9fe6ff; }
.ch-meta__star { color: #f5b301; display: inline-flex; }
.ch-msg.is-timed .ch-bubble { box-shadow: 0 0 0 1.5px var(--warning) inset; }

.ch-quote { display: flex; gap: 8px; width: 100%; text-align: left; margin-bottom: 6px; padding: 5px 8px; border-radius: 10px; background: rgba(127, 127, 127, .14); }
.ch-quote__bar { width: 3px; border-radius: 2px; background: var(--accent); flex: none; }
.ch-msg.is-me .ch-quote__bar { background: currentColor; opacity: .7; }
.ch-quote__body { display: flex; flex-direction: column; min-width: 0; font-size: var(--fs-sm); line-height: 1.3; }
.ch-quote__body b { font-size: var(--fs-xs); }
.ch-quote__body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }

/* Ảnh */
.ch-images { display: grid; gap: 3px; border-radius: 18px; overflow: hidden; max-width: 340px; }

/* Video trong tin nhắn */
.ch-video { position: relative; display: block; padding: 0; border: 0; cursor: pointer; width: min(260px, 66vw); max-width: 100%; border-radius: 14px; overflow: hidden; background: #111; aspect-ratio: 16 / 9; }
.ch-video:not(.is-portrait) { width: min(320px, 72vw); }
.ch-video__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; background: #111; }
/* Chỉ một nút phát nhỏ ở giữa và thời lượng ở góc trên trái, không thanh điều khiển */
.ch-video__play { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; display: grid; place-items: center; padding-left: 2px; color: #fff; background: rgba(0, 0, 0, .42); }
.ch-video__dur { position: absolute; left: 8px; top: 8px; padding: 1px 7px; border-radius: 6px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: #fff; background: rgba(0, 0, 0, .5); pointer-events: none; }
.ch-video__dur:empty { display: none; }

/* ---------- Trình xem video toàn màn hình ---------- */
.vv-root { position: fixed; inset: 0; z-index: 1300; background: #000; display: flex; align-items: center; justify-content: center; touch-action: pan-y; -webkit-user-select: none; user-select: none; }
.vv-el { width: 100%; height: 100%; object-fit: contain; background: #000; transition: transform .2s var(--ease); }
.vv-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 0 calc(12px + env(safe-area-inset-left, 0px)); display: flex; }
.vv-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(255, 255, 255, .18); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); flex: none; }
.vv-big { position: absolute; left: 50%; top: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%; display: none; place-items: center; padding-left: 3px; color: #fff; background: rgba(0, 0, 0, .5); }
.vv-root.is-paused .vv-big { display: grid; }
.vv-bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px; padding: 28px calc(14px + env(safe-area-inset-right, 0px)) calc(14px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px)); background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }
.vv-time { color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; min-width: 34px; text-align: center; }
.vv-seek { flex: 1; min-width: 0; height: 24px; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.vv-seek::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.vv-seek::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.vv-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: #fff; }
.vv-seek::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: #fff; }
.vv-top, .vv-bar { transition: opacity .25s var(--ease); }
.vv-root.is-idle .vv-top, .vv-root.is-idle .vv-bar { opacity: 0; pointer-events: none; }
html.vv-open body { overflow: hidden; }
.ch-images.n2 { grid-template-columns: 1fr 1fr; } .ch-images.n3 { grid-template-columns: 1fr 1fr; } .ch-images.n3 .ch-images__cell:first-child { grid-column: 1 / -1; }
.ch-images.n4 { grid-template-columns: 1fr 1fr; }
.ch-images__cell { position: relative; display: block; padding: 0; background: var(--surface-2); overflow: hidden; aspect-ratio: 1; }
.ch-images.is-single .ch-images__cell { aspect-ratio: auto; }
.ch-images img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--dur); }
.ch-images.is-single img { max-height: 380px; object-fit: contain; }
.ch-images__cell:hover img { transform: scale(1.03); }
.ch-images__more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .5); color: #fff; font-size: 26px; font-weight: 700; }

/* Tệp / thoại / liên hệ / vị trí / liên kết */
.ch-file, .ch-contact, .ch-location, .ch-linkcard { display: flex; align-items: center; gap: 12px; min-width: 220px; text-decoration: none; text-align: left; color: inherit; }
.ch-file__ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: rgba(127, 127, 127, .2); flex: none; }
.ch-file__meta, .ch-contact__meta, .ch-location__meta, .ch-linkcard__txt { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.ch-file__meta b, .ch-linkcard__txt b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-file__meta small, .ch-contact__meta small, .ch-location__meta small, .ch-linkcard__txt small { opacity: .7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-location__pin { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); }
.ch-linkcard { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: rgba(127, 127, 127, .14); text-decoration: none; min-width: 0; }
.ch-linkcard__ic { opacity: .8; }

.ch-voice { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.ch-voice__btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); flex: none; }
.ch-msg.is-me .ch-voice__btn { background: rgba(255, 255, 255, .92); color: var(--accent); }
.ch-voice__wave { flex: 1; height: 30px; display: flex; align-items: center; gap: 2px; cursor: pointer; }
.ch-voice__wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .35; }
.ch-voice__wave i.is-done { opacity: 1; }
.ch-voice__time { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; opacity: .8; }

/* Bình chọn */
.ch-poll { min-width: 250px; display: flex; flex-direction: column; gap: 6px; }
.ch-poll__head { display: flex; gap: 8px; align-items: flex-start; }
.ch-poll__meta, .ch-poll__foot { opacity: .7; font-size: var(--fs-xs); }
.ch-poll__opt { position: relative; display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; overflow: hidden; text-align: left; background: rgba(127, 127, 127, .14); }
.ch-poll__opt:disabled { cursor: default; }
.ch-poll__fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); opacity: .22; transition: width var(--dur) var(--ease); }
.ch-poll__opt.is-mine { outline: 1.5px solid var(--accent); }
.ch-poll__check, .ch-poll__text, .ch-poll__count { position: relative; }
.ch-poll__text { flex: 1; }
.ch-poll__count { font-weight: 700; font-size: var(--fs-sm); }

/* Cảm xúc */
.ch-reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -6px; padding: 0 6px; position: relative; z-index: 1; }
.ch-react { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); font-size: 13px; }
.ch-react small { font-size: 11px; font-weight: 700; color: var(--text-2); }
.ch-react.is-mine { background: var(--accent-soft); border-color: var(--accent); }
.ch-quickreact { display: flex; gap: 2px; padding: 4px; }
.ch-quickreact__btn { width: 38px; height: 38px; border-radius: 50%; font-size: 22px; display: grid; place-items: center; transition: transform var(--dur-fast); }
.ch-quickreact__btn:hover { transform: scale(1.25); background: var(--hover); }
.ch-quickreact__btn.is-mine { background: var(--accent-soft); }

/* Thanh công cụ rê chuột */
.ch-hover { position: absolute; top: -14px; display: none; gap: 2px; padding: 2px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); z-index: 3; }
.ch-msg.is-other .ch-hover { left: 56px; } .ch-msg.is-me .ch-hover { right: 6px; }
.ch-msg:hover .ch-hover, .ch-msg:focus-within .ch-hover { display: inline-flex; }
.ch-hover__btn { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--text-2); }
.ch-hover__btn:hover { background: var(--hover); color: var(--accent); }
@media (hover: none) { .ch-hover { display: none !important; } }

/* Chuyển tiếp */
.ch-fwd { display: flex; flex-direction: column; gap: 10px; }
.ch-fwd__list { max-height: 300px; overflow-y: auto; }
.ch-fwd__row { display: flex; align-items: center; gap: 10px; }
.ch-fwd__preview { display: flex; flex-direction: column; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.ch-fwd__preview span { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-fwd__count { margin-right: auto; color: var(--text-2); font-size: var(--fs-sm); align-self: center; }

/* Trình xem ảnh */
.ch-viewer { --v-bg: 1; position: fixed; inset: 0; z-index: 1200; background: rgba(0, 0, 0, calc(.96 * var(--v-bg))); animation: ch-fade .16s var(--ease); overscroll-behavior: contain; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ch-viewer.is-leaving { opacity: 0; transition: opacity .18s; pointer-events: none; }
@keyframes ch-fade { from { opacity: 0; } }
.ch-viewer__stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
.ch-viewer__img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: contain; transform-origin: 50% 50%; will-change: transform; backface-visibility: hidden; -webkit-user-drag: none; pointer-events: auto; }
.ch-viewer__bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 6px; padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 24px; color: #fff; background: linear-gradient(rgba(0, 0, 0, .6), transparent); transition: opacity .2s, transform .2s; z-index: 2; }
.ch-viewer__who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-viewer__title { font-size: var(--fs-md); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-viewer__sub { font-size: var(--fs-xs); opacity: .8; }
.ch-viewer__foot { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 24px 12px calc(14px + env(safe-area-inset-bottom, 0px)); color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .55)); transition: opacity .2s; pointer-events: none; z-index: 2; }
.ch-viewer__count { font-size: var(--fs-sm); padding: 3px 12px; border-radius: 99px; background: rgba(255, 255, 255, .16); }
.ch-viewer.is-clean .ch-viewer__bar { opacity: 0; transform: translateY(-12px); pointer-events: none; }
.ch-viewer.is-clean .ch-viewer__foot, .ch-viewer.is-clean .is-prev, .ch-viewer.is-clean .is-next { opacity: 0; pointer-events: none; }
.ch-viewer__btn { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.ch-viewer__btn:hover, .ch-viewer__btn:active { background: rgba(255, 255, 255, .18); }
.ch-viewer .ch-viewer__btn[hidden] { display: none; }
.ch-viewer .is-prev, .ch-viewer .is-next { position: absolute; top: 50%; margin-top: -24px; width: 48px; height: 48px; background: rgba(255, 255, 255, .14); z-index: 2; transition: opacity .2s; }
.ch-viewer .is-prev { left: 14px; } .ch-viewer .is-next { right: 14px; }
@media (pointer: coarse) { .ch-viewer .is-prev, .ch-viewer .is-next { display: none; } } /* điện thoại: vuốt ngang thay cho nút */

/* Menu "…" : bảng trượt từ dưới lên trên điện thoại, thả xuống góc phải trên máy tính */
.ch-viewer__menu { position: absolute; inset: 0; z-index: 5; }
.ch-viewer__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); animation: ch-fade .16s var(--ease); }
.ch-viewer__sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); color: var(--text); border-radius: 18px 18px 0 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .35); animation: ch-sheet .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes ch-sheet { from { transform: translateY(100%); } }
.ch-viewer__grip { width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 4px auto 8px; }
.ch-viewer__item { display: flex; align-items: center; gap: 16px; width: 100%; padding: 14px 16px; border-radius: var(--r-md); font-size: var(--fs-lg, 16px); text-align: left; color: inherit; }
.ch-viewer__item:active, .ch-viewer__item:hover { background: var(--hover); }
.ch-viewer__item.is-danger { color: var(--danger); }
.ch-viewer__sep { height: 1px; background: var(--border); margin: 6px 12px; }
/* Máy tính (chuột): bố cục kiểu Zalo Web */
.ch-viewer__dock, .ch-viewer__strip, .ch-viewer__close { display: none; }
@media (hover: hover) and (pointer: fine) {
  .ch-viewer { --strip: 0px; background: rgba(18, 18, 18, var(--v-bg)); }
  .ch-viewer.has-strip { --strip: 132px; }
  .ch-viewer__stage { inset: 0 var(--strip) 64px 0; }
  .ch-viewer__bar, .ch-viewer__foot { display: none; }
  .ch-viewer__dock { display: flex; position: absolute; left: 0; right: 0; bottom: 0; height: 64px; align-items: center; padding: 0 16px; background: #2b2b2b; color: #fff; z-index: 3; }
  .ch-viewer__dock .ch-viewer__who { flex: 1 1 0; }
  .ch-viewer__tools { display: flex; align-items: center; gap: 4px; flex: none; }
  .ch-viewer__dock-end { flex: 1 1 0; display: flex; justify-content: flex-end; }
  .ch-viewer__tool { width: 44px; height: 44px; border-radius: 10px; }
  .ch-viewer__div { width: 1px; height: 22px; background: rgba(255, 255, 255, .3); margin: 0 10px; }
  .ch-viewer__close { display: grid; position: absolute; top: 12px; left: 12px; z-index: 3; background: rgba(255, 255, 255, .12); }
  .ch-viewer__strip { display: flex; flex-direction: column; align-items: center; gap: 10px; position: absolute; top: 0; right: 0; bottom: 64px; width: var(--strip); padding: 12px 0; overflow-y: auto; overflow-x: hidden; background: #1b1b1b; z-index: 2; scrollbar-width: none; }
  .ch-viewer__strip::-webkit-scrollbar { display: none; }
  .ch-viewer:not(.has-strip) .ch-viewer__strip { display: none; }
  .ch-viewer__thumb { flex: none; width: 84px; height: 96px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; opacity: .7; padding: 0; background: #000; transition: opacity .15s, border-color .15s; }
  .ch-viewer__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .ch-viewer__thumb:hover { opacity: 1; }
  .ch-viewer__thumb.is-active { opacity: 1; border-color: #fff; }
  .ch-viewer .is-prev, .ch-viewer .is-next { left: auto; right: calc(var(--strip) + 14px); width: 48px; height: 48px; margin-top: 0; background: rgba(0, 0, 0, .75); }
  .ch-viewer .is-prev { top: calc(50% - 58px); } .ch-viewer .is-next { top: calc(50% + 2px); }
  .ch-viewer.is-clean .is-prev, .ch-viewer.is-clean .is-next { opacity: 1; pointer-events: auto; }
  .ch-viewer__backdrop { background: transparent; }
  .ch-viewer__sheet { left: auto; right: 12px; top: auto; bottom: 72px; width: 250px; border-radius: var(--r-md); border: 1px solid var(--border); padding: 6px; animation: kit-pop var(--dur-fast) var(--ease); }
  .ch-viewer__grip { display: none; }
  .ch-viewer__item { padding: 10px 12px; font-size: var(--fs-md); gap: 12px; }
}
.ch-report { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.ch-report__row { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-radius: var(--r-sm); cursor: pointer; }
.ch-report__row:hover { background: var(--hover); }
.ch-report__row input { accent-color: var(--danger); width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .ch-viewer__sheet, .ch-viewer__backdrop { animation: none; } }

@media (max-width: 760px) {
  .ch-msg__main { max-width: 84%; }
  .ch-sticker { font-size: 64px; }
  .ch-list { padding: 0 10px; }
}

/* ===== Chọn chữ & sao chép: chỉ chọn trong một tin nhắn; cảm ứng không bật chọn vùng ===== */
.ch-list, .ch-msg { -webkit-user-select: none; user-select: none; }
.ch-text { -webkit-user-select: text; user-select: text; cursor: text; }
.ch-list:has(.ch-msg.is-sel-target) .ch-msg:not(.is-sel-target) .ch-text { -webkit-user-select: none; user-select: none; }
@media (pointer: coarse) {
  .ch-msg, .ch-text, .ch-bubble { -webkit-user-select: none !important; user-select: none !important; -webkit-touch-callout: none !important; }
  .ch-text { cursor: default; }
}
.ch-msg.is-selected .ch-text { -webkit-user-select: none; user-select: none; }

/* Vuốt phải để trả lời */
.ch-msg__main { transition: transform .18s; will-change: transform; }
.ch-msg.is-swipe-ready .ch-bubble { box-shadow: 0 0 0 2px var(--accent); }

/* Ảnh đại diện bấm để phóng to */
.is-zoomable { cursor: zoom-in; }

/* ===== Bảng cảm xúc + menu khi giữ tin nhắn ===== */
.mp { position: fixed; inset: 0; z-index: 1250; }
.mp__backdrop { position: absolute; inset: 0; background: rgba(8, 10, 20, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity .16s; }
.mp.is-in .mp__backdrop { opacity: 1; }
.mp.is-leaving { opacity: 0; transition: opacity .12s; }
.mp__bar { position: absolute; display: flex; gap: 2px; padding: 5px 6px; border-radius: 30px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-3); transform: scale(.7); transform-origin: bottom center; opacity: 0; transition: transform .2s cubic-bezier(.2,.9,.3,1.3), opacity .14s; }
.mp.is-in .mp__bar { transform: scale(1); opacity: 1; }
.mp__emoji { width: 42px; height: 42px; border-radius: 50%; font-size: 26px; line-height: 1; display: grid; place-items: center; transition: transform .14s; animation: mp-pop .26s cubic-bezier(.2,.9,.3,1.4) both; }
.mp__emoji:hover, .mp__emoji:active { transform: scale(1.3) translateY(-3px); }
.mp__emoji.is-mine { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.mp__emoji--more { font-size: 18px; color: var(--text-2); background: var(--surface-2); }
@keyframes mp-pop { from { transform: scale(0) translateY(10px); } to { transform: none; } }
.mp__clone { position: absolute; margin: 0; overflow: hidden; pointer-events: none; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); max-width: none; }
.mp__menu { position: absolute; min-width: 220px; max-width: min(300px, calc(100vw - 20px)); overflow-y: auto; padding: 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-3); transform: scale(.9); transform-origin: top center; opacity: 0; transition: transform .18s, opacity .14s; }
.mp.is-in .mp__menu { transform: none; opacity: 1; }
.mp__item { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 11px 12px; border-radius: 10px; text-align: left; font-size: var(--fs-md); color: var(--text); }
.mp__item:hover, .mp__item:active { background: var(--hover); }
.mp__item.is-danger { color: var(--danger); }
.mp__item svg { flex: none; color: var(--text-2); }
.mp__item.is-danger svg { color: var(--danger); }
.mp__sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* ===== Danh sách người thả cảm xúc ===== */
.rd__tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.rd__tab { flex: none; padding: 6px 12px; border-radius: var(--r-pill); font-weight: 600; color: var(--text-2); }
.rd__tab.is-on { background: var(--accent-soft); color: var(--accent); }
.rd__list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; padding-top: 6px; }
.rd__row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: var(--r-md); text-align: left; }
.rd__row.is-me:hover { background: var(--hover); }
.rd__name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rd__name small { color: var(--text-3); }
.rd__emoji { font-size: 24px; }

/* ---------- Nhãn dán: biểu tượng + chữ trend, viền trắng như sticker thật ---------- */
.stk { --c1: #8b9bff; --c2: #5b6cff; display: inline-flex; flex-direction: column; align-items: center; gap: 4px; max-width: 100%; user-select: none; -webkit-user-select: none; }
.stk__e { line-height: 1; filter: drop-shadow(2px 0 0 #fff) drop-shadow(-2px 0 0 #fff) drop-shadow(0 2px 0 #fff) drop-shadow(0 -2px 0 #fff) drop-shadow(0 3px 5px rgba(0, 0, 0, .22)); }
.stk__c { font-weight: 800; letter-spacing: .1px; color: #fff; text-align: center; line-height: 1.15; padding: 3px 10px 4px; border-radius: 999px; border: 2px solid #fff; background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 3px 8px rgba(0, 0, 0, .2); text-shadow: 0 1px 1px rgba(0, 0, 0, .25); max-width: 100%; overflow-wrap: anywhere; }
.stk--sm .stk__e { font-size: 44px; } .stk--sm .stk__c { font-size: 11px; }
.stk--md .stk__e { font-size: 64px; } .stk--md .stk__c { font-size: 14px; }
.stk--lg .stk__e { font-size: 88px; } .stk--lg .stk__c { font-size: 17px; padding: 4px 14px 5px; border-width: 3px; }
.ch-sticker { font-size: inherit; line-height: 1; padding: 4px 6px; }
@keyframes stk-bounce { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-7px) scale(1.06); } 60% { transform: translateY(0) scale(.97); } }
@keyframes stk-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes stk-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes stk-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.stk--bounce .stk__e { animation: stk-bounce 1.6s ease-in-out infinite; }
.stk--wiggle .stk__e { animation: stk-wiggle 1.4s ease-in-out infinite; transform-origin: 50% 80%; }
.stk--pulse .stk__e { animation: stk-pulse 1.3s ease-in-out infinite; }
.stk--float .stk__e { animation: stk-float 2.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .stk .stk__e { animation: none !important; } }
@media (max-width: 820px) { .stk--lg .stk__e { font-size: 76px; } .stk--lg .stk__c { font-size: 15px; } }

/* ---------- Nhãn dán vector: kích thước + hoạt ảnh ---------- */
.stk--art { display: inline-block; line-height: 0; }
.stk-svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(2.5px 0 0 #fff) drop-shadow(-2.5px 0 0 #fff) drop-shadow(0 2.5px 0 #fff) drop-shadow(0 -2.5px 0 #fff) drop-shadow(0 4px 6px rgba(40, 30, 70, .22)); }
.stk--art.stk--tab { width: 34px; } .stk--art.stk--tab .stk-svg { filter: none; }
.stk--art.stk--sm { width: 78px; } .stk--art.stk--md { width: 120px; } .stk--art.stk--lg { width: 168px; }
@media (max-width: 820px) { .stk--art.stk--lg { width: 150px; } }
/* Mặc định tâm xoay/co giãn là giữa phần tử; các lớp có trục riêng (thân, tay vẫy, lửa, đập...) dùng toạ độ khung vẽ */
.stk-svg .a-twinkle, .stk-svg .a-pop, .stk-svg .a-blink, .stk-svg .a-drip { transform-box: fill-box; transform-origin: center; }
.stk-svg .a-bob, .stk-svg .a-jump, .stk-svg .a-sway, .stk-svg .a-wave, .stk-svg .a-spin, .stk-svg .a-pulse, .stk-svg .a-flick { transform-box: view-box; }
@keyframes a-bob { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.025, .975); } }
@keyframes a-jump { 0%, 100% { transform: translateY(0) scale(1, 1); } 30% { transform: translateY(-10px) scale(.97, 1.04); } 55% { transform: translateY(0) scale(1.04, .96); } }
@keyframes a-sway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes a-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-2.5px); } 40% { transform: translateX(2.5px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(2px); } }
@keyframes a-wave { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-22deg); } }
@keyframes a-cheer { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes a-twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.6); } }
@keyframes a-rise { 0% { opacity: 0; transform: translateY(8px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes a-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes a-fall { 0% { opacity: 0; transform: translateY(-8px); } 25% { opacity: 1; } 100% { opacity: 0; transform: translateY(22px); } }
@keyframes a-drip { 0% { opacity: 0; transform: translateY(-6px) scale(.7); } 30% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(10px) scale(1); } }
@keyframes a-pop { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.22); } }
@keyframes a-flick { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(.9, 1.12); } }
@keyframes a-spin { to { transform: rotate(360deg); } }
@keyframes a-blink { 0%, 92%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@keyframes a-gush { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes a-blinkbar { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
.stk-svg .a-bob { animation: a-bob 2.4s ease-in-out infinite; }
.stk-svg .a-jump { animation: a-jump 1.3s ease-in-out infinite; }
.stk-svg .a-sway { animation: a-sway 2.6s ease-in-out infinite; }
.stk-svg .a-shake { animation: a-shake .5s linear infinite; }
.stk-svg .a-wave { animation: a-wave 0.9s ease-in-out infinite; transform-box: view-box; }
.stk-svg .a-cheer { animation: a-cheer .8s ease-in-out infinite; }
.stk-svg .a-twinkle { animation: a-twinkle 1.5s ease-in-out infinite; }
.stk-svg .a-rise { animation: a-rise 2.2s ease-out infinite; }
.stk-svg .a-float { animation: a-float 2.4s ease-in-out infinite; }
.stk-svg .a-fall { animation: a-fall 1.8s ease-in infinite; }
.stk-svg .a-drip { animation: a-drip 1.6s ease-in infinite; }
.stk-svg .a-pop { animation: a-pop 1.1s ease-in-out infinite; }
.stk-svg .a-pulse { animation: a-pop 1s ease-in-out infinite; }
.stk-svg .a-flick { animation: a-flick .5s ease-in-out infinite; }
.stk-svg .a-spin { animation: a-spin 4s linear infinite; transform-box: view-box; }
.stk-svg .a-blink { animation: a-blink 4s infinite; }
.stk-svg .a-gush { animation: a-gush .9s ease-in-out infinite; }
.stk-svg .a-blinkbar { animation: a-blinkbar 1s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .stk-svg * { animation: none !important; } }
