/* Chat nổi (đợt 5): neo góc dưới phải, phía trên nút "Góp ý"; điện thoại: tấm toàn màn hình phía trên thanh tab. */

body.is-logged-out #chat-float-root { display: none; }

.cf-dock { position: fixed; right: 22px; bottom: 76px; z-index: 50; display: flex; align-items: flex-end; gap: 12px; flex-direction: row; pointer-events: none; }
.cf-dock > * { pointer-events: auto; }
.cf-pills { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.cf-pill { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); cursor: pointer; font-weight: 600; }
.cf-pill .ellipsis { min-width: 0; }
.cf-dot { color: var(--warn); }

.cf-win { width: 340px; height: min(460px, calc(100vh - 140px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22); overflow: hidden; }
.cf-head { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; background: var(--sidebar); color: #fff; }
.cf-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 700; }
.cf-title .ellipsis { min-width: 0; }
.cf-tools { display: flex; align-items: center; gap: 8px; }
.cf-tools > :first-child { margin-right: auto; }
.cf-link { font-size: 12px; color: var(--sidebar-ink); text-decoration: underline; }
.cf-icon { border: 0; background: rgba(255, 255, 255, 0.12); color: #fff; width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.cf-icon:hover { background: rgba(255, 255, 255, 0.24); }

.cf-tabs { display: flex; gap: 4px; overflow-x: auto; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cf-tab { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap; cursor: pointer; }
.cf-tab.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.cf-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column-reverse; padding: 10px; background: var(--surface-2); }
.cf-msgs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 8px; }
.cf-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; max-width: 85%; }
.cf-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.cf-bubble { padding: 7px 11px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.cf-msg.is-mine .cf-bubble { background: var(--good-bg); border-color: transparent; }
.cf-meta { font-size: 11px; color: var(--muted); }
.cf-empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; }

.cf-composer { display: flex; gap: 6px; align-items: flex-end; padding: 8px; border-top: 1px solid var(--line); background: var(--surface); }
.cf-composer textarea { flex: 1 1 auto; min-width: 0; resize: none; border: 1px solid var(--line-strong); border-radius: 10px; padding: 7px 9px; background: var(--surface); }

@media (max-width: 860px) {
  .cf-dock { inset: auto 0 calc(62px + env(safe-area-inset-bottom)) 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; }
  .cf-pills { flex-direction: row; justify-content: flex-end; padding: 0 12px 8px; flex-wrap: wrap; }
  .cf-win { width: 100%; height: calc(100vh - var(--bar-h) - 62px - env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
  /* Điện thoại chỉ hiện 1 khung (mở gần nhất), khung còn lại vẫn giữ trong bộ nhớ. */
  .cf-win:not(:last-child) { display: none; }
}
