/* Multi Web AI — batch 1 UI. Minimal & Swiss style. System fonts only, no CDN. */

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgb(15 23 42 / 0.08);
  --header-h: 60px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #334155;
  --accent: #ea580c;
  --accent-hover: #f97316;
  --danger: #f87171;
  --danger-hover: #ef4444;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.4);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.3; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 8px; }
ul { margin: 0; padding: 0; list-style: none; }

a { color: var(--accent); }

.muted { color: var(--muted); }

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--card);
  color: var(--text);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 100;
  transition: top 200ms ease;
}
.skip-link:focus { top: 8px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { color: var(--accent); display: inline-flex; flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 18px; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 8px; }

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lang-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.lang-btn:hover { background: var(--bg); color: var(--text); }
.lang-btn.is-active { background: var(--accent); color: #fff; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  max-width: 280px;
}
/* (f) Tên dài cắt ngắn bằng "…" thay vì xuống dòng: tên dài từng quấn
   thành nhiều dòng, đẩy đầu trang tràn/chồng lấn ở màn hẹp. Tên đầy đủ
   vẫn xem được khi hover nhờ title="tên đầy đủ" do app.js đặt. */
.user-chip svg { flex-shrink: 0; }
.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 10ch; /* tối đa ~10 ký tự + "…" */
  line-height: 1.3;
}

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease, opacity 200ms ease;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.icon-btn:hover { background: var(--bg); }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

.link-btn {
  background: none;
  border: 0;
  padding: 12px 4px;
  min-height: 44px;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; }
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  transition: border-color 200ms ease;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 2px rgb(234 88 12 / 0.25); }

