/* Trình nhắn tin kiểu Zalo */
main.chat-mode { max-width: none; padding: 12px; }
.ch { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - 150px); min-height: 460px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.ch-side { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ch-top { display: flex; gap: 6px; padding: 12px; align-items: center; }
.ch-top input { flex: 1; border-radius: 99px; padding: 7px 14px; background: var(--bg); }
.ch-top button { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; flex: none; }
.ch-tabs { display: flex; gap: 6px; padding: 0 12px 8px; }
.ch-tabs button { background: transparent; color: var(--mut); border: 1px solid var(--line); border-radius: 99px; padding: 2px 12px; font-size: 13px; }
.ch-tabs button.on { background: var(--tint, var(--bg)); color: var(--pri); border-color: var(--pri); font-weight: 600; }
.ch-list { overflow-y: auto; flex: 1; }
.ch-room { display: flex; gap: 10px; padding: 10px 12px; cursor: pointer; align-items: center; border-left: 3px solid transparent; }
.ch-room:hover { background: var(--bg); }
.ch-room.on { background: var(--tint, var(--bg)); border-left-color: var(--pri); }
.ch-av { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; flex: none; font-size: 15px; }
.ch-av.sm { width: 32px; height: 32px; font-size: 12px; }
.ch-rm { min-width: 0; flex: 1; }
.ch-rm .r1, .ch-rm .r2 { display: flex; gap: 6px; align-items: baseline; justify-content: space-between; }
.ch-rm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.ch-rm .t { font-size: 12px; color: var(--mut); flex: none; }
.ch-rm .p { color: var(--mut); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-room.unread .p, .ch-room.unread b { color: var(--ink); font-weight: 700; }
.ch-badge { background: #e5484d; color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; flex: none; }
.nav-badge { background: #e5484d; color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 6px; margin-left: 6px; line-height: 17px; display: inline-block; vertical-align: 1px; }
.ch-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.ch-head { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.ch-head .nm { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-head .sub { font-size: 12px; color: var(--mut); font-weight: 400; display: block; }
.ch-head button { padding: 4px 10px; }
.ch-msgs { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.ch-day { align-self: center; background: var(--line); color: var(--mut); font-size: 12px; border-radius: 99px; padding: 1px 12px; margin: 10px 0 6px; }
.ch-sys { align-self: center; color: var(--mut); font-size: 12px; margin: 6px 0; text-align: center; }
.ch-row { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.ch-row.me { flex-direction: row-reverse; }
.ch-row .ch-av { margin-bottom: 2px; }
.ch-row.cont .ch-av { visibility: hidden; }
.ch-bub { max-width: min(68%, 560px); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 7px 12px; position: relative; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.ch-row.me .ch-bub { background: var(--tint, #dff3dc); border-color: transparent; }
.ch-bub .who { font-size: 12px; color: var(--pri); font-weight: 600; display: block; }
.ch-bub .tm { display: block; font-size: 11px; color: var(--mut); margin-top: 2px; text-align: right; white-space: normal; }
.ch-bub.gone { color: var(--mut); font-style: italic; }
.ch-bub img { display: block; max-width: 300px; max-height: 300px; border-radius: 8px; cursor: zoom-in; }
.ch-bub .file { display: flex; gap: 8px; align-items: center; cursor: pointer; white-space: normal; }
.ch-bub .quote { border-left: 3px solid var(--pri); background: rgba(127,127,127,.12); padding: 2px 8px; margin-bottom: 4px; font-size: 12px; color: var(--mut); border-radius: 4px; white-space: normal; }
.ch-bub .acts { position: absolute; top: -14px; display: none; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1px 3px; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.ch-row:not(.me) .acts { right: -6px; } .ch-row.me .acts { left: -6px; }
.ch-row:hover .acts { display: flex; }
.ch-bub .acts button { background: none; border: 0; color: var(--ink); padding: 1px 6px; font-size: 13px; }
.ch-seen { align-self: flex-end; font-size: 11px; color: var(--mut); margin: 0 4px 4px; }
.ch-compose { background: var(--card); border-top: 1px solid var(--line); padding: 8px 12px; }
.ch-reply { display: flex; gap: 8px; align-items: center; background: var(--bg); border-left: 3px solid var(--pri); padding: 3px 10px; margin-bottom: 6px; font-size: 13px; color: var(--mut); border-radius: 4px; }
.ch-reply span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-tools { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.ch-tools button { background: none; border: 0; font-size: 18px; padding: 2px 6px; border-radius: 6px; color: var(--ink); }
.ch-tools button:hover { background: var(--bg); }
.ch-emo { display: none; flex-wrap: wrap; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; max-width: 360px; }
.ch-emo.open { display: flex; }
.ch-emo button { font-size: 20px; padding: 2px 5px; background: none; border: 0; }
.ch-in { display: flex; gap: 8px; align-items: flex-end; }
.ch-in textarea { flex: 1; resize: none; max-height: 140px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 8px 12px; font: inherit; }
.ch-empty { margin: auto; text-align: center; color: var(--mut); padding: 24px; }
.ch-empty big { display: block; font-size: 44px; }
.ch-pick { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
.ch-pick label { display: flex; gap: 10px; align-items: center; padding: 6px 10px; cursor: pointer; margin: 0; }
.ch-pick label:hover { background: var(--bg); }
.ch-pick input { width: auto; }
.ch-back { display: none; }
@media (max-width: 760px) {
  .ch { grid-template-columns: 1fr; height: calc(100vh - 130px); }
  .ch.in-room .ch-side, .ch:not(.in-room) .ch-main { display: none; }
  .ch-back { display: inline-block; }
  .ch-bub { max-width: 82%; }
}
