/* ============================================================
   AUTOSALES PRO — TƯƠNG TÁC TRÊN MÁY TÍNH (pwa/js/dt-tuong-tac.js)
   ------------------------------------------------------------
   2 cột kiểu Zalo PC trong #dt-view-tt: trái 320px danh sách phòng,
   phải khung chat. Ngôn ngữ thị giác theo mockup điện thoại đã duyệt
   (nền phòng #E4EAF2, bong bóng mình #DBE8FF, bo 16px, huy hiệu
   "Quản trị", chip cảm xúc, trích dẫn thanh xanh trái…).
   Mọi lớp có tiền tố "dtt-" và chỉ tồn tại trong DOM desktop, nên
   không ăn chéo sang giao diện điện thoại (log.md bẫy #9). Riêng
   .dtt-hoi là hộp thoại mở qua KHUNG.moTam (gắn vào <body>).
   ============================================================ */

.dt-view-tt{
  --dtt-nen-chat: #E4EAF2;
  --dtt-bong-toi: #DBE8FF;
  --dtt-bong:     #FFFFFF;
  --dtt-do:       var(--loi, #DC2626);
  --dtt-xanh-la:  var(--tot, #05A65B);
  --dtt-cao: calc(100vh - 66px - 2 * var(--dt-le));
}
@supports (height:100dvh){ .dt-view-tt{ --dtt-cao: calc(100dvh - 66px - 2 * var(--dt-le)); } }
@media (max-width:1180px) and (min-width:1024px){
  .dt-view-tt{ --dtt-cao: calc(100vh - 66px - 28px); }
  @supports (height:100dvh){ .dt-view-tt{ --dtt-cao: calc(100dvh - 66px - 28px); } }
}

/* Badge chưa đọc ở mục sidebar "Tương tác" */
.dt-nav .dt-nav-cham{
  margin-left:auto; min-width:19px; height:19px; padding:0 6px;
  border-radius:var(--dt-bo-pill); background:var(--dtt-do, #DC2626); color:#fff;
  font-size:11px; font-weight:800; line-height:19px; text-align:center;
  font-variant-numeric:tabular-nums;
}

/* ============================================================
   KHUNG 2 CỘT
   ============================================================ */
.dtt{
  display:grid; grid-template-columns:320px minmax(0,1fr);
  height:var(--dtt-cao); min-height:480px; max-width:1560px; margin:0 auto;
  background:var(--dt-mat); border:1px solid var(--dt-vien); border-radius:var(--dt-bo-the);
  overflow:hidden;
}
:where(.dtt) button{ font-family:inherit; color:inherit; background:none; border:0; }
.dtt-nut-ic{
  width:34px; height:34px; border-radius:8px; flex:none;
  display:grid; place-items:center; color:var(--dt-muc-2);
}
.dtt-nut-ic:hover{ background:var(--dt-nen); color:var(--dt-muc); }
.dtt :focus-visible{ outline:2px solid var(--dt-xanh); outline-offset:2px; }

/* ---------- Cột trái ---------- */
.dtt-trai{ position:relative; display:flex; flex-direction:column; min-height:0; border-right:1px solid var(--dt-vien); background:var(--dt-mat); }
.dtt-trai-dau{ flex:none; padding:16px 16px 10px; }
.dtt-trai-hang{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.dtt-trai-dau h2{ font-size:18px; font-weight:800; letter-spacing:-.01em; }
.dtt-tim{
  display:flex; align-items:center; gap:8px; height:38px; padding:0 12px;
  background:var(--dt-nen); border:1px solid var(--dt-vien); border-radius:var(--dt-bo-o);
  color:#9AA6B8; cursor:text;
}
.dtt-tim:focus-within{ border-color:var(--dt-xanh); background:var(--dt-mat); }
.dtt-tim svg{ flex:none; }
.dtt-tim input{ flex:1; min-width:0; border:0; background:transparent; font-family:inherit; font-size:13.5px; color:var(--dt-muc); }
.dtt-tim input:focus{ outline:0; }
.dtt-tim input::placeholder{ color:#9AA6B8; }
.dtt-tim input:disabled{ cursor:not-allowed; }
.dtt-tim input::-webkit-search-cancel-button{ cursor:pointer; }
.dtt-tim-dem{ flex:none; font-size:11.5px; font-weight:700; color:var(--dt-muc-2); font-variant-numeric:tabular-nums; }

.dtt-ds-phong{ flex:1; min-height:0; overflow-y:auto; padding:0 10px 16px; }
.dtt-nhan-muc{ font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--dt-muc-2); padding:14px 8px 6px; }
.dtt-ds-ghi{ font-size:12.5px; color:var(--dt-muc-2); padding:4px 8px; }
.dtt-ds-loi{ font-size:12.5px; color:var(--dt-muc-2); padding:12px 8px; display:flex; flex-direction:column; align-items:flex-start; gap:8px; }
.dtt-ds-loi button{ color:var(--dt-xanh); font-weight:700; cursor:pointer; padding:0; }
.dtt-phong-khung{ display:flex; flex-direction:column; gap:2px; }
.dtt-phong-muc{
  display:flex; align-items:center; gap:11px; width:100%; text-align:left;
  padding:10px 10px; border-radius:10px; cursor:pointer; position:relative;
  transition:background .12s;
}
button.dtt-phong-muc:hover{ background:var(--dt-nen); }
.dtt-phong-muc.dtt-chon{ background:var(--dt-nhan-nhat); }
.dtt-phong-muc.dtt-sap{ opacity:.55; cursor:default; }
.dtt-av-phong{
  width:46px; height:46px; border-radius:50%; flex:none;
  display:grid; place-items:center; color:#fff; font-weight:800; font-size:15px;
  background:linear-gradient(135deg,#3b82f6,#1d4ed8);
}
.dtt-av-phong.dtt-xam{ background:linear-gradient(135deg,#cbd2dc,#a3adbb); }
.dtt-phong-chu{ flex:1; min-width:0; }
.dtt-phong-chu b{ display:flex; align-items:center; gap:6px; font-size:14px; font-weight:700; min-width:0; }
.dtt-phong-ten{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dtt-phong-chu p{ font-size:12.5px; color:var(--dt-muc-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.dtt-phong-chu p.dtt-dam{ color:var(--dt-muc); font-weight:600; }
.dtt-phong-phai{ flex:none; display:flex; flex-direction:column; align-items:flex-end; gap:5px; align-self:flex-start; padding-top:3px; }
.dtt-phong-phai small{ font-size:11.5px; color:var(--dt-muc-2); }
.dtt-dem-do{
  min-width:19px; height:19px; padding:0 6px; border-radius:99px;
  background:var(--dtt-do); color:#fff; font-size:11px; font-weight:800; line-height:19px; text-align:center;
}
.dtt-phong-xuong{ height:66px; border-radius:10px; margin:2px 0; background:linear-gradient(90deg,var(--dt-nen) 25%,#EDF1F6 50%,var(--dt-nen) 75%); background-size:200% 100%; animation:dtt-anh 1.3s linear infinite; }
@keyframes dtt-anh{ to{ background-position:-200% 0; } }

/* ---------- Cột phải ---------- */
.dtt-phai{ position:relative; display:flex; flex-direction:column; min-width:0; min-height:0; background:var(--dtt-nen-chat); }
.dtt-phong{ flex:1; display:flex; flex-direction:column; min-height:0; }

/* Trạng thái thay thế (đang tải / rỗng / khoá / lỗi) */
.dtt-trong{ flex:1; display:grid; place-items:center; padding:24px; }
.dtt-trong-hop{ max-width:360px; text-align:center; display:flex; flex-direction:column; align-items:center; gap:8px; color:var(--dt-muc-2); font-size:13.5px; line-height:1.5; }
.dtt-trong-hop b{ color:var(--dt-muc); font-size:15.5px; font-weight:700; }
.dtt-trong-ic{ width:64px; height:64px; border-radius:50%; background:var(--dt-mat); color:var(--dt-xanh); display:grid; place-items:center; margin-bottom:4px; }
.dtt-trong-ic svg{ width:30px; height:30px; }
.dtt-nut-thu{ margin-top:6px; height:36px; padding:0 18px; border-radius:var(--dt-bo-o); background:var(--dt-xanh); color:#fff; font-weight:700; font-size:13.5px; cursor:pointer; }
.dtt-xoay{ width:16px; height:16px; border-radius:50%; border:2px solid rgba(20,102,195,.2); border-top-color:var(--dt-xanh); animation:dtt-quay .8s linear infinite; flex:none; }
.dtt-xoay-to{ width:30px; height:30px; border-width:3px; margin-bottom:6px; }
@keyframes dtt-quay{ to{ transform:rotate(360deg); } }

/* Đầu phòng */
.dtt-dau{ flex:none; height:62px; display:flex; align-items:center; gap:12px; padding:0 18px; background:var(--dt-mat); border-bottom:1px solid var(--dt-vien); }
.dtt-dau .dtt-av-phong{ width:40px; height:40px; font-size:14px; }
.dtt-dau-chu{ flex:1; min-width:0; line-height:1.3; }
.dtt-dau-chu b{ display:block; font-size:15.5px; font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.dtt-dau-chu > span{ display:flex; align-items:center; gap:5px; font-size:12px; color:var(--dt-muc-2); }
.dtt-cham{ width:7px; height:7px; border-radius:50%; flex:none; }
.dtt-cham-xanh{ background:var(--dtt-xanh-la); }
.dtt-cham-vang{ background:#F59E0B; }
.dtt-cham-do{ background:var(--dtt-do); }

/* Thanh ghim */
.dtt-ghim{ flex:none; display:flex; align-items:center; gap:4px; padding:0 10px 0 0; background:var(--dt-mat); border-bottom:1px solid var(--dt-vien); }
.dtt-ghim-noi{ flex:1; min-width:0; display:flex; align-items:center; gap:10px; padding:8px 8px 8px 18px; text-align:left; cursor:pointer; }
.dtt-ghim-noi:hover .dtt-ghim-chu span{ color:var(--dt-xanh); }
.dtt-ghim-ic{ color:var(--dt-xanh); display:grid; place-items:center; flex:none; }
.dtt-ghim-chu{ flex:1; min-width:0; font-size:13px; }
.dtt-ghim-chu small{ display:block; font-size:11px; color:var(--dt-muc-2); }
.dtt-ghim-chu span{ display:block; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
/* "+n ⌄" — có hơn 1 tin ghim (§5f) */
.dtt-ghim-them{
  flex:none; display:inline-flex; align-items:center; gap:3px; height:36px; padding:0 8px 0 10px;
  border-radius:8px; color:var(--dt-xanh); cursor:pointer;
}
.dtt-ghim-them:hover{ background:var(--dt-nen); }
.dtt-ghim-them b{
  font-size:12px; font-weight:800; background:var(--dt-nhan-nhat); color:var(--dt-xanh);
  border-radius:var(--dt-bo-pill); padding:2px 8px; line-height:1.35;
}
.dtt-ghim-them svg{ transition:transform .28s cubic-bezier(.32,.72,0,1); }
.dtt-ghim-them.dtt-mo svg{ transform:rotate(180deg); }

/* Danh sách tất cả tin ghim — xổ xuống phủ trên khung chat */
.dtt-gds-phu{
  position:absolute; inset:0; z-index:8; background:rgba(11,23,54,.18);
  opacity:0; pointer-events:none; transition:opacity .28s cubic-bezier(.32,.72,0,1);
}
.dtt-gds-phu.dtt-mo{ opacity:1; pointer-events:auto; }
.dtt-gds{
  position:absolute; left:0; right:0; top:0; z-index:9;
  display:flex; flex-direction:column; max-height:min(72%, 460px);
  background:var(--dt-mat); border-bottom:1px solid var(--dt-vien); border-radius:0 0 14px 14px;
  box-shadow:0 18px 40px -18px rgba(11,23,54,.35);
  clip-path:inset(0 0 100% 0 round 0 0 14px 14px); opacity:0; visibility:hidden; transform:translateY(-8px);
  transition:clip-path .28s cubic-bezier(.32,.72,0,1), transform .28s cubic-bezier(.32,.72,0,1),
    opacity .16s linear, visibility 0s linear .28s;
}
.dtt-gds.dtt-mo{
  clip-path:inset(0 0 0 0 round 0 0 14px 14px); opacity:1; visibility:visible; transform:none;
  transition:clip-path .28s cubic-bezier(.32,.72,0,1), transform .28s cubic-bezier(.32,.72,0,1), opacity .16s linear, visibility 0s;
}
.dtt-gds-dau{ flex:none; display:flex; align-items:center; gap:8px; padding:8px 10px 4px 18px; }
.dtt-gds-dau b{ font-size:13px; font-weight:700; }
.dtt-gds-dau span{ flex:1; font-size:12px; color:var(--dt-muc-2); font-variant-numeric:tabular-nums; }
.dtt-gds-ds{ flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:0 10px 10px; }
.dtt-gds-dong{ display:flex; align-items:center; gap:4px; }
.dtt-gds-dong + .dtt-gds-dong{ box-shadow:inset 0 1px 0 var(--dt-vien); }
.dtt-gds-dong:hover{ background:var(--dt-nen); }
.dtt-gds-noi{
  flex:1; min-width:0; display:flex; align-items:flex-start; gap:10px; min-height:52px; padding:9px 8px;
  text-align:left; cursor:pointer; border-radius:10px;
}
.dtt-gds-noi .dtt-av{ width:30px; height:30px; font-size:12px; flex:none; visibility:visible; }
.dtt-gds-chu{ flex:1; min-width:0; }
.dtt-gds-hang{ display:flex; align-items:baseline; gap:8px; }
.dtt-gds-hang b{ flex:1; min-width:0; font-size:13px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.dtt-gds-hang time{ flex:none; font-size:11px; color:#8792A4; }
.dtt-gds-nd{
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden;
  font-size:13px; line-height:1.4; color:var(--dt-muc-2); margin-top:2px; overflow-wrap:break-word; overflow-wrap:anywhere;
}
.dtt-gds-noi:hover .dtt-gds-nd{ color:var(--dt-muc); }
.dtt-gds-bo{
  flex:none; height:34px; padding:0 10px; margin-right:4px; border-radius:8px;
  font-size:12.5px; font-weight:600; color:var(--dtt-do); cursor:pointer;
}
.dtt-gds-bo:hover{ background:var(--loi-nhat, #FDECEC); }
/* dấu ghim nhỏ cạnh giờ trên bong bóng */
.dtt-dau-ghim{ flex:none; color:var(--dt-xanh); transform:rotate(35deg); }
@media (prefers-reduced-motion:reduce){
  .dtt-gds, .dtt-gds.dtt-mo, .dtt-gds-phu, .dtt-ghim-them svg{ transition:none; }
}

/* Vùng tin */
.dtt-khung{ flex:1; min-height:0; position:relative; display:flex; flex-direction:column; }
.dtt-cuon{ flex:1; min-height:0; overflow-y:auto; position:relative; padding:12px 22px 10px; overscroll-behavior:contain; overflow-anchor:none; outline:0; }
.dtt-ds-tin{ display:flex; flex-direction:column; }
.dtt-mat-ket-noi{ position:absolute; left:0; right:0; top:0; z-index:3; background:var(--canh-nhat, #FBEFD9); color:var(--canh, #B26A00); font-size:12.5px; font-weight:600; padding:7px 18px; text-align:center; }
.dtt-tai-cu{ position:absolute; top:10px; left:50%; transform:translateX(-50%); z-index:3; display:flex; align-items:center; gap:8px; background:var(--dt-mat); border-radius:99px; padding:6px 14px; font-size:12px; font-weight:600; color:var(--dt-muc-2); box-shadow:0 2px 8px rgba(11,23,54,.12); }
.dtt-dau-cuoc{ text-align:center; font-size:11.5px; color:var(--dt-muc-2); padding:6px 0 10px; }
.dtt-rong-tin{ display:flex; flex-direction:column; align-items:center; gap:6px; text-align:center; color:var(--dt-muc-2); font-size:13px; padding:12vh 20px 0; }
.dtt-rong-tin svg{ color:var(--dt-xanh); opacity:.7; margin-bottom:4px; }
.dtt-rong-tin b{ color:var(--dt-muc); font-size:15px; }

.dtt-ngay{ display:flex; justify-content:center; margin:14px 0 8px; }
.dtt-ngay span{ background:rgba(16,19,25,.18); color:#fff; font-size:11.5px; font-weight:600; border-radius:99px; padding:3px 11px; }
.dtt-he-thong{ text-align:center; font-size:12px; color:var(--dt-muc-2); margin:8px 60px; }

/* Một dòng tin */
.dtt-dong{ display:flex; align-items:flex-end; gap:8px; margin-top:3px; border-radius:10px; }
.dtt-dong.dtt-dau-nhom{ margin-top:10px; }
.dtt-dong.dtt-toi{ flex-direction:row-reverse; }
.dtt-av{ width:32px; height:32px; border-radius:50%; flex:none; display:grid; place-items:center; color:#fff; font-weight:700; font-size:13px; visibility:hidden; -webkit-user-select:none; user-select:none; }
.dtt-dong.dtt-cuoi-nhom .dtt-av{ visibility:visible; }
.dtt-cot{ display:flex; flex-direction:column; align-items:flex-start; min-width:0; max-width:62%; }
.dtt-toi .dtt-cot{ align-items:flex-end; }
.dtt-ten{ font-size:12px; color:var(--dt-muc-2); margin:0 0 3px 10px; }
.dtt-ten b{ color:var(--dt-muc); font-weight:700; }
.dtt-huy-qt{ font-size:10px; font-weight:800; color:#fff; background:#2563EB; border-radius:99px; padding:1px 7px; margin-left:5px; vertical-align:1px; }
.dtt-bong-hang{ display:flex; align-items:center; gap:6px; max-width:100%; }
.dtt-toi .dtt-bong-hang{ flex-direction:row-reverse; }

.dtt-bong{
  position:relative; min-width:0; max-width:100%;
  background:var(--dtt-bong); border-radius:16px; padding:8px 12px 6px;
  font-size:14px; line-height:1.45; color:var(--dt-muc);
  box-shadow:0 1px 1px rgba(16,19,25,.06);
  overflow-wrap:break-word; overflow-wrap:anywhere;
}
.dtt-toi .dtt-bong{ background:var(--dtt-bong-toi); }
.dtt-bong.dtt-qt{ border:1.5px solid #bcd0ff; }
.dtt-bong.dtt-co-cx{ margin-bottom:12px; }
.dtt-bong.dtt-dang{ opacity:.6; }
.dtt-bong.dtt-loi{ box-shadow:0 0 0 1.5px rgba(220,38,38,.45); }
.dtt-chu{ white-space:pre-wrap; }
.dtt-chu a{ color:var(--dt-xanh); text-decoration:underline; text-underline-offset:2px; }
.dtt-chu-thu-hoi{ font-style:italic; color:#98A0AD; }
.dtt-gio{ display:flex; align-items:center; gap:3px; font-size:10.5px; color:#8792A4; margin-top:2px; }
.dtt-toi .dtt-gio{ justify-content:flex-end; }

.dtt-trich{
  display:block; width:100%; text-align:left; cursor:pointer;
  border-left:3px solid #2563EB; background:rgba(37,99,235,.07);
  border-radius:6px; padding:4px 8px; margin-bottom:5px; font-size:12.5px; color:var(--dt-muc-2);
}
.dtt-trich:hover{ background:rgba(37,99,235,.12); }
.dtt-trich b{ display:block; color:#1B45B8; font-size:12px; }
.dtt-trich span{ display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.dtt-cx{
  position:absolute; right:8px; bottom:-12px; display:flex; align-items:center; gap:1px;
  background:#fff; border-radius:99px; padding:1px 7px 1px 5px; font-size:12px; line-height:18px;
  box-shadow:0 1px 3px rgba(16,19,25,.18); cursor:pointer;
}
.dtt-cx em{ font-style:normal; font-size:11px; color:var(--dt-muc-2); margin-left:3px; font-variant-numeric:tabular-nums; }
.dtt-cx.dtt-cx-toi{ box-shadow:0 0 0 1.5px #93b4ff, 0 1px 3px rgba(16,19,25,.18); }
.dtt-cx.dtt-cx-toi em{ color:#1B45B8; font-weight:700; }

.dtt-loi-gui{ font-size:12px; color:var(--dtt-do); margin:3px 4px 0; }
.dtt-loi-gui button{ color:var(--dtt-do); font-weight:700; text-decoration:underline; cursor:pointer; padding:0; font-size:12px; }

/* Hàng nút nổi khi rê chuột (cảm xúc nhanh · trả lời · …) */
.dtt-hd{ flex:none; display:flex; align-items:center; gap:2px; opacity:0; pointer-events:none; transition:opacity .12s; }
.dtt-dong:hover .dtt-hd, .dtt-dong:focus-within .dtt-hd, .dtt-dong.dtt-dang-menu .dtt-hd{ opacity:1; pointer-events:auto; }
.dtt-hd-nut{ width:28px; height:28px; border-radius:50%; display:grid; place-items:center; color:var(--dt-muc-2); background:rgba(255,255,255,.85); font-size:14px; cursor:pointer; box-shadow:0 1px 2px rgba(16,19,25,.1); }
.dtt-hd-nut:hover{ background:#fff; color:var(--dt-xanh); }
.dtt-hd-cx{ position:relative; display:flex; }
.dtt-hd-bang{
  position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%) translateY(4px);
  display:flex; gap:2px; background:#fff; border-radius:99px; padding:4px 6px;
  box-shadow:0 6px 20px -6px rgba(16,19,25,.35); opacity:0; pointer-events:none;
  transition:opacity .14s, transform .14s; z-index:4; white-space:nowrap;
}
/* cầu nối vô hình để di chuột từ nút lên bảng không bị mất hover */
.dtt-hd-bang::after{ content:""; position:absolute; left:0; right:0; top:100%; height:8px; }
.dtt-hd-cx:hover .dtt-hd-bang{ opacity:1; pointer-events:auto; transform:translateX(-50%); }
.dtt-hd-bang button{ width:32px; height:32px; border-radius:50%; font-size:20px; line-height:1; cursor:pointer; transition:transform .12s; }
.dtt-hd-bang button:hover{ transform:scale(1.22); background:var(--dt-nen); }
.dtt-hd-bang button.dtt-chon{ background:var(--dt-nhan-nhat); }

/* Nhấp nháy khi nhảy tới tin (ghim / trích dẫn) + kết quả tìm */
.dtt-dong.dtt-nhay .dtt-bong{ animation:dtt-nhay 1.5s ease; }
@keyframes dtt-nhay{ 0%,40%{ box-shadow:0 0 0 3px rgba(37,99,235,.45); } 100%{ box-shadow:0 1px 1px rgba(16,19,25,.06); } }
.dtt-dong.dtt-khop .dtt-bong{ box-shadow:0 0 0 2px rgba(245,158,11,.45); }
.dtt-dong.dtt-khop-dang .dtt-bong{ box-shadow:0 0 0 2.5px #F59E0B; }

/* Tin mới vào */
.dtt-dong.dtt-vao{ animation:dtt-vao .26s cubic-bezier(.32,.72,0,1); }
@keyframes dtt-vao{ from{ opacity:0; transform:translateY(8px) scale(.98); } }

/* Đã xem */
.dtt-da-xem{ display:flex; align-items:center; gap:2px; margin:4px 0 0 40px; }
.dtt-da-xem.dtt-phai{ justify-content:flex-end; margin:4px 2px 0 0; }
.dtt-da-xem i{ width:16px; height:16px; border-radius:50%; font-style:normal; font-size:8.5px; font-weight:800; color:#fff; display:grid; place-items:center; border:1.5px solid var(--dtt-nen-chat); }
.dtt-da-xem span{ font-size:11px; color:var(--dt-muc-2); margin-left:4px; }

/* Đang soạn */
.dtt-dang-soan{ display:flex; align-items:center; gap:8px; margin:8px 0 2px 40px; font-size:12px; color:var(--dt-muc-2); }
.dtt-cham3{ display:flex; gap:3px; background:#fff; border-radius:99px; padding:7px 10px; }
.dtt-cham3 i{ width:6px; height:6px; border-radius:50%; background:#98A0AD; animation:dtt-nhun 1.2s infinite; }
.dtt-cham3 i:nth-child(2){ animation-delay:.15s; }
.dtt-cham3 i:nth-child(3){ animation-delay:.3s; }
@keyframes dtt-nhun{ 0%,60%,100%{ transform:none; opacity:.5; } 30%{ transform:translateY(-4px); opacity:1; } }

/* Nút "↓ n tin mới" */
.dtt-xuong{
  position:absolute; right:22px; bottom:14px; z-index:3;
  height:34px; padding:0 14px; border-radius:99px;
  background:var(--dt-xanh); color:#fff; font-size:12.5px; font-weight:700; cursor:pointer;
  box-shadow:0 6px 16px -6px rgba(20,102,195,.6);
}

/* Trả lời (trên ô soạn) */
.dtt-tra-loi{ flex:none; display:flex; align-items:center; gap:10px; background:var(--dt-mat); border-top:1px solid var(--dt-vien); padding:8px 12px 8px 18px; }
.dtt-tra-loi-chu{ flex:1; min-width:0; border-left:3px solid #2563EB; padding-left:9px; font-size:12.5px; color:var(--dt-muc-2); }
.dtt-tra-loi-chu b{ display:block; color:#1B45B8; font-size:12px; }
.dtt-tra-loi-chu p{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Ô soạn */
.dtt-soan{ flex:none; position:relative; display:flex; align-items:flex-end; gap:6px; background:var(--dt-mat); border-top:1px solid var(--dt-vien); padding:10px 12px; }
.dtt-soan textarea{
  flex:1; min-width:0; resize:none; border:1px solid var(--dt-vien); border-radius:var(--dt-bo-o);
  background:var(--dt-nen); font-family:inherit; font-size:14px; line-height:21px; color:var(--dt-muc);
  padding:6px 12px; height:35px; max-height:calc(21px * 5 + 14px); overflow-y:hidden;
}
.dtt-soan textarea:focus{ outline:0; border-color:var(--dt-xanh); background:var(--dt-mat); }
.dtt-soan textarea::placeholder{ color:#9AA6B8; }
.dtt-soan .dtt-nut-ic{ height:35px; width:35px; }
.dtt-dem-chu{ position:absolute; right:60px; top:-20px; font-size:11px; color:var(--dt-muc-2); background:var(--dt-mat); border-radius:6px; padding:1px 6px; }
.dtt-nut-gui{ width:35px; height:35px; border-radius:50%; flex:none; display:grid; place-items:center; color:#98A0AD; transition:background .15s, color .15s; }
.dtt-nut-gui.dtt-bat{ background:var(--dt-xanh); color:#fff; cursor:pointer; }
.dtt-nut-gui:disabled{ cursor:default; }
.dtt-bang-emoji{
  position:absolute; left:10px; bottom:calc(100% + 6px); z-index:5;
  display:grid; grid-template-columns:repeat(8,34px); gap:2px; padding:8px;
  background:var(--dt-mat); border:1px solid var(--dt-vien); border-radius:12px;
  box-shadow:0 12px 32px -12px rgba(11,23,54,.3);
}
.dtt-bang-emoji button{ width:34px; height:34px; border-radius:8px; font-size:20px; line-height:1; cursor:pointer; }
.dtt-bang-emoji button:hover{ background:var(--dt-nen); }

.dtt-bi-cam{ flex:none; display:flex; align-items:center; justify-content:center; gap:8px; background:var(--dt-mat); border-top:1px solid var(--dt-vien); padding:16px; font-size:13.5px; font-weight:600; color:var(--dt-muc-2); }

/* Menu tin (chuột phải / "…") */
.dtt-menu{
  position:fixed; z-index:60; min-width:200px; padding:6px;
  background:var(--dt-mat); border:1px solid var(--dt-vien); border-radius:12px;
  box-shadow:0 16px 40px -14px rgba(11,23,54,.35);
}
.dtt-menu > button{
  display:flex; align-items:center; gap:10px; width:100%; height:36px; padding:0 10px;
  border-radius:8px; font-size:13.5px; font-weight:500; text-align:left; cursor:pointer; color:var(--dt-muc);
}
.dtt-menu > button svg{ color:var(--dt-xanh); flex:none; }
.dtt-menu > button:hover{ background:var(--dt-nen); outline:0; }
.dtt-menu > button:focus-visible{ background:var(--dt-nen); outline:0; }   /* tách riêng: Safari < 15.4 bỏ cả luật nếu chung danh sách với :focus-visible */
.dtt-menu > button.dtt-do, .dtt-menu > button.dtt-do svg{ color:var(--dtt-do); }
.dtt-menu-cx{ display:flex; justify-content:space-between; gap:2px; padding:2px 2px 6px; margin-bottom:4px; border-bottom:1px solid var(--dt-vien); }
.dtt-menu-cx button{ width:32px; height:32px; border-radius:50%; font-size:20px; line-height:1; cursor:pointer; transition:transform .12s; }
.dtt-menu-cx button:hover{ transform:scale(1.2); background:var(--dt-nen); outline:0; }
.dtt-menu-cx button:focus-visible{ transform:scale(1.2); background:var(--dt-nen); outline:0; }
.dtt-menu-cx button.dtt-chon{ background:var(--dt-nhan-nhat); }

/* Hộp xác nhận thu hồi (KHUNG.moTam, nằm ngoài #app-desktop) */
.dtt-hoi{ padding:0 22px; font-size:14px; line-height:1.5; color:var(--dt-muc, #0B1736); text-align:center; }
.dtt-hoi blockquote{ margin:10px 0 0; padding:8px 12px; border-radius:10px; background:#F6F9FC; color:#61708A; font-size:13px; text-align:left; overflow-wrap:break-word; overflow-wrap:anywhere; }
.dtt-hoi-nut{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:16px; }
.dtt-hoi-nut .nut{ height:44px; font-size:14px; }
.dtt-hoi .dtt-nut-do{ background:var(--loi, #DC2626); }

/* Màn thấp/hẹp trong dải desktop */
@media (max-width:1180px) and (min-width:1024px){
  .dtt{ grid-template-columns:280px minmax(0,1fr); }
  .dtt-cuon{ padding:10px 14px; }
  .dtt-cot{ max-width:70%; }
}

@media (prefers-reduced-motion:reduce){
  .dtt-dong.dtt-vao, .dtt-dong.dtt-nhay .dtt-bong, .dtt-phong-xuong{ animation:none; }
  .dtt-cham3 i{ animation:none; opacity:.7; }
  .dtt-xoay{ animation-duration:2.4s; }
  .dtt-hd, .dtt-hd-bang, .dtt-hd-bang button, .dtt-menu-cx button, .dtt-nut-gui, .dtt-phong-muc{ transition:none; }
  .dtt-hd-bang button:hover, .dtt-menu-cx button:hover{ transform:none; }
}
/* đếm vượt giới hạn */
.dtt-dem-chu.dtt-qua{ color:var(--dtt-do); font-weight:700; }
/* Tin gõ lúc mất kết nối, chờ có mạng lại để lõi tự gửi */
.dtt-cho-mang{ display:inline-flex; align-items:center; gap:3px; font-style:normal; font-weight:600; color:var(--canh, #B26A00); }

/* ============================================================
   THÔNG BÁO KHI APP ĐANG MỞ (§5b + §5c)
   ============================================================ */
/* Chuông gạch: phòng đang tắt thông báo (cột trái + đầu phòng) */
.dtt-chuong-tat{ display:inline-grid; place-items:center; flex:none; color:#98A0AD; }
.dtt-dau-chu b{ display:flex; align-items:center; gap:6px; min-width:0; }
#dtt-dau-ten{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.dtt-dem-do.dtt-dem-xam{ background:#AEB6C2; }

/* Bảng cài đặt thông báo (nút chuông đầu cột trái) */
.dtt-cai-dat{
  position:absolute; left:12px; right:12px; top:56px; z-index:20;
  background:var(--dt-mat); border:1px solid var(--dt-vien); border-radius:12px;
  box-shadow:0 16px 40px -14px rgba(11,23,54,.35); padding:6px 14px 14px;
}
.dtt-cd-dau{ display:flex; align-items:center; justify-content:space-between; padding:4px 0 6px; border-bottom:1px solid var(--dt-vien); margin-bottom:4px; }
.dtt-cd-dau b{ font-size:14px; font-weight:800; }
.dtt-cd-dong{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:9px 0; cursor:pointer; }
.dtt-cd-dong b{ display:block; font-size:13.5px; font-weight:600; }
.dtt-cd-dong small{ display:block; font-size:11.5px; color:var(--dt-muc-2); margin-top:1px; }
.dtt-cd-dong.dtt-cd-mo{ opacity:.5; cursor:default; }
.dtt-cong-tac{
  -webkit-appearance:none; appearance:none; flex:none; margin:0;
  width:36px; height:21px; border-radius:99px; background:#CBD2DC; position:relative; cursor:pointer;
  transition:background .15s;
}
.dtt-cong-tac::after{
  content:""; position:absolute; top:2px; left:2px; width:17px; height:17px; border-radius:50%;
  background:#fff; box-shadow:0 1px 2px rgba(16,19,25,.25); transition:transform .15s;
}
.dtt-cong-tac:checked{ background:var(--dt-xanh); }
.dtt-cong-tac:checked::after{ transform:translateX(15px); }
.dtt-cong-tac:disabled{ cursor:default; }
.dtt-cong-tac:focus-visible{ outline:2px solid var(--dt-xanh); outline-offset:2px; }
.dtt-cd-may{ border-top:1px solid var(--dt-vien); margin-top:4px; padding-top:10px; }
.dtt-cd-nut{ width:100%; height:36px; border-radius:var(--dt-bo-o); background:var(--dt-nhan-nhat); color:var(--dt-xanh); font-weight:700; font-size:13px; cursor:pointer; }
.dtt-cd-nut:hover{ background:#DCEBFF; }
.dtt-cd-ghi{ font-size:11.5px; line-height:1.45; color:var(--dt-muc-2); margin-top:6px; }
.dtt-cd-ok{ font-size:13px; font-weight:600; color:var(--tot, #05A65B); margin-bottom:8px; }
/* Thông báo đẩy khi đóng trang (§5d) */
.dtt-cd-push-dau{ margin-bottom:8px; }
.dtt-cd-push-dau b{ display:block; font-size:13.5px; font-weight:600; }
.dtt-cd-push-dau small{ display:block; font-size:11.5px; line-height:1.45; color:var(--dt-muc-2); margin-top:1px; }
.dtt-cd-nut.dtt-cd-nut-phu{ background:var(--dt-nen); color:var(--dt-muc); border:1px solid var(--dt-vien); }
.dtt-cd-nut:disabled{ opacity:.6; cursor:default; }
.dtt-cd-canh{ font-size:12px; line-height:1.5; color:var(--canh, #B26A00); background:var(--canh-nhat, #FBEFD9); border-radius:8px; padding:8px 10px; }
.dtt-cd-chan-doan{ margin-top:10px; max-height:200px; overflow:auto; font:11px/1.45 ui-monospace, Menlo, monospace; background:var(--dt-nen); border:1px solid var(--dt-vien); border-radius:8px; padding:8px; white-space:pre-wrap; overflow-wrap:break-word; overflow-wrap:anywhere; -webkit-user-select:text; user-select:text; }
.dtt-cd-ghi .dtt-xoay{ display:inline-block; width:12px; height:12px; vertical-align:-2px; margin-right:4px; }

/* Menu đầu phòng: dòng ghi chú không bấm được */
.dtt-menu-ghi{ display:flex; align-items:center; gap:6px; padding:6px 10px 8px; font-size:12px; font-weight:600; color:var(--dt-muc-2); border-bottom:1px solid var(--dt-vien); margin-bottom:4px; }

/* Thẻ thông báo góc dưới phải (kiểu Zalo PC) */
.dtt-tb{
  position:fixed; right:20px; bottom:88px; z-index:80; width:340px;   /* nằm trên ô soạn, không che nút Gửi */
  display:flex; align-items:flex-start;
  background:var(--dt-mat); border:1px solid var(--dt-vien); border-radius:12px;
  box-shadow:0 18px 44px -16px rgba(11,23,54,.42);
  opacity:0; transform:translateY(12px); transition:opacity .2s, transform .22s cubic-bezier(.32,.72,0,1);
}
.dtt-tb.dtt-tb-hien{ opacity:1; transform:none; }
.dtt-tb.dtt-tb-nay{ animation:dtt-tb-nay .3s ease; }
@keyframes dtt-tb-nay{ 40%{ transform:translateY(-3px); } }
.dtt-tb button{ font-family:inherit; color:inherit; background:none; border:0; cursor:pointer; }
.dtt-tb-noi{ flex:1; min-width:0; display:flex; gap:11px; padding:12px 4px 12px 14px; text-align:left; border-radius:12px 0 0 12px; }
.dtt-tb-noi:hover .dtt-tb-dau b{ color:var(--dt-xanh); }
.dtt-tb-av{ width:38px; height:38px; border-radius:50%; flex:none; display:grid; place-items:center; color:#fff; font-weight:700; font-size:14px; }
.dtt-tb-chu{ flex:1; min-width:0; }
.dtt-tb-dau{ display:flex; align-items:baseline; gap:6px; min-width:0; }
.dtt-tb-dau b{ font-size:13px; font-weight:700; color:var(--dt-muc); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.dtt-tb-them{ flex:none; font-style:normal; font-size:11px; font-weight:700; color:var(--dt-xanh); background:var(--dt-nhan-nhat); border-radius:99px; padding:1px 7px; }
.dtt-tb-noi-dung{
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  font-size:13px; line-height:1.4; color:var(--dt-muc-2); margin-top:2px; overflow-wrap:break-word; overflow-wrap:anywhere;
}
.dtt-tb-dong{ flex:none; width:30px; height:30px; margin:6px 6px 0 0; border-radius:8px; display:grid; place-items:center; color:var(--dt-muc-2); }
.dtt-tb-dong:hover{ background:var(--dt-nen); color:var(--dt-muc); }
.dtt-tb :focus-visible{ outline:2px solid var(--dt-xanh); outline-offset:-2px; }

@media (prefers-reduced-motion:reduce){
  .dtt-tb{ transition:none; transform:none; }
  .dtt-tb.dtt-tb-nay{ animation:none; }
  .dtt-cong-tac, .dtt-cong-tac::after{ transition:none; }
}

/* ============================================================
   THÀNH VIÊN PHÒNG (§5e) — drawer bên phải trong khung chat
   ============================================================ */
.dtt-dau-chu{ cursor:pointer; border-radius:8px; }
.dtt-dau-chu:hover #dtt-dau-ten{ color:var(--dt-xanh); }
.dtt-nut-ic.dtt-bat{ background:var(--dt-nhan-nhat); color:var(--dt-xanh); }
/* Drawer mở thì khung chat (trừ đầu phòng) chừa 300px bên phải — ô soạn/nút Gửi không bị che */
.dtt-co-tv .dtt-phong > :not(.dtt-dau){ margin-right:300px; }
.dtt-tv{
  position:absolute; top:62px; right:0; bottom:0; z-index:10; width:300px;
  display:flex; flex-direction:column;
  background:var(--dt-mat); border-left:1px solid var(--dt-vien);
  animation:dtt-tv-vao .22s cubic-bezier(.32,.72,0,1);
}
@keyframes dtt-tv-vao{ from{ transform:translateX(24px); opacity:0; } }
.dtt-tv-dau{ flex:none; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:12px 10px 8px 16px; }
.dtt-tv-dau b{ display:block; font-size:15px; font-weight:800; }
.dtt-tv-dau span{ display:block; font-size:12px; color:var(--dt-muc-2); margin-top:1px; }
.dtt-tv-tim{ flex:none; margin:0 12px 8px; }
.dtt-tv-ds{ flex:1; min-height:0; overflow-y:auto; padding:0 8px 12px; overscroll-behavior:contain; }
.dtt-tv-dong{ display:flex; align-items:center; gap:10px; padding:8px; border-radius:10px; }
.dtt-tv-dong:hover{ background:var(--dt-nen); }
.dtt-tv-av{ position:relative; width:36px; height:36px; border-radius:50%; flex:none; display:grid; place-items:center; color:#fff; font-weight:700; font-size:14px; }
.dtt-tv-on{ position:absolute; right:-1px; bottom:-1px; width:11px; height:11px; border-radius:50%; background:var(--dtt-xanh-la); border:2px solid var(--dt-mat); }
.dtt-tv-chu{ flex:1; min-width:0; }
.dtt-tv-chu b{ display:block; font-size:13.5px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.dtt-tv-chu b em{ font-style:normal; font-weight:500; color:var(--dt-muc-2); }
.dtt-tv-chu small{ display:block; font-size:12px; color:var(--dt-muc-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:1px; }
.dtt-tv-chu .dtt-tv-dang{ color:var(--dtt-xanh-la); }
.dtt-tv-trong{ display:flex; flex-direction:column; align-items:center; gap:8px; text-align:center; font-size:13px; line-height:1.5; color:var(--dt-muc-2); padding:36px 16px; }
@media (prefers-reduced-motion:reduce){ .dtt-tv{ animation:none; } }