.error { color: var(--danger); font-size: 14px; }
.success { color: #15803d; font-size: 14px; }
[data-theme="dark"] .success { color: #4ade80; }

/* ---------- Status / invite banner ---------- */
.status {
  max-width: 1360px;
  margin: 12px auto 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  width: calc(100% - 32px);
}
.status.is-error { border-color: var(--danger); color: var(--danger); }
.status.is-ok { border-color: #16a34a; color: #15803d; }
[data-theme="dark"] .status.is-ok { color: #4ade80; }

.invite-banner {
  max-width: 1360px;
  width: calc(100% - 32px);
  margin: 12px auto 0;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--card);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.invite-banner-body { display: flex; align-items: flex-start; gap: 10px; color: var(--accent); }
.invite-banner-text { color: var(--text); }
.invite-banner-text p { margin: 2px 0 0; color: var(--muted); }
.invite-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.invite-result { width: 100%; margin: 4px 0 0; }

/* ---------- Layout ---------- */
.app-shell { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-view { display: flex; flex-direction: column; align-items: center; gap: 16px; justify-content: center; padding: 24px 0; }
.auth-card { width: 100%; max-width: 440px; }
.auth-tabs { display: flex; gap: 4px; margin: 16px 0; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  grid-template-areas: "sidebar" "channels" "detail";
}

.sidebar { grid-area: sidebar; min-width: 0; }
.channels-panel { grid-area: channels; min-width: 0; }
.detail { grid-area: detail; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sidebar-head h2 { margin: 0; }

.ws-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ws-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
}
.ws-item:hover { border-color: var(--accent); }
.ws-item.is-active { border-color: var(--accent); background: rgb(234 88 12 / 0.08); }
.ws-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }

.create-ws { margin-top: 4px; }

.channel-list, .member-list { display: flex; flex-direction: column; gap: 8px; }
.channel-item, .member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* (D3-d) Tên kênh bị cắt thành "#muse-tra…" ở 1440px: cột kênh chỉ 280px
   mà một hàng kênh phải chứa cả tên + huy hiệu "Chỉ Muse" + nhóm, đều
   white-space: nowrap, nên tên bị bóp tới ~100px rồi cắt bằng ellipsis.
   Sửa: cho hàng kênh xuống dòng thay vì bóp tên; tên chiếm hết chỗ còn
   lại của dòng 1 (min-width: 0 để ellipsis chỉ dùng khi thật sự hết chỗ);
   nhóm rỗng (groupName null, trường hợp của #muse-trao-doi ngoài demo)
   thì ẩn hẳn để không ăn một khoảng gap 8px. */
.channel-item { flex-wrap: wrap; }
.channel-name { flex: 1 1 auto; min-width: 0; }
.channel-item .badge { flex: 0 0 auto; max-width: 100%; }
.channel-group:empty { display: none; }
.channel-name, .member-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-group, .member-email { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-demo { border-color: var(--accent); color: var(--accent); background: rgb(234 88 12 / 0.08); }
.badge-count { background: var(--bg); }

.ws-meta { color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.meta-sep { color: var(--border); }

.app-footer { border-top: 1px solid var(--border); padding: 16px; text-align: center; color: var(--muted); font-size: 14px; }
.app-footer p { margin: 0; }
.footer-links { margin-top: 8px; display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 8px; }
.footer-sep { color: var(--border); }

/* ---------- Trang pháp lý công khai (#terms / #privacy) ---------- */
.legal-view { display: flex; flex-direction: column; align-items: center; padding: 24px 0; }
.legal-card { width: 100%; max-width: 760px; }
.legal-card h1 { font-size: 24px; }
.legal-body h2 { font-size: 17px; margin: 20px 0 8px; }
.legal-body p { overflow-wrap: anywhere; }
.legal-notice { max-width: 440px; margin: 0 auto; text-align: center; font-size: 14px; }

/* ---------- Mobile drawer (under 768px) ---------- */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    z-index: 40;
    overflow-y: auto;
    background: var(--card);
    border-right: 1px solid var(--border);
    padding: 16px;
    transform: translateX(-105%);
    transition: transform 200ms ease;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgb(15 23 42 / 0.5);
  }
  .brand-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; }
  /* Đầu trang mobile: cho phép xuống 2 hàng (thương hiệu ở hàng 1, các nút
     thao tác ở hàng 2) thay vì chen nhau trên 1 hàng ở 375px; tên người
     dùng đã cắt ngắn bằng "…" ở quy tắc .user-chip span phía trên. */
  .app-header { flex-wrap: wrap; row-gap: 8px; padding: 8px 12px; }
  .brand { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
  .badge-demo { overflow: visible; text-overflow: clip; white-space: normal; max-width: 100%; line-height: 1.35; text-align: center; }
  .header-actions { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  .user-chip { max-width: 130px; }
  /* Nút Đăng xuất thu thành icon ở màn hẹp: chữ vẫn còn trong DOM (đọc
     được bằng trình đọc màn hình qua aria-label) nhưng không chiếm chỗ,
     không gãy thành 2 dòng. */
  #logoutBtn { font-size: 0; gap: 0; min-width: 44px; padding: 10px 12px; }
  #logoutBtn::after { content: "→"; font-size: 20px; line-height: 1; }
}

@media (min-width: 768px) {
  .menu-btn, .sidebar-close, .sidebar-overlay { display: none !important; }
  .layout {
    grid-template-columns: 240px 1fr;
    grid-template-areas:
      "sidebar channels"
      "sidebar detail";
  }
  .sidebar { position: static; transform: none; }
  .auth-card { padding: 24px; }
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 280px 260px 1fr;
    grid-template-areas: "sidebar channels detail";
    align-items: start;
  }
  .sidebar, .channels-panel { position: sticky; top: calc(var(--header-h) + 16px); }
}

@media (min-width: 1440px) {
  /* (D3-d) Nới cột kênh 280px -> 300px: "#muse-trao-doi" (~116px) +
     huy hiệu "Chỉ Muse" (~87px) + nhóm "Muse" (~40px) + 2 gap + padding
     vừa đủ một dòng (cần ~259px trong 274px ruột cột). */
  .layout { grid-template-columns: 300px 300px 1fr; }
  .app-shell { padding: 24px; }
}

/* ---------- Đợt 2: kho bảo mật / Muse / Kanban / chat / tích hợp ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
.check-list input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Kho bảo mật */
.vault-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.vault-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.vault-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.vault-masked { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.once-value {
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: rgb(234 88 12 / 0.08);
  overflow-wrap: anywhere;
  font-size: 14px;
}

/* Muse */
.agent-form { margin: 12px 0; }
.table-wrap { overflow-x: auto; margin: 12px 0; }
.agents-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.agents-table th, .agents-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.agents-table td .btn, .agents-table td button {
  min-height: 44px;
  padding: 8px 12px;
  margin: 2px 4px 2px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.agents-table td button:hover { border-color: var(--accent); }
.keys-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.keys-list li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.keys-list button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: transparent;
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}
.stats-list { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.stats-list dt { font-weight: 600; }
.stats-list dd { margin: 0; }
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; padding-left: 24px; }

/* Việc + Kanban */
#taskFormWrap label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
}
#taskFormWrap input,
#taskFormWrap select,
#taskFormWrap textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
#taskFormWrap textarea { min-height: 88px; resize: vertical; }
#taskFormWrap fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 12px; padding: 12px; }
#taskFormWrap fieldset label { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 4px; cursor: pointer; }
#taskFormWrap fieldset input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--accent); }
#taskFormWrap button[type="submit"], .p3-task-card button, .p3-comments button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
#taskFormWrap button[type="submit"] { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.p3-kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.p3-kanban-col {
  flex: 1 0 240px;
  min-width: 240px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
}
.p3-kanban-col h4 { margin: 0 0 12px; }
.p3-task-card {
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.p3-task-card h4 { margin: 0 0 8px; }
.p3-task-card p { font-size: 14px; }
.p3-task-card button { margin: 2px 4px 2px 0; }
.p3-task-actions { margin: 8px 0; }
.p3-comments { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; }
.p3-comment-list { font-size: 14px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.p3-comment-form { display: flex; gap: 8px; }
.p3-comment-form input {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
}

/* Thanh công cụ: tìm kiếm + chuông + hiện diện */
.app-toolbar { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.toolbar-search { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar-search input[type="search"] {
  flex: 1;
  min-width: 180px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.toolbar-search select {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-result { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.search-result-meta { color: var(--muted); font-size: 14px; }
.toolbar-notif { position: relative; }
.notif-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  width: min(360px, 90vw);
  max-height: 60vh;
  overflow-y: auto;
}
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.notif-item.is-unread { border-color: var(--accent); }
.presence-list { display: flex; flex-wrap: wrap; gap: 8px; }
.presence-list li { padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 14px; }

/* Chat */
.chat-panel, .dm-panel, .integrations-view { margin-top: 16px; }
.chat-head, .integrations-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chat-head h2, .integrations-head h2 { margin: 0; }
.message-list { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow-y: auto; margin: 12px 0; }
.message {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
.message.is-pinned { border-color: var(--accent); }
.message-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.message-author { font-weight: 700; color: var(--text); }
.message-edited { font-style: italic; }
.message-body { overflow-wrap: anywhere; white-space: pre-wrap; }
.message-reply-to { font-size: 14px; color: var(--muted); border-left: 3px solid var(--accent); padding-left: 8px; margin-bottom: 6px; }
.message-attachments { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.attachment-image { max-width: 100%; max-height: 320px; border-radius: var(--radius); }
.message-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.message-actions .link-btn { min-height: 44px; padding: 8px 10px; }
.message-edit-input {
  width: 100%;
  min-height: 88px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.mention-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 8px;
}
.mention-option {
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mention-option:hover { background: var(--bg); }
.reply-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 8px;
}
.pending-files { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}
.file-chip-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.file-chip button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}
.chat-composer { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-composer input[type="text"] {
  flex: 1;
  min-width: 180px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.edit-history-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.edit-history-who { font-weight: 600; font-size: 14px; }
.edit-history-old { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }

/* Tạo kênh */
.create-channel { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Tích hợp */
.integrations-view section { margin-bottom: 16px; }
.integrations-view label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 14px; }
.integrations-view input,
.integrations-view select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.integrations-view button { min-height: 44px; margin: 2px 4px 2px 0; }
.integrations-view code { overflow-wrap: anywhere; }
#intStatus { margin: 12px 0; }

/* ----- Đợt 5 E1: mã QR bật 2FA ----- */
/* Khung QR căn giữa, nền trắng cố định để app xác thực quét được ở cả
   chế độ sáng lẫn tối. Canvas 220px + viền/padding vẫn gọn trong thẻ ở
   màn 375px; max-width giữ QR không tràn khi thẻ hẹp hơn. */
.twofa-qr { margin: 12px 0; text-align: center; }
.twofa-qr canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.twofa-qr figcaption { margin-top: 8px; font-size: 13px; text-align: left; }
/* Bí mật 32 ký tự là một token liền mạch: cho xuống dòng để không tràn
   thẻ ở màn hẹp. Mã dự phòng đã có khoảng trắng nên tự xuống dòng được. */
#twofaSecretValue { overflow-wrap: anywhere; }
