/* ITC Web UI — AI_OS brand-aligned palette (BRAND_STYLE_GUIDE.md §3-§5).
   Sub-brand ITC: cyan #06b6d4 + Captions lucide icon. */

:root {
  /* ── §3.3 Surface light mode ── */
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --border: rgba(0,0,0,0.08);
  --text: #111827;
  --text-dim: #6b7280;

  /* ── §3.1 Brand + accent ── */
  --brand-dark: #0F2540;            /* navbar/sidebar deep blue */
  --brand-gradient-start: #1f3b68;
  --brand-gradient-end: #2a4c84;
  --accent: #5b9cf6;                /* AI_OS family accent-blue (CTAs, focus) */
  --accent-soft: #e8f0fe;           /* light tint of accent */
  --itc-accent: #06b6d4;            /* ITC sub-brand cyan (Captions icon, live indicator) */
  --itc-accent-soft: #ecfeff;       /* light tint */

  /* ── §3.2 Functional ── */
  --green: #22c55e;                 /* success */
  --amber: #facc15;                 /* warning */
  --red: #ef4444;                   /* error */
  --info: #3b82f6;                  /* info */

  /* ── Caption semantic (preserved from v1.0) ── */
  --en: #0a3a8c;
  --vn: #b91c1c;
  --vn-bg: #fef2f2;

  /* ── Chat bubble ── */
  --chat-mine-bg: #e8f0fe;
  --chat-other-bg: #f3f4f6;

  /* ── §5.3 Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow: var(--shadow-md);       /* default alias */

  /* ── §5.2 Border radius ── */
  --radius-sm: 2px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius: var(--radius-lg);       /* default alias = 8px (was 10px) */

  /* ── §5.1 Spacing (Tailwind-aligned) ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --gap: var(--space-3);            /* default alias = 12px */

  /* ── §4.1 Font stack ── */
  --font-en: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-vn: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Be Vietnam Pro", sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* ── Layout ── */
  --header-h: 56px;
  --footer-h: 40px;
  --tabs-h: 0px;
}

body.dark {
  /* ── §3.3 Surface dark mode ── */
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-2: #1f2937;
  --border: rgba(255,255,255,0.08);
  --text: #f9fafb;
  --text-dim: #9ca3af;

  /* Accent stays same (per §3.3 spec); tint changes for dark contrast */
  --accent-soft: #1e293b;
  --itc-accent-soft: #0c2a30;

  /* Caption semantic dark variants */
  --en: #93c5fd;
  --vn: #fda4af;
  --vn-bg: #2a1418;

  --chat-mine-bg: #1e293b;
  --chat-other-bg: #1f2937;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.6);
  --shadow: var(--shadow-md);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-vn);
  font-size: 15px;
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

/* ════════════════════════════════════════════════════════════════
   v2.0 LAYOUT B — Hybrid restructure (icon rail trái)
   ════════════════════════════════════════════════════════════════ */
/* Icon rail mặc định ẩn — chỉ hiện khi body.layout-b active.
   Khi rail hiện, body content offset 60px qua padding-left. */
.rail-b { display: none; }

body.layout-b {
  padding-left: 60px;
}
body.layout-b .rail-b {
  display: flex;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column;
  align-items: center;
  padding: var(--space-3) 0;
  gap: 4px;
  z-index: 50;
}
.rail-b-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  position: relative;
  transition: all 0.15s;
  padding: 0;
}
.rail-b-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.rail-b-btn.active {
  color: var(--itc-accent);
  background: var(--itc-accent-soft);
}
.rail-b-btn.active::before {
  content: "";
  position: absolute;
  left: -2px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--itc-accent);
  border-radius: 0 2px 2px 0;
}
.rail-b-btn svg {
  display: block;
}
.rail-b-spacer { flex: 1; }
/* Count badge cyan ở góc phải-trên (cho tab Đội) */
.rail-b-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--itc-accent);
  color: white;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
  line-height: 1;
}
.rail-b-count[hidden] { display: none; }

/* v2.24.2: KHÔI PHỤC #presence pill trong header Layout B — Sprint 1 Task 1.3
   👥 pill dùng _presenceMiniDrop riêng; #presenceDropdown chỉ mở từ ➕ newChatBtn.
   v2.24.24 fix: KHÔNG ẩn presenceDropdown ở đây — ẩn nó kill luôn ➕ newChatBtn. */

/* Mobile responsive — rail thu lại thành thanh ngang dưới */
@media (max-width: 720px) {
  body.layout-b {
    padding-left: 0;
    padding-bottom: 56px;
  }
  body.layout-b .rail-b {
    top: auto;
    right: 0;
    width: auto;
    height: 56px;
    flex-direction: row;
    padding: 0 var(--space-2);
    border-right: 0;
    border-top: 1px solid var(--border);
  }
  body.layout-b .rail-b-btn.active::before {
    left: 6px;
    right: 6px;
    top: -2px;
    bottom: auto;
    width: auto;
    height: 3px;
    border-radius: 0 0 2px 2px;
  }
  body.layout-b .rail-b-spacer { flex: 0; min-width: var(--space-2); }
}

/* ────────────────────────────────────────────────────────────────
   Layout B — view container swapping (5 views: live/recordings/team/settings/help)
   ──────────────────────────────────────────────────────────────── */
/* Default: view-b chỉ render khi layout-b active. Khi không layout-b, các view kia ẩn,
   legacy 2-pane render bình thường. */
body:not(.layout-b) .view-b:not(#view-b-live) { display: none; }
body:not(.layout-b) #view-b-live { display: contents; }

body.layout-b .two-pane {
  display: block;          /* override grid để view-b điều khiển layout */
  grid-template-columns: none;
  background: var(--bg);
}
body.layout-b .view-b { display: none; }
body.layout-b .view-b.active { display: block; height: 100%; overflow: hidden; }

/* "Đang phát" view: 3-pane training (captions | slide | chat) + slide strip dưới
   v2.15.4: Refactor pane-hide qua CSS variables — combine ĐÚNG khi ≥2
   no-X class active. Trước: rule cascade last-wins → đóng 2 pane chỉ 1 pane
   biến mất (pane còn lại hiển thị do rule sau ghi đè width). */
body.layout-b #view-b-live.active {
  --w-captions: minmax(0, 1fr);
  --w-slide:    minmax(0, 1fr);
  --w-chat:     minmax(0, 0.7fr);
  --h-strip:    180px;
  display: grid;
  grid-template-columns: var(--w-captions) var(--w-slide) var(--w-chat);
  grid-template-rows: 1fr var(--h-strip);
  grid-template-areas:
    "captions slide chat"
    "strip strip strip";
  gap: 1px;
  background: var(--border);
}
body.layout-b #view-b-live #captions-pane { grid-area: captions; }
body.layout-b #view-b-live #slide-pane-b { grid-area: slide; }
body.layout-b #view-b-live #chat-pane { grid-area: chat; }
body.layout-b #view-b-live #slideStrip { grid-area: strip; border-top: 1px solid var(--border); }
/* Pane hidden state — set width track của pane đó về 0 + display:none cho
   chính pane. Compound đúng khi nhiều class no-X cùng active. v2.15.5:
   thêm display:none vì width=0 không đủ — content (pane-header, chat-input-row)
   vẫn render overflow ra ngoài cột 0px → leftover UI bên trái. */
body.layout-b #view-b-live.no-captions { --w-captions: 0; }
body.layout-b #view-b-live.no-slide    { --w-slide: 0; }
body.layout-b #view-b-live.no-chat     { --w-chat: 0; }
body.layout-b #view-b-live.no-strip    { --h-strip: 0; }
body.layout-b #view-b-live.no-captions #captions-pane { display: none !important; }
body.layout-b #view-b-live.no-slide    #slide-pane-b  { display: none !important; }
body.layout-b #view-b-live.no-chat     #chat-pane     { display: none !important; }
body.layout-b #view-b-live.no-strip    #slideStrip    { display: none !important; }
/* v2.15.6: khi cả 3 pane chính đóng → tự ẩn slide-strip + collapse main
   (tránh strip tự widen theo content header → main shrink-to-fit lệch trái). */
body.layout-b #view-b-live.no-captions.no-slide.no-chat #slideStrip { display: none !important; }
body.layout-b > main.two-pane { min-width: 0; }

/* Slide pane B: middle column showing latest captured slide + OCR + actions */
.slide-pane-b { display: none; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--surface-2); }
body.layout-b .slide-pane-b { display: flex; }
.slide-pane-body {
  flex: 1; overflow-y: auto; padding: var(--space-4);
}
.slide-pane-image-wrap {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, #0F2540, #1f3b68);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; margin-bottom: var(--space-3);
}
.slide-pane-image-wrap img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.slide-pane-ocr {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-3);
  font-size: 12px; line-height: 1.6;
  margin-bottom: var(--space-3);
}
.slide-pane-ocr-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-dim); font-weight: 700; margin-bottom: 4px;
}
.slide-pane-ocr-en { color: var(--en); margin-bottom: var(--space-2); }
.slide-pane-ocr-vn {
  color: var(--text); padding: 6px 10px; background: var(--vn-bg);
  border-left: 3px solid var(--vn); border-radius: 4px;
}
.slide-pane-actions {
  display: flex; gap: var(--space-2);
}
.slide-pane-actions button {
  flex: 1; padding: 6px 10px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius-md);
  cursor: pointer; font-size: 12px;
}
.slide-pane-actions button.primary {
  background: var(--itc-accent); color: white; border-color: var(--itc-accent);
}

/* Khi không layout-b: slide-pane-b ẩn (legacy 2-pane vẫn dùng slide-strip cũ) */
body:not(.layout-b) .slide-pane-b { display: none !important; }
body.layout-c .slide-pane-b { display: none !important; }

/* 4 view khác: full-width content scroll dọc */
body.layout-b #view-b-recordings.active,
body.layout-b #view-b-team.active,
body.layout-b #view-b-settings.active,
body.layout-b #view-b-help.active {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.view-b-header {
  padding: var(--space-4) var(--space-6) var(--space-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-b-header h2 {
  margin: 0 0 var(--space-1);
  font-size: 18px;
  font-weight: 600;
}
.view-b-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.view-b-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}
.view-b-body code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 90%;
}
.view-b-body kbd {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 90%;
}

/* ════════════════════════════════════════════════════════════════
   v2.0 LAYOUT C — Full Teams clone (rail 60 + section 280 + main)
   ════════════════════════════════════════════════════════════════ */
.rail-c, .section-col-c { display: none; }

body.layout-c {
  padding-left: 340px;     /* rail 60 + section 280 */
}
body.layout-c .rail-c {
  display: flex;
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 60px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column; align-items: center;
  padding: var(--space-3) 0; gap: 4px;
  z-index: 50;
}
body.layout-c .section-col-c {
  display: flex;
  position: fixed; left: 60px; top: 0; bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column;
  z-index: 49;
  overflow: hidden;
}
/* Reuse rail-b-btn styling pattern */
.rail-c-btn {
  width: 44px; height: 44px;
  border: none; background: transparent; cursor: pointer;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); position: relative;
  transition: all 0.15s; padding: 0;
}
.rail-c-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-c-btn.active { color: var(--itc-accent); background: var(--itc-accent-soft); }
.rail-c-btn.active::before {
  content: ""; position: absolute; left: -2px; top: 6px; bottom: 6px;
  width: 3px; background: var(--itc-accent); border-radius: 0 2px 2px 0;
}
.rail-c-spacer { flex: 1; }
.rail-c-count {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--itc-accent); color: white;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface); line-height: 1;
}
.rail-c-count[hidden] { display: none; }

/* Section column content swap */
.section-c-content { display: none; flex-direction: column; height: 100%; flex: 1; overflow: hidden; }
.section-c-content.active { display: flex; }
.section-c-header {
  padding: var(--space-4); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.section-c-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.section-c-body { flex: 1; overflow-y: auto; padding: var(--space-2); }
.section-c-pills { display: flex; gap: 4px; padding: var(--space-2); flex-wrap: wrap; }
.section-c-pill {
  padding: 3px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 11px; color: var(--text-dim); cursor: pointer;
}
.section-c-pill.active { background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); font-weight: 500; }
.section-c-group {
  font-size: 11px; font-weight: 700; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: var(--space-3) var(--space-3) 4px;
}
.section-c-item {
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  cursor: pointer; display: flex; align-items: center; gap: var(--space-2);
  font-size: 13px;
}
.section-c-item:hover { background: var(--surface-2); }
.section-c-item.active { background: var(--itc-accent-soft); color: var(--itc-accent); font-weight: 500; }
.section-c-item .ic { width: 18px; opacity: 0.7; }
.section-c-empty {
  padding: var(--space-4); font-size: 12px; color: var(--text-dim);
  text-align: center; font-style: italic;
}

/* C: layout view-b-live differently based on active C tab.
   3 panes (captions/chat/slide-strip) only show ONE per active C live-tab.
   v2.2: opacity transition smooth — fix flicker khi swap C tab */
body.layout-c #view-b-live.active {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
  /* v2.24.3: bắt buộc height: 100% — không có thì #captions-pane bên trong
     không có max-height → .captions {flex:1; overflow-y:auto} không trigger
     scroll trên mobile (cả auto-scroll lẫn touch-scroll đều chết). overflow:
     hidden trên container ngoài để chỉ con .captions/.chat-messages scroll. */
  height: 100%;
  overflow: hidden;
}
body.layout-c #view-b-live > * {
  grid-column: 1; grid-row: 1;
  transition: opacity 0.15s ease-out;
  will-change: opacity;
  /* v2.24.3: min-height: 0 cho phép flex con shrink dưới content size —
     classic flexbox overflow fix. Không có → flex-grow ép parent giãn theo
     nội dung → scroll chết. */
  min-height: 0;
  /* Mobile iOS Safari smooth scrolling fallback (modern iOS không cần
     nhưng vẫn safe để giữ). */
  -webkit-overflow-scrolling: touch;
}
/* Default = captions tab: show captions only */
body.layout-c.c-tab-captions #view-b-live #captions-pane { display: flex; }
body.layout-c.c-tab-captions #view-b-live #chat-pane,
body.layout-c.c-tab-captions #view-b-live .slide-strip { display: none !important; }
body.layout-c.c-tab-chat #view-b-live #chat-pane { display: flex; }
body.layout-c.c-tab-chat #view-b-live #captions-pane,
body.layout-c.c-tab-chat #view-b-live .slide-strip { display: none !important; }
body.layout-c.c-tab-slide #view-b-live .slide-strip { display: flex; flex-direction: column; }
body.layout-c.c-tab-slide #view-b-live #captions-pane,
body.layout-c.c-tab-slide #view-b-live #chat-pane { display: none !important; }

/* v2.30: tab Phiên dịch dùng full width — cột phải two-pane trống ở layout-c,
   thu hồi để gom toàn bộ control phiên dịch lên 1 hàng. */
body.layout-c.c-tab-interpreter > main.two-pane { grid-template-columns: minmax(0, 1fr); }

/* C: ẩn header + footer + mobile-tabs + control-panel + B rail (override v1.1.0) */
body.layout-c > header,
body.layout-c > footer,
body.layout-c .mobile-tabs,
body.layout-c .control-panel,
body.layout-c .rail-b { display: none !important; }
/* v2.24.24: #presenceDropdown KHÔNG ẩn trong layout-c — mở được từ ➕ newChatBtn */
/* v2.24.2: KHÔI PHỤC #presence pill trong header Layout C — Sprint 1 Task 1.3. */

/* C: layout-b view-b-live grid override for layout-c (single column) */
body.layout-c #view-b-recordings.active,
body.layout-c #view-b-team.active,
body.layout-c #view-b-settings.active,
body.layout-c #view-b-help.active {
  display: flex; flex-direction: column;
  background: var(--bg); height: 100%; overflow: hidden;
}

/* Mobile responsive C: hide section column on small screens */
@media (max-width: 720px) {
  body.layout-c { padding-left: 0; padding-bottom: 56px; }
  body.layout-c .rail-c {
    top: auto; right: 0; width: auto; height: 56px;
    flex-direction: row; padding: 0 var(--space-2);
    border-right: 0; border-top: 1px solid var(--border);
  }
  body.layout-c .section-col-c { display: none; }

  /* v2.22.3 — Fix Bug D: rail-c position:fixed bottom 56px che gần hết
     chat-input-row trên mobile Layout C. body.padding-bottom đẩy được normal
     block flow nhưng main.two-pane là flex-fill height → chat-input-row dán
     đáy main, vẫn bị rail overlay. Đẩy chat-input-row up = rail height + iPhone
     safe-area (home indicator), giữ tap-target nguyên vẹn. */
  body.layout-c.is-mobile #chat-pane .chat-input-row,
  body.layout-c.is-mobile #chat-pane #chatForm {
    padding-bottom: calc(56px + max(8px, env(safe-area-inset-bottom)));
  }
  /* Tương tự với compose mode rich-text (Bug D đối xứng cho mọi input layer). */
  body.layout-c.is-mobile #chat-pane .compose-wrap {
    margin-bottom: calc(56px + max(8px, env(safe-area-inset-bottom)));
  }
}

/* ════════════════════════════════════════════════════════════════
   v2.0 P4 — Customization #3 Multi-language picker (B + C)
   ════════════════════════════════════════════════════════════════ */
.lang-picker {
  display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.lang-chip {
  padding: 2px 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 11px; cursor: pointer;
  color: var(--text-dim); display: inline-flex; align-items: center; gap: 3px;
  font-weight: 500;
}
.lang-chip:hover { background: var(--surface-2); }
.lang-chip.active { background: var(--itc-accent-soft); color: var(--itc-accent);
  border-color: var(--itc-accent); }
.lang-chip.auto { background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); }
.lang-chip.add { background: transparent; border-style: dashed; }

/* Hide caption lang line theo body.hide-lang-X class */
body.hide-lang-fr .cap .lang-line.fr,
body.hide-lang-de .cap .lang-line.de,
body.hide-lang-zh .cap .lang-line.zh,
body.hide-lang-ja .cap .lang-line.ja { display: none; }
/* Extra lang line colors (v2.3) */
.cap .lang-line {
  font-size: 13px; line-height: 1.5; padding: 4px 8px; border-radius: 4px;
  margin-top: 4px;
}
.cap .lang-line.en { color: var(--en); background: rgba(91,156,246,0.08); }
.cap .lang-line.vi { color: var(--text); font-weight: 500; font-size: 14px;
  background: var(--vn-bg); border-left: 3px solid var(--vn); }
.cap .lang-line.fr { color: #6366f1; background: rgba(99,102,241,0.08); }
.cap .lang-line.de { color: #d97706; background: rgba(217,119,6,0.08); }
.cap .lang-line.zh { color: #b91c1c; background: rgba(185,28,28,0.06); }
.cap .lang-line.ja { color: #db2777; background: rgba(219,39,119,0.08); }
.cap .lang-line .lang-tag {
  font-size: 9px; text-transform: uppercase; font-weight: 700;
  background: rgba(0,0,0,0.15); color: inherit; padding: 1px 5px;
  border-radius: 3px; margin-right: 6px; letter-spacing: 0.04em;
  opacity: 0.7;
}

/* ════════════════════════════════════════════════════════════════
   v2.3 — Global search bar in topbar
   ════════════════════════════════════════════════════════════════ */
.global-search {
  flex: 1; max-width: 480px; min-width: 0;
  margin: 0 var(--space-3);
  position: relative;
  display: flex; align-items: center; gap: var(--space-2);
}
.global-search input {
  flex: 1; min-width: 0;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text); font-size: 13px;
  font-family: var(--font-vn);
  outline: none;
}
.global-search input:focus {
  border-color: var(--itc-accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--itc-accent-soft);
}
.global-search input::placeholder { color: var(--text-dim); }
.global-search-hint {
  font-size: 11px; color: var(--text-dim);
  flex-shrink: 0;
}
.global-search-hint.has-results { color: var(--itc-accent); font-weight: 600; }
/* Highlight matches across caption/chat */
.cap.search-match,
.chat-msg.search-match { outline: 2px solid var(--itc-accent); outline-offset: 2px; }
.cap.search-dim,
.chat-msg.search-dim { opacity: 0.3; }
mark.search-hit {
  background: rgba(250,204,21,0.45); color: inherit;
  padding: 0 2px; border-radius: 2px;
}

/* Layout C: ẩn header chính nên global search cũng ẩn — section-c-search thay thế */
body.layout-c .global-search { display: none !important; }

/* v2.14.0 — Global search collapse: chỉ hiện icon 🔍, click expand inline */
.global-search.collapsed { flex: 0 0 auto; max-width: none; }
.global-search.collapsed input,
.global-search.collapsed .global-search-hint { display: none; }
.global-search:not(.collapsed) .global-search-toggle { display: none; }
.global-search-toggle {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.global-search-toggle:hover { background: var(--itc-accent-soft); border-color: var(--itc-accent); }

/* v2.14.0 — Pane restore pills inline trong header (thay sticky bar bên dưới) */
.header-pane-restore {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 var(--space-2);
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--itc-accent-soft, rgba(34,211,238,0.10));
  border: 1px solid var(--itc-accent, #22d3ee);
  font-size: 11px;
}
.header-pane-restore[hidden] { display: none; }
.header-pane-restore .prb-label {
  color: var(--itc-accent, #22d3ee);
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}
.header-pane-restore .prb-pill {
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface, #fff); border: 1px solid var(--border);
  color: var(--text); font-size: 11px; cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.header-pane-restore .prb-pill:hover {
  background: var(--itc-accent-soft);
  border-color: var(--itc-accent);
}
.header-pane-restore .prb-pill[hidden] { display: none; }
.header-pane-restore .prb-pill-all {
  background: var(--itc-accent, #22d3ee); color: #fff;
  border-color: var(--itc-accent);
}
body.dark .header-pane-restore .prb-pill {
  background: rgba(255,255,255,0.05); color: var(--text, #e4e4e7);
}
/* Layout C ẩn header → pane restore pills cũng ẩn */
body.layout-c .header-pane-restore { display: none !important; }

/* v2.15.0 #8 — Pre-hoc TEXT-REVERSE typing indicator strip */
.reverse-typing-strip {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 var(--space-2);
  flex-wrap: wrap;
}
.reverse-typing-strip[hidden] { display: none; }
.reverse-typing-chip {
  padding: 2px 9px; border-radius: 999px;
  background: rgba(34, 211, 238, 0.10);
  border: 1px solid var(--c, #06b6d4);
  color: var(--text); font-size: 11px;
  white-space: nowrap;
  animation: reverseTypingPulse 1.6s ease-in-out infinite;
}
@keyframes reverseTypingPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
body.layout-c .reverse-typing-strip { display: none !important; }

/* ════════════════════════════════════════════════════════════════
   v2.3 — Section column search input + filter pills + badges
   ════════════════════════════════════════════════════════════════ */
.section-c-search {
  width: 100%;
  margin-top: var(--space-2);
  padding: 5px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-vn);
  outline: none;
}
.section-c-search:focus {
  border-color: var(--itc-accent);
  background: var(--surface);
}
.section-c-search::placeholder { color: var(--text-dim); }

.section-c-badge {
  margin-left: auto;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  line-height: 1.3;
}
.section-c-badge[hidden] { display: none; }

/* Section thumb row (slide) — chuẩn theo mockup */
.section-c-thumb-row {
  display: flex; gap: var(--space-2);
  padding: var(--space-2); border-radius: var(--radius-md);
  cursor: pointer; align-items: center;
}
.section-c-thumb-row:hover { background: var(--surface-2); }
.section-c-thumb-row.active { background: var(--itc-accent-soft); }
.section-c-thumb-row .thumb {
  width: 80px; height: 45px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #cbd5e1; font-size: 9px; padding: 4px;
  overflow: hidden; display: flex;
  align-items: flex-end;
}
.section-c-thumb-row .thumb img {
  width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm);
}
.section-c-thumb-row .meta {
  flex: 1; min-width: 0; font-size: 11px; color: var(--text-dim);
}
.section-c-thumb-row .meta b { color: var(--text); display: block; font-size: 12px; }

/* Acronym highlight (ctx menu find-acronym + replay) */
.cap.acronym-hl {
  animation: acronymPulse 1.5s ease-in-out;
  outline: 2px solid var(--itc-accent); outline-offset: 2px;
}
@keyframes acronymPulse {
  0%, 100% { background: var(--surface); }
  50% { background: var(--itc-accent-soft); }
}

/* ════════════════════════════════════════════════════════════════
   v2.0 P4 — Customization #4 Smart context menu (B + C)
   ════════════════════════════════════════════════════════════════ */
.ctx-menu {
  position: fixed; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  padding: 4px; min-width: 240px;
  z-index: 9999; display: none;
}
.ctx-menu.active { display: block; }
.ctx-group { padding: 4px 0; }
.ctx-group + .ctx-group { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.ctx-group-label {
  padding: 4px 12px 2px; font-size: 10px;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; cursor: pointer; font-size: 13px;
  border-radius: 4px;
}
.ctx-item:hover { background: var(--itc-accent-soft); color: var(--itc-accent); }
.ctx-item .ic { width: 18px; text-align: center; opacity: 0.8; }
.ctx-item .sc {
  margin-left: auto; font-size: 10px; color: var(--text-dim);
  font-family: var(--font-mono); padding: 1px 6px; background: var(--surface-2);
  border-radius: 3px; border: 1px solid var(--border);
}
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: rgba(239,68,68,0.1); color: var(--red); }

/* ════════════════════════════════════════════════════════════════
   v2.0 P4 — Customization #5 Zalo-style chat compose (B + C)
   ════════════════════════════════════════════════════════════════ */
.zalo-tools {
  display: flex; gap: 1px; padding: 4px 8px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  align-items: center;
  background: var(--surface);
}
.zalo-tool-btn {
  background: transparent; border: 0; padding: 4px 6px;
  cursor: pointer; color: var(--text-dim);
  border-radius: 4px; font-size: 15px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; min-height: 28px;
}
.zalo-tool-btn:hover { background: var(--surface-2); color: var(--text); }
.zalo-tool-btn.active { color: var(--itc-accent); background: var(--itc-accent-soft); }
.zalo-tool-btn svg { width: 16px; height: 16px; stroke-width: 2; }
.zalo-tool-divider { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }
.zalo-tool-more { margin-left: auto; }

.zalo-format-bar {
  display: none; gap: 1px;
  padding: 4px 8px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  align-items: center; flex-wrap: wrap;
}
.zalo-format-bar.active { display: flex; }
.zalo-fmt-btn {
  background: transparent; border: 0; padding: 3px 8px;
  cursor: pointer; color: var(--text); font-size: 13px; font-weight: 700;
  border-radius: 3px;
  min-width: 24px; line-height: 1;
}
.zalo-fmt-btn:hover { background: var(--surface); }
.zalo-fmt-btn.italic { font-style: italic; font-weight: 400; }
.zalo-fmt-btn.underline { text-decoration: underline; font-weight: 400; }
.zalo-fmt-btn.strike { text-decoration: line-through; font-weight: 400; }
.zalo-fmt-btn.small { font-size: 11px; }
.zalo-fmt-divider { width: 1px; height: 14px; background: var(--border); margin: 0 4px; }
.zalo-fmt-expand { margin-left: auto; }

/* ════════════════════════════════════════════════════════════════
   v2.0 P5 — Customization #1 Pane toggle/popout (B-only)
   ════════════════════════════════════════════════════════════════ */
.pane-ctrl { display: inline-flex; gap: 2px; margin-left: var(--space-2); }
.pane-ctrl-btn {
  background: transparent; border: 0; cursor: pointer;
  padding: 3px 6px; border-radius: 4px;
  color: var(--text-dim); font-size: 13px; line-height: 1;
}
.pane-ctrl-btn:hover { background: var(--surface-2); color: var(--text); }
.pane-ctrl-btn.active { color: var(--itc-accent); background: var(--itc-accent-soft); }

/* Pane controls only visible in layout-b */
body:not(.layout-b) .pane-ctrl { display: none; }

/* Hidden pane state — chỉ ẩn pane trong layout-b */
body.layout-b .pane.pane-hidden { display: none !important; }
/* Grid responsive khi pane bị ẩn */
/* v2.3.10 fix: XOÁ 2 dòng legacy 2-pane override (gây bug "click X chat
   thì khung chuyên gia biến mất" vì grid 2-col đẩy slide vào col=0).
   3-pane grid rules đã định nghĩa đúng ở lines 263-271. */

/* v2.3.5: Popout floating window — MOVE-based, live update qua DOM gốc */
.pane-popout {
  position: fixed;
  min-width: 320px; min-height: 200px;
  background: var(--surface); border: 1px solid var(--itc-accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0,0,0,0.35), 0 4px 12px rgba(6,182,212,0.18);
  display: flex; flex-direction: column; overflow: hidden;
  resize: both;
}
.pane-popout > .pane { flex: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; }
.pane-popout > .pane > .pane-header { background: var(--surface-2); }

/* v2.3.5: Popout custom header bar — drag handle + minimize + close */
.pane-popout-header {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; height: 28px;
  background: linear-gradient(90deg, var(--itc-accent), var(--accent));
  color: white;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.pane-popout-header:active { cursor: grabbing; }
.pane-popout-grip {
  font-size: 14px; opacity: 0.85;
  letter-spacing: -2px;
}
.pane-popout-tag {
  flex: 1; font-size: 11px; font-weight: 700;
  text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
  letter-spacing: 0.02em;
}
.pane-popout-btn {
  background: transparent; border: 0; color: white;
  width: 22px; height: 22px; border-radius: 4px;
  cursor: pointer; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.pane-popout-btn:hover { background: rgba(255,255,255,0.22); }
.pane-popout-btn[data-pop-act="close"]:hover { background: var(--red); }

/* Minimized: collapse to just header bar */
.pane-popout.minimized {
  height: 28px !important;
  resize: none;
  min-height: 28px;
}
.pane-popout.minimized > .pane { display: none; }

/* Hide pane-ctrl inline (đã có popout header rồi — tránh double close button) */
.pane-popout .pane-ctrl { display: none !important; }

/* v2.2: ctx-menu action visual highlight (find acronym, replay) */
.cap.acronym-hl {
  background: var(--itc-accent-soft) !important;
  border-color: var(--itc-accent) !important;
  box-shadow: 0 0 0 2px var(--itc-accent-soft);
  animation: capHl 0.3s ease-out;
}
@keyframes capHl {
  0% { transform: scale(1); }
  50% { transform: scale(1.01); }
  100% { transform: scale(1); }
}

/* ════════════════════════════════════════════════════════════════
   v2.0 P6 — First-visit layout modal + Settings switcher
   ════════════════════════════════════════════════════════════════ */
.layout-modal { z-index: 9000; }
.layout-modal .modal-body { max-width: 760px; }
.layout-modal-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4);
  padding: var(--space-4) 0;
}
.layout-card {
  background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  cursor: pointer; transition: all 0.2s;
  display: flex; flex-direction: column; gap: var(--space-3);
}
.layout-card:hover { border-color: var(--itc-accent); transform: translateY(-2px); }
.layout-card.selected {
  border-color: var(--itc-accent);
  background: var(--itc-accent-soft);
}
.layout-card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.layout-card .lc-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  background: var(--itc-accent); color: white;
  align-self: flex-start;
}
.layout-card p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-dim); }
.layout-card-preview {
  height: 80px; background: var(--surface-2); border-radius: var(--radius-md);
  display: grid; gap: 1px; padding: 4px;
}
.layout-card-preview.lc-b {
  grid-template-columns: 14px 1fr 1fr 0.7fr;
}
.layout-card-preview.lc-c {
  grid-template-columns: 14px 28px 1fr;
}
.layout-card-preview > div { background: var(--bg); border-radius: 2px; }
.layout-card-preview > div:first-child { background: var(--itc-accent); }

/* Settings layout switcher — v2.3.1: 2-column grid trên desktop để fit 1 viewport */
#view-b-settings .view-b-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-3);
  align-content: start;
  padding: var(--space-3) var(--space-4);
}
@media (max-width: 1024px) {
  #view-b-settings .view-b-body {
    grid-template-columns: 1fr;
  }
}
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4);
  margin-bottom: 0;
}
.settings-section h3 { margin: 0 0 var(--space-2); font-size: 13px; font-weight: 600; }
.settings-row {
  display: flex; gap: var(--space-2); align-items: center;
  padding: 4px 0; font-size: 12px;
}
.settings-row .label { width: 110px; color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.settings-row input[type="text"], .settings-row select {
  padding: 4px 8px; font-size: 12px;
}
.layout-radio-group { display: flex; gap: var(--space-2); }
.layout-radio {
  padding: 6px 14px; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius-md);
  cursor: pointer; font-size: 13px;
}
.layout-radio.active {
  background: var(--itc-accent); color: white; border-color: var(--itc-accent);
  font-weight: 600;
}

/* ─────────────── Header ─────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
  min-height: var(--header-h);
}

.brand { display: flex; align-items: center; gap: var(--space-3); }
/* Sub-brand icon: cyan accent per BRAND_STYLE_GUIDE §2.2 + §7.2 (24-28px standalone) */
.brand .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--itc-accent-soft);
  color: var(--itc-accent);
  flex-shrink: 0;
}
.brand .logo svg { display: block; }
/* v2.5.10: ALIA logo riêng — no background wrapper (SVG đã có gradient).
   LIVE dot bottom-right pulse cam khi phiên running (body.session-running). */
.brand .alia-logo {
  background: transparent;
  width: 32px; height: 32px;
  border-radius: 7px;
  overflow: hidden;
}
.brand .alia-logo svg { width: 32px; height: 32px; }
.brand .alia-logo svg circle {
  transition: fill 0.3s, opacity 0.3s;
}
@keyframes aliaLivePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
body.session-running .brand .alia-logo svg circle {
  animation: aliaLivePulse 1.4s ease-in-out infinite;
  fill: #ef4444;   /* đỏ pulse khi phiên running */
}
.brand h1 {
  font-size: 18px;             /* §4.2 text-xl */
  line-height: 24px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand .tagline {
  margin: 0;
  font-size: 11px;             /* §4.2 text-xs */
  line-height: 15px;
  color: var(--text-dim);
}

.header-right { display: flex; align-items: center; gap: 14px; }

.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.presence-bubbles { display: inline-flex; gap: 2px; margin-left: 4px; }
.presence-bubbles .bubble {
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-family: var(--font-en);
  border: 1.5px solid var(--surface);
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.status-pill.idle .dot { background: var(--text-dim); }
.status-pill.listening .dot { background: var(--green); animation: pulse 1.4s ease-in-out infinite; }
.status-pill.loading .dot { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.status-pill.error .dot { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ─────────────── Control panel ─────────────── */
.control-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  flex-shrink: 0;
}
.control-panel details { padding: 6px 0; }
.control-panel summary {
  cursor: pointer; padding: 6px 0; font-size: 13px;
  color: var(--text-dim); font-weight: 500; list-style: none;
  outline: none; user-select: none;
}
.control-panel summary::-webkit-details-marker { display: none; }
.controls {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px;
  padding: 10px 0; align-items: end;
}
.controls label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12px;
  color: var(--text-dim); font-weight: 500;
}
.controls input, .controls select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
}
.controls input:focus, .controls select:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.actions { display: flex; gap: 8px; }

button {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 500;
  transition: all 0.15s ease;
}
button:hover:not(:disabled) { background: var(--surface-2); transform: translateY(-1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); color: white; border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(0.92); }
.link-btn {
  background: transparent; border: 0; color: var(--accent);
  padding: 2px 4px; font-size: 12px; cursor: pointer; text-decoration: underline;
}

/* ─────────────── Mobile tabs (hidden on desktop) ─────────────── */
.mobile-tabs {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 12px;
  font-weight: 600;
  color: var(--text-dim);
  position: relative;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn .badge {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px;
  background: var(--red); color: white; font-size: 10px; font-weight: 800;
  border-radius: 9px; padding: 0 5px; margin-left: 4px; vertical-align: middle;
}
.tab-btn .badge:empty { display: none; }

/* ─────────────── 2-pane layout ─────────────── */
.two-pane {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.7fr);
  gap: 1px;
  background: var(--border);
  overflow: hidden;
}
.pane {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.pane-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pane-header h2 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text-dim); }
.pane-toggles { display: flex; gap: 12px; }

/* ─────────────── Captions area ─────────────── */
.captions {
  flex: 1; overflow-y: auto; padding: 18px;
  scroll-behavior: smooth;
}
.placeholder {
  max-width: 520px; margin: 64px auto; text-align: center; color: var(--text-dim);
  padding: var(--space-6) var(--space-4);
}
.placeholder-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 72px; height: 72px; border-radius: var(--radius-xl);
  background: var(--itc-accent-soft);
  color: var(--itc-accent);
  margin: 0 auto var(--space-4);
}
.placeholder.small .placeholder-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
}
.placeholder h3 {
  font-weight: 600;
  font-size: 18px;             /* §4.2 text-xl */
  line-height: 24px;
  color: var(--text);
  margin: 0 0 var(--space-2);
}
.placeholder p {
  font-size: 13px;             /* §4.2 text-sm */
  line-height: 1.6;
  margin: 0 auto var(--space-2);
  max-width: 420px;
}
.placeholder.small { margin: 40px auto; }
.placeholder.small p { font-size: 13px; }
.placeholder .hint {
  margin-top: var(--space-4); font-size: 12px;
  padding: var(--space-2) var(--space-4);
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 999px;
  display: inline-block;
  border: 1px solid var(--border);
}
.placeholder .hint-sub {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.85;
}

/* v2.3.8 — Modern caption row: compact, no chrome, hover-reveal actions
   ──────────────────────────────────────────────────────────────────
   Khác cũ: bỏ card chrome (border + shadow + radius + bg). Mỗi caption là
   1 row text với subtle separator + hover background. VN primary, EN
   secondary dim. Actions hover-reveal. Latest cap có cyan accent. Caps
   xa fade dần. */

.captions { padding: 0 8px 16px; }

.cap {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
  transition: background 0.15s, opacity 0.25s;
  position: relative;
}
.cap:hover { background: var(--surface-2); }
/* Latest LIVE caption — cyan accent + bg subtle để draw attention */
.cap.live {
  border-left: 3px solid var(--itc-accent);
  background: linear-gradient(to right, var(--itc-accent-soft) 0%, transparent 60%);
}
.cap.live::after {
  content: "● LIVE";
  position: absolute; top: 4px; right: 8px;
  font-size: 9px; font-weight: 700;
  color: var(--itc-accent); letter-spacing: 0.05em;
  font-family: var(--font-mono);
  animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* v2.7.0 — Streaming Whisper partial caption pill.
 * Hiển thị sticky-like ở cuối captions area khi speaker đang nói.
 * Italic EN text + pulse animation = trải nghiệm realtime cho user. */
.cap-partial-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  margin: 8px 6px;
  background: linear-gradient(135deg,
    var(--itc-accent-soft, rgba(6,182,212,0.12)) 0%,
    var(--itc-accent-soft, rgba(6,182,212,0.06)) 100%);
  border: 1px solid var(--itc-accent, #06b6d4);
  border-left: 3px solid var(--itc-accent, #06b6d4);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text, #1a1a20);
  animation: partialPulse 1.6s ease-in-out infinite;
  position: relative;
}
.cap-partial-icon {
  font-size: 18px;
  animation: partialMicPulse 1s ease-in-out infinite;
}
.cap-partial-label {
  font-weight: 600;
  font-size: 11px;
  color: var(--itc-accent-bold, #0891b2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cap-partial-text {
  font-style: italic;
  flex: 1;
  color: var(--text-dim, #4a4a5a);
}
@keyframes partialPulse {
  0%, 100% { background: linear-gradient(135deg, var(--itc-accent-soft, rgba(6,182,212,0.12)) 0%, var(--itc-accent-soft, rgba(6,182,212,0.06)) 100%); }
  50%      { background: linear-gradient(135deg, var(--itc-accent-soft, rgba(6,182,212,0.20)) 0%, var(--itc-accent-soft, rgba(6,182,212,0.10)) 100%); }
}
@keyframes partialMicPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.15); opacity: 0.7; }
}

.cap.new { animation: capSlideIn 0.25s ease-out; }
@keyframes capSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.cap.stale { opacity: 0.6; }
.cap.stale:hover { opacity: 1; }

.cap.bookmarked { background: linear-gradient(to right, rgba(250,204,21,0.15) 0%, transparent 50%); }
body.dark .cap.bookmarked { background: linear-gradient(to right, rgba(250,204,21,0.10) 0%, transparent 50%); }
.cap.bookmarked .cap-time::before { content: "⭐ "; color: #f59e0b; }

/* Time chip — small mono, top-aligned */
.cap-time {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-dim);
  padding: 4px 6px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  text-align: center;
  cursor: help;
  align-self: start;
  margin-top: 2px;
  white-space: nowrap;
  flex-shrink: 0;
}
.cap.live .cap-time {
  background: var(--itc-accent);
  color: white; border-color: var(--itc-accent);
  font-weight: 700;
}

/* Text column: VN primary lớn, EN secondary dim */
.cap-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cap-line { line-height: 1.5; }
.cap-line.vn {
  font-family: var(--font-vn);
  font-size: 15px; font-weight: 500;
  color: var(--text);
}
.cap-line.en {
  font-family: var(--font-en);
  font-size: 12px; font-style: italic;
  color: var(--text-dim);
  opacity: 0.85;
}
/* Extra lang lines (FR/DE/ZH/JA) compact */
.cap-line.lang-fr, .cap-line.lang-de, .cap-line.lang-zh,
.cap-line.lang-ja, .cap-line.lang-ko, .cap-line.lang-es {
  font-size: 11px; opacity: 0.75;
  padding: 1px 6px; border-radius: 3px;
}
.cap-line.lang-fr { color: #6366f1; background: rgba(99,102,241,0.06); }
.cap-line.lang-de { color: #d97706; background: rgba(217,119,6,0.06); }
.cap-line.lang-zh { color: #b91c1c; background: rgba(185,28,28,0.06); }
.cap-line.lang-ja { color: #db2777; background: rgba(219,39,119,0.06); }
.cap-line .lang-tag {
  font-size: 8px; font-weight: 700; letter-spacing: 0.05em;
  background: rgba(0,0,0,0.12); color: inherit; padding: 0 4px;
  border-radius: 2px; margin-right: 4px;
  vertical-align: middle;
}

/* Actions — hover-reveal, no always-visible buttons */
.cap-actions {
  display: inline-flex; gap: 2px;
  opacity: 0; transform: translateX(4px);
  transition: opacity 0.15s, transform 0.15s;
  align-self: center;
  flex-shrink: 0;
}
.cap:hover .cap-actions { opacity: 1; transform: translateX(0); }
.cap-act-btn {
  width: 26px; height: 26px;
  border: 0; background: transparent;
  border-radius: 50%;
  font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  transition: all 0.12s;
}
.cap-act-btn:hover {
  background: var(--itc-accent-soft);
  color: var(--itc-accent);
  transform: scale(1.15);
}
.cap.bookmarked .cap-act-btn[data-act="star"] {
  opacity: 1; color: #f59e0b;
}

/* Time block mini divider (mỗi 60s) */
.cap-time-block {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 12px 6px;
  pointer-events: none;
}
.cap-time-block-line {
  flex: 1; height: 1px; background: var(--border);
  opacity: 0.5;
}
.cap-time-block-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700; color: var(--text-dim);
  letter-spacing: 0.05em;
  padding: 2px 8px; background: var(--surface);
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* EN/VN toggles từ legacy still apply */
body.hide-en .cap .cap-line.en { display: none; }
body.hide-vn .cap .cap-line.vn { display: none; }
/* v2.3.19: hide-slides ẩn element + collapse grid row 2 (không để khoảng trống) */
body.hide-slides .slide-strip { display: none; }
body.layout-b.hide-slides #view-b-live.active { grid-template-rows: 1fr 0 !important; }

/* Mobile: compact further */
@media (max-width: 720px) {
  .cap { grid-template-columns: 44px 1fr auto; gap: 6px; padding: 5px 8px; }
  .cap-line.vn { font-size: 14px; }
  .cap-line.en { font-size: 11px; }
  .cap-time { font-size: 10px; padding: 2px 4px; }
}

/* ─────────────── Slide strip ─────────────── */
.slide-strip {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 10px 14px 14px;
  flex-shrink: 0;
}
.slide-strip-header {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-dim); font-weight: 600;
  margin-bottom: 8px;
}
.slide-strip-header > div { display: flex; gap: 4px; }
.slide-thumbs {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px;
  scroll-behavior: smooth;
}
.slide-thumbs::-webkit-scrollbar { height: 6px; }
.slide-thumbs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.slide-thumb {
  flex-shrink: 0;
  width: 120px; height: 68px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.15s;
}
.slide-thumb:hover { border-color: var(--accent); transform: translateY(-2px); }
.slide-thumb.new { border-color: var(--accent); animation: slideIn 0.3s; }
.slide-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.slide-thumb .seq-label {
  position: absolute; bottom: 2px; left: 2px;
  background: rgba(0,0,0,0.6); color: white;
  font-size: 10px; padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace;
}
.slide-thumb .ocr-flag {
  position: absolute; top: 2px; right: 2px;
  font-size: 10px;
  background: var(--green); color: white;
  padding: 1px 4px; border-radius: 3px;
}
.slide-thumbs:empty::after {
  content: 'Chưa có slide nào — bấm 📸 để chụp ngay';
  color: var(--text-dim); font-size: 12px; font-style: italic;
  padding: 16px;
}

/* ─────────────── Slide modal ─────────────── */
.slide-modal-body { max-width: 1100px; max-height: 92vh; }
.slide-modal-content {
  padding: 0; display: flex; flex-direction: column;
  overflow: hidden;
}
.slide-modal-content img {
  max-width: 100%; max-height: 65vh; object-fit: contain;
  background: black;
  display: block;
}
.slide-ocr-block {
  padding: 12px 18px; border-top: 1px solid var(--border);
  overflow-y: auto; max-height: 25vh;
}
.slide-ocr-block summary {
  cursor: pointer; font-size: 13px; color: var(--text-dim); font-weight: 600;
}
.slide-ocr-en, .slide-ocr-vn {
  margin-top: 8px;
  font-size: 13px; white-space: pre-wrap;
  padding: 8px 10px; border-radius: 6px;
}
.slide-ocr-en { background: var(--accent-soft); color: var(--en); font-family: var(--font-en); }
.slide-ocr-vn { background: var(--vn-bg); color: var(--text); border-left: 3px solid var(--vn); }
.slide-ocr-en:empty, .slide-ocr-vn:empty { display: none; }

/* ═════════════════════════════════════════════════════════════
   v0.4.0 — CHAT NÂNG CẤP
   ═════════════════════════════════════════════════════════════ */

/* Header icon buttons (PiP, snap) */
.header-btn { padding: 6px 10px; font-size: 16px; }
/* Icon-only nút: mặc định KHÔNG viền — chỉ hiện viền pill khi hover/focus.
   Áp dụng cho mọi .icon-btn trong app (header, chat input, slide strip…). */
.icon-btn {
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  padding: 6px 10px; font-size: 16px; cursor: pointer; line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover:not(:disabled),
.icon-btn:focus-visible {
  background: var(--surface-2);
  border-color: var(--border);
  transform: translateY(-1px);
}
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* Active/pressed state — nút đang mở popup (vd: emoji picker, presence dropdown) */
.icon-btn.is-active {
  background: var(--surface-2);
  border-color: var(--accent);
}

/* ───── Channel strip ───── */
.channel-strip {
  display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  flex-shrink: 0; scrollbar-width: thin;
}
.ch-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 13px;
  white-space: nowrap; transition: all 0.15s;
}
.ch-btn:hover { background: var(--surface-2); }
.ch-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.ch-btn .ch-icon {
  font-weight: 700; font-family: ui-monospace, Menlo, monospace; opacity: 0.7;
}
.ch-btn.active .ch-icon { opacity: 1; }
.ch-btn.dm .ch-icon { font-size: 14px; }
.ch-btn .ch-badge {
  background: var(--red); color: white; font-size: 10px; font-weight: 800;
  border-radius: 9px; padding: 1px 5px; min-width: 16px; text-align: center;
}
.ch-btn .ch-badge:empty { display: none; }
.ch-btn .ch-close {
  border: 0; background: transparent; opacity: 0.5; cursor: pointer;
  padding: 0 0 0 4px; font-size: 11px; color: inherit;
}
.ch-btn .ch-close:hover { opacity: 1; }
/* v2.9.8: liên hệ DM Claude (pinned bot) — viền tím nhận diện, không có nút đóng */
.ch-btn.bot {
  border-color: #a855f7;
  background: color-mix(in srgb, #a855f7 12%, transparent);
}
.ch-btn.bot .ch-icon { opacity: 1; }
.ch-btn.bot.active {
  background: #a855f7; color: #fff; border-color: #a855f7;
}
/* v2.24.21: ⋯ menu button trên bot chip — ẩn cho đến khi hover chip */
.ch-btn .ch-menu {
  border: 0; background: transparent; cursor: pointer;
  padding: 0 2px; font-size: 14px; font-weight: 700;
  color: inherit; opacity: 0; transition: opacity 0.12s;
  line-height: 1; letter-spacing: 1px;
}
.ch-btn:hover .ch-menu { opacity: 0.7; }
.ch-btn .ch-menu:hover { opacity: 1 !important; }
.ch-btn.active .ch-menu { opacity: 0.6; }
.ch-btn.active:hover .ch-menu { opacity: 1; }
/* v2.24.21: dropdown menu DM actions */
.dm-menu {
  position: fixed; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 180px; display: flex; flex-direction: column; gap: 2px;
}
.dm-menu button {
  border: 0; background: transparent; cursor: pointer;
  padding: 8px 12px; border-radius: 7px; text-align: left;
  font-size: 13px; color: var(--text); white-space: nowrap;
  transition: background 0.1s;
}
.dm-menu button:hover { background: var(--surface-2); }
.dm-menu button.danger { color: var(--red, #ef4444); }
.dm-menu button.danger:hover { background: color-mix(in srgb, var(--red, #ef4444) 10%, transparent); }

/* ───── Hover toolbar trên caption ───── */
.cap { position: relative; }
.cap .hover-toolbar {
  position: absolute; top: 6px; right: 6px;
  display: none; gap: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px; box-shadow: var(--shadow);
}
.cap:hover .hover-toolbar { display: flex; }
.cap .hover-toolbar button {
  border: 0; background: transparent; padding: 3px 6px;
  font-size: 12px; cursor: pointer; border-radius: 3px;
}
.cap .hover-toolbar button:hover { background: var(--surface-2); }

/* Ẩn actions-mini cũ vì hover toolbar đã thay */
.cap .actions-mini { display: none; }
.cap { grid-template-columns: 64px 1fr; }
@media (max-width: 900px) { .cap { grid-template-columns: 50px 1fr; } }

/* ───── Hover toolbar trên chat message ───── */
.chat-msg { position: relative; }
.chat-msg .msg-toolbar {
  position: absolute; top: -10px; right: 10px;
  display: none; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px; box-shadow: var(--shadow);
  z-index: 5;
}
.chat-msg:hover .msg-toolbar { display: flex; }
.chat-msg.mine .msg-toolbar { right: auto; left: 50px; }
.chat-msg .msg-toolbar button {
  border: 0; background: transparent; padding: 3px 6px;
  font-size: 13px; cursor: pointer; border-radius: 3px;
}
.chat-msg .msg-toolbar button:hover { background: var(--surface-2); }

/* v2.3.30 — Claude bot styling (response cho @claude mention) */
.chat-msg.bot-claude .bubble {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.10) 0%, rgba(168, 85, 247, 0.04) 100%);
  border-left: 3px solid #a855f7;
}
/* v2.10.1: avatar bot = chữ "C" trên nền tím (KHÔNG còn emoji 🤖 — user báo
   trông giống "quả táo" chèn vào tin). Gỡ ::before content + visibility:hidden →
   initials hiện bình thường như avatar thường. Vẫn giữ màu tím nhận diện Claude. */
.chat-msg.bot-claude .avatar {
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%) !important;
  color: white !important;
  font-weight: 700;
}
.chat-msg.bot-claude .bot-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  background: #a855f7;
  color: white;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

/* ───── Reactions Zalo-style — float pills overlap bottom of bubble ─────
 *
 * Khác cách cũ: reactions không nằm TRONG bubble, mà là SIBLING của bubble
 * trong .bubble-col. Position dùng negative margin-top để overlap rìa dưới
 * bubble như Zalo/Messenger/iMessage.
 */
.bubble-col {
  display: flex; flex-direction: column;
  min-width: 0;          /* prevent overflow */
}
.reactions {
  display: inline-flex; flex-wrap: wrap; gap: 3px;
  margin-top: -10px;        /* overlap bottom rìa của bubble */
  margin-left: 10px;        /* indent từ rìa trái bubble (others) */
  align-self: flex-start;   /* không stretch full width */
  z-index: 2;               /* trên bubble shadow */
  position: relative;
}
.chat-msg.mine .reactions {
  margin-left: 0;
  margin-right: 10px;
  align-self: flex-end;     /* mine: bottom-left của bubble (avatar bên phải) */
}
.reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font-size: 11px;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  line-height: 1.2;
}
.reaction:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.16);
}
.reaction.mine {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.reaction .count {
  font-weight: 700;
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 1px;
}
.reaction.mine .count { color: var(--accent); }

/* ───── Emoji picker ───── */
.emoji-picker {
  position: absolute; bottom: 60px; right: 70px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 8px; display: grid; grid-template-columns: repeat(8, 32px);
  gap: 2px; z-index: 20; max-width: 280px;
}
.emoji-picker.hidden { display: none; }
.emoji-picker button {
  width: 32px; height: 32px; border: 0; background: transparent;
  cursor: pointer; font-size: 20px; border-radius: 4px; padding: 0;
}
.emoji-picker button:hover { background: var(--surface-2); }

/* ───── File attach row (preview trước khi gửi) ───── */
.chat-attach-row {
  display: flex; gap: 6px; padding: 6px 12px; flex-wrap: wrap;
  background: var(--accent-soft); border-top: 1px solid var(--border);
}
.chat-attach-row.hidden { display: none; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px;
}
.attach-chip.uploading { opacity: 0.6; }
.attach-chip .remove {
  border: 0; background: transparent; padding: 0 0 0 4px; cursor: pointer; font-size: 13px;
}
.attach-chip .preview-img {
  width: 24px; height: 24px; object-fit: cover; border-radius: 3px;
}

/* ───── Drop overlay ───── */
.drop-overlay {
  position: absolute; inset: 0;
  background: rgba(13, 110, 253, 0.15);
  border: 3px dashed var(--accent);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 30;
}
.drop-overlay.hidden { display: none; }
.drop-msg {
  background: var(--surface); padding: 16px 24px; border-radius: var(--radius);
  font-weight: 700; box-shadow: var(--shadow);
}

/* ───── Attachment trong message ───── */
.msg-attachments {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.msg-attach-img, .msg-attach-vid {
  max-width: 280px; max-height: 200px;
  border-radius: 6px; cursor: pointer;
}
.msg-attach-aud { width: 240px; }
.msg-attach-file {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px; text-decoration: none; color: var(--text);
}
.msg-attach-file:hover { background: var(--accent-soft); }

/* ───── Markdown render trong text ───── */
.text strong { font-weight: 700; }
.text em { font-style: italic; }
.text code {
  background: var(--surface-2); padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}
.text pre {
  background: var(--surface-2); padding: 8px 10px; border-radius: 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
  overflow-x: auto; margin: 4px 0;
}
.text del { opacity: 0.5; }

/* ───── Edited indicator + deleted message ───── */
.chat-msg .edited-mark { font-size: 10px; color: var(--text-dim); margin-left: 6px; }
.chat-msg.deleted .bubble { opacity: 0.4; font-style: italic; }
.chat-msg.deleted .text::before { content: '(tin nhắn đã bị xoá)'; color: var(--text-dim); }

/* ───── Input row icon buttons ───── */
/* Icon-only nút trong chat input: nén padding để 📎 + 😀 sát vào nhau, gọn cho mobile. */
.chat-input-row .icon-btn {
  flex-shrink: 0;
  padding: 4px 6px;
  font-size: 18px;
  line-height: 1;
}
/* Kéo icon-btn về cùng cluster — general sibling vì có <input type="file" hidden> chen giữa */
.chat-input-row .icon-btn ~ .icon-btn { margin-left: -6px; }
/* Đẩy chat input (text) cách cluster icon đúng 2px thay vì 8px gap mặc định */
.chat-input-row .icon-btn ~ input[type="text"] { margin-left: -4px; }

/* v2.10.2: hàng nút ô nhập chỉ giữ ⋯ (Khác). Ẩn 📎 + 😀 standalone — đính
   kèm/emoji vẫn mở được qua popover ⋯ (zaloFileBtn/zaloEmojiBtn ủy quyền lại
   #attachBtn/#emojiBtn). KHÔNG xóa DOM: handler bind cứng vào id, xóa sẽ crash
   init. Reset margin-left âm trên ⋯ vì các icon-btn trước đã display:none. */
.chat-input-row #attachBtn,
.chat-input-row #emojiBtn { display: none !important; }
.chat-input-row #chatMoreBtn { margin-left: 0 !important; }

/* ───── Presence bubble click ───── */
.presence-bubbles .bubble { cursor: pointer; transition: transform 0.15s; }
.presence-bubbles .bubble:hover { transform: scale(1.2); }

/* ───── Picture-in-Picture / focus mode ───── */
body.pip-mode header,
body.pip-mode .control-panel,
body.pip-mode footer,
body.pip-mode .slide-strip,
body.pip-mode .mobile-tabs,
body.pip-mode #captions-pane {
  display: none !important;
}
body.pip-mode .two-pane {
  grid-template-columns: 1fr; background: var(--bg);
}
body.pip-mode .chat-pane { display: flex !important; }

/* ─── Khi chat pane đã được TÁCH sang cửa sổ PiP riêng ───
 * Trang chính: captions mở full width, không để khoảng trống.
 * documentPictureInPicture moves chat-pane sang PiP window — DOM main không còn chat-pane,
 * nhưng grid vẫn cấp space → phải đổi grid về 1 cột. */
body.chat-in-pip .two-pane {
  grid-template-columns: 1fr !important;
}

/* Cửa sổ PiP — full screen layout chỉ cho chat pane */
body.pip-window {
  height: 100vh; overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg); margin: 0;
}
body.pip-window .chat-pane {
  flex: 1; display: flex !important;
  height: 100vh; min-height: 0;
}

/* Exit focus mode button — chỉ hiện khi pip-mode bật */
.exit-focus-btn {
  display: none;
  position: fixed; top: 8px; right: 8px;
  padding: 4px 10px; font-size: 12px;
  background: var(--accent); color: white; border: 0;
  border-radius: 6px; cursor: pointer; z-index: 200;
  box-shadow: var(--shadow);
}
body.pip-mode .exit-focus-btn { display: block; }

/* Info toast (cho snap helper, không phải copy toast) */
.info-toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--surface); color: var(--text);
  padding: 14px 20px; border-radius: 8px; z-index: 1000;
  font-size: 13px; box-shadow: var(--shadow);
  max-width: 520px; line-height: 1.5;
  border: 1px solid var(--accent);
  display: flex; flex-direction: column; gap: 8px;
}
.info-toast .toast-title { font-weight: 700; color: var(--accent); }
.info-toast a { color: var(--accent); font-weight: 600; }
.info-toast .toast-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: 0; cursor: pointer; opacity: 0.5;
}
.info-toast .toast-close:hover { opacity: 1; }

/* ═════════════════════════════════════════════════════════════
   v0.5.0 — Role-based UI (host vs team)
   ═════════════════════════════════════════════════════════════ */

/* Ẩn mọi host-only UI cho team */
body:not(.is-host) [data-host-only] { display: none !important; }

/* No-flash: nếu user đã có trong localStorage, ẩn modal name ngay từ parse HTML
 * (trước khi JS chạy ensureUser). Inline script ở head set html.has-user-pre. */
html.has-user-pre #nameModal { display: none !important; }
html.dark-pre body { background: #0b1220; color: #e6edf7; }  /* dark color flash prevention */

/* Role badge ở header */
/* v2.24.21: role-badge gộp vào my-user chip — không còn standalone pill */
.role-badge {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim); line-height: 1.4;
}
body.is-host .role-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white; border-color: transparent;
}
.role-badge::before { content: none; }

/* ═════════════════════════════════════════════════════════════
   Phase 6 — Post-session export UI
   ═════════════════════════════════════════════════════════════ */

#sessionsList li {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 14px 20px;
}
#sessionsList li:hover {
  background: var(--surface-2);
}
.session-row-main { flex: 1; min-width: 0; }
.session-row-actions {
  display: flex; gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}
/* Primary action prominent, danger secondary (smaller) */
.session-row-actions .export-btn { flex: 1; min-width: 180px; }
.session-row-actions .danger-btn { padding: 8px 12px; flex-shrink: 0; }
@media (max-width: 600px) {
  .session-row-actions { flex-direction: column; align-items: stretch; }
  .session-row-actions button { width: 100%; }
}
.session-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.rec-badge {
  display: inline-block; padding: 1px 6px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px; font-size: 11px; font-weight: 600; margin-left: 6px;
}
.export-btn {
  padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.export-block {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.export-block:empty { display: none; }

.export-progress {
  background: var(--surface-2);
  border-radius: 6px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.export-step {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
}
.export-step .step-label { flex: 1; font-weight: 500; }
.export-step .step-detail { color: var(--text-dim); font-size: 12px; }
.export-step.running { color: var(--amber); }
.export-step.done { color: var(--green); }
.export-step.failed { color: var(--red); }
.export-step.skipped { color: var(--text-dim); opacity: 0.7; }

.export-outputs {
  background: var(--accent-soft);
  border-radius: 6px; padding: 8px 10px;
}
.export-outputs-label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px;
}
.export-files {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.export-file {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
  text-decoration: none; font-size: 13px; color: var(--text);
  transition: all 0.15s;
}
.export-file:hover { background: var(--accent); color: white; border-color: var(--accent); }
.export-file .size {
  font-size: 11px; color: var(--text-dim); margin-left: 4px;
}
.export-file:hover .size { color: rgba(255,255,255,0.8); }

/* ─── Danger button (xoá) ─── */
.danger-btn {
  background: transparent; color: var(--red);
  border: 1px solid var(--red); border-radius: 6px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.danger-btn:hover:not(:disabled) {
  background: var(--red); color: white;
}
.danger-btn:disabled {
  opacity: 0.3; border-color: var(--text-dim); color: var(--text-dim); cursor: not-allowed;
}

/* ─── Confirm dialog ─── */
.confirm-overlay { z-index: 200; }
.confirm-body { border: 2px solid var(--red); }
.confirm-message ul { font-size: 13px; }
.confirm-message code {
  background: var(--surface-2); padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}
.confirm-message p { margin: 6px 0; }
#confirm-typing-input {
  font-family: ui-monospace, Menlo, monospace;
  text-transform: uppercase;
}

/* ───── Presence dropdown ───── */
.presence { position: relative; cursor: pointer; }
.presence:hover { background: var(--accent-soft); }
.presence-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(10,25,41,0.25);
  width: 340px; max-height: 70vh; z-index: 150;
  display: flex; flex-direction: column;
  animation: dropdownIn 0.12s ease-out;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 720px) {
  /* Trên mobile: full-width sheet từ dưới lên */
  .presence-dropdown {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; max-height: 80vh;
    border-radius: 16px 16px 0 0;
    animation: sheetUp 0.18s ease-out;
  }
  @keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}
.presence-dropdown.hidden { display: none; }
.presence-dropdown-header {
  display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border);
}
.presence-dropdown-header input {
  flex: 1; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 13px;
}
.presence-list {
  list-style: none; margin: 0; padding: 4px;
  overflow-y: auto; flex: 1;
}
.presence-item {
  margin: 0; border-radius: 6px;
}
.presence-item label {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; cursor: pointer; width: 100%;
  border-radius: 6px;
}
.presence-item:hover label { background: var(--surface-2); }
.presence-item.selected label { background: var(--accent-soft); }
.presence-item input { accent-color: var(--accent); }
.avatar-mini {
  width: 26px; height: 26px; border-radius: 50%;
  color: white; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase; flex-shrink: 0;
}
.presence-item .username { font-weight: 500; }
.presence-list .empty { padding: 16px; color: var(--text-dim); font-style: italic; text-align: center; }
.presence-dropdown-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px; border-top: 1px solid var(--border);
}
.selected-count { font-size: 13px; color: var(--text-dim); }

/* ───── @ mention autocomplete popup ─────
 * Position: JS-driven (getBoundingClientRect của chat input). CSS chỉ define
 * style + hidden. Vị trí cụ thể (top/left) do showMentionPopup() set inline.
 */
.mention-popup {
  position: fixed;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(10,25,41,0.2);
  min-width: 220px; max-width: 320px; padding: 4px;
  z-index: 100;
  animation: ctxIn 0.08s ease-out;
}
.mention-popup.hidden { display: none; }
.mention-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 6px 10px; border: 0; background: transparent;
  text-align: left; cursor: pointer; font-size: 13px;
  border-radius: 4px; color: var(--text); font-family: inherit;
}
.mention-item.active, .mention-item:hover {
  background: var(--accent-soft);
}

/* ───── Context menu (right-click) ───── */
.context-menu {
  position: fixed; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  min-width: 240px; max-width: 340px;
  max-height: 80vh; overflow-y: auto;
  padding: 6px; user-select: none;
  animation: ctxIn 0.08s ease-out;
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.context-menu.hidden { display: none; }
.context-menu hr {
  margin: 6px 2px; border: 0; border-top: 1px solid var(--border);
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 12px; border: 0; background: transparent;
  border-radius: 6px; cursor: pointer; text-align: left;
  font-size: 13px; color: var(--text); font-family: inherit;
  transition: background 0.08s;
}
.ctx-item:hover:not(:disabled), .ctx-item:focus:not(:disabled) {
  background: var(--accent); color: white; outline: none;
}
.ctx-item:hover:not(:disabled) .ctx-shortcut,
.ctx-item:focus:not(:disabled) .ctx-shortcut {
  background: rgba(255,255,255,0.2); color: white;
}
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover:not(:disabled),
.ctx-item.danger:focus:not(:disabled) {
  background: var(--red); color: white;
}
.ctx-item:disabled { opacity: 0.35; cursor: not-allowed; }
.ctx-icon { width: 18px; flex-shrink: 0; text-align: center; }
.ctx-label { flex: 1; }
.ctx-shortcut {
  font-size: 11px; color: var(--text-dim);
  font-family: ui-monospace, Menlo, monospace;
  background: var(--surface-2); padding: 1px 6px; border-radius: 3px;
}

/* ═════════════════════════════════════════════════════════════
   v0.8 — Avatar upload (image thật trong circle)
   ═════════════════════════════════════════════════════════════ */

/* Avatar circle có img → ẩn initials, fit cover */
.avatar.has-img, .avatar-mini.has-img, .bubble-presence.has-img,
.presence-bubbles .bubble.has-img {
  overflow: hidden;
  position: relative;
}
.avatar img, .avatar-mini img, .presence-bubbles .bubble img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Avatar preview trong name modal — center layout, ảnh là focal point */
.avatar-pick-row {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 4px 0 8px;
}
.avatar-preview {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 36px; font-weight: 700;
  font-family: var(--font-en); text-transform: uppercase;
  overflow: hidden; flex-shrink: 0;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border), 0 4px 12px rgba(0,0,0,0.08);
  position: relative;
  cursor: pointer;
  transition: transform 0.15s;
}
.avatar-preview:hover {
  transform: scale(1.04);
}
.avatar-preview::after {
  content: '📷';
  position: absolute; bottom: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.avatar-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.avatar-pick-actions {
  display: flex; gap: 8px; align-items: center;
  font-size: 12px;
}
.avatar-pick-row .hint {
  margin: 0; font-size: 11px; color: var(--text-dim);
  text-align: center;
}
.avatar-pick-actions .link-btn {
  padding: 4px 10px; background: var(--surface-2); border-radius: 6px;
  border: 1px solid var(--border); color: var(--text);
  text-decoration: none; font-weight: 500;
}
.avatar-pick-actions .link-btn:hover { background: var(--accent-soft); border-color: var(--accent); }


/* ─────────────── Chat pane ─────────────── */
.chat-header { gap: 12px; flex-wrap: wrap; }
.my-user {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px;
  font-weight: 600; color: var(--text);
}
.my-color {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); display: inline-block;
}

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px; scroll-behavior: smooth;
}

.chat-msg {
  margin-bottom: 14px;            /* tăng gap vì reactions overlap bottom */
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
}
.chat-msg .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  color: white; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); text-transform: uppercase;
}
.chat-msg .bubble {
  background: var(--chat-other-bg);
  padding: 8px 12px;
  border-radius: 12px 12px 12px 4px;
  word-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}
.chat-msg .meta {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
  font-size: 12px;
}
.chat-msg .meta .user { font-weight: 700; }
.chat-msg .meta .ts { color: var(--text-dim); font-size: 11px; font-family: ui-monospace, Menlo, monospace; }
.chat-msg .text { white-space: pre-wrap; }
.chat-msg .text a { color: var(--accent); }

.chat-msg.mine {
  grid-template-columns: 1fr 28px;
}
.chat-msg.mine .avatar { order: 2; }
.chat-msg.mine .bubble {
  background: var(--chat-mine-bg);
  border-radius: 12px 12px 4px 12px;
}
.chat-msg.mine .meta { justify-content: flex-end; }

/* v2.15.10: bubble dịch ngược viền cam — transparency log VI→target cho cả đội */
.chat-msg.chat-reverse .bubble {
  border-left: 3px solid var(--amber);
  background: rgba(250, 204, 21, 0.08);
}
.chat-msg.chat-reverse.mine .bubble {
  border-left: none;
  border-right: 3px solid var(--amber);
}
.chat-msg.chat-reverse .bubble::before {
  content: "↔ DỊCH NGƯỢC";
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--amber);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.chat-msg .reply-ref {
  font-size: 12px;
  border-left: 2px solid var(--accent);
  padding: 2px 8px;
  margin-bottom: 4px;
  opacity: 0.85;
  background: var(--surface);
  border-radius: 4px;
  color: var(--text-dim);
  display: flex; flex-direction: column; gap: 2px;
}
.chat-msg .reply-ref .ref-en { color: var(--en); font-family: var(--font-en); font-size: 11px; }
.chat-msg .reply-ref .ref-vn { color: var(--text); font-size: 12px; }
.chat-msg .reply-ref .ref-chat { color: var(--text); font-size: 12px; font-style: italic; }

.chat-msg.system { grid-template-columns: 1fr; text-align: center; }
.chat-msg.system .bubble {
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
  padding: 4px;
}

.typing-line {
  padding: 0 16px 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  min-height: 18px;
}
.typing-line .dot-pulse::after {
  content: ' …';
  animation: typing 1.4s linear infinite;
}
@keyframes typing { 0%{content:' .'} 33%{content:' ..'} 66%{content:' ...'} }

.chat-reply-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: var(--accent-soft);
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.chat-reply-bar.hidden { display: none; }
.chat-reply-bar .reply-label { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.chat-reply-bar .reply-preview {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.chat-reply-bar .reply-cancel {
  background: transparent; border: 0; padding: 0; font-size: 14px; opacity: 0.6;
}

.chat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input,
.chat-input-row textarea {
  flex: 1; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; font-family: inherit;
  line-height: 1.5;
  /* v2.3.25 textarea: multi-line + auto-resize via JS */
  resize: none;
  min-height: 36px;
  max-height: 144px;
  overflow-y: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.chat-input-row input:focus,
.chat-input-row textarea:focus {
  outline: none;
  border-color: var(--itc-accent);
  box-shadow: 0 0 0 3px var(--itc-accent-soft);
}
.chat-input-row button { border-radius: 18px; padding: 8px 18px; flex-shrink: 0; }

/* Align baseline khi textarea grow nhiều dòng */
.chat-input-row { align-items: flex-end; }

/* ─────────────── Footer ─────────────── */
footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px; background: var(--surface); border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-dim); flex-shrink: 0;
}
.toggles { display: flex; gap: 16px; align-items: center; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  font-size: 12px;
}
/* v2.3.16: respect HTML hidden attribute (legacy CSS override mất tác dụng) */
.toggle[hidden] { display: none !important; }
.toggle input { width: 14px; height: 14px; accent-color: var(--accent); }
.meta { display: flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.sep { opacity: 0.4; }

/* ─────────────── Modal ─────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(10,25,41,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-body {
  background: var(--surface); border-radius: var(--radius); padding: 0;
  max-width: 600px; width: 90%; max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column;
}
.modal-body.small { max-width: 420px; }
.modal-body header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  box-shadow: none; min-height: auto; padding: 14px 20px;
}
.modal-body header h2 { margin: 0; font-size: 16px; }
.modal-body .close {
  background: transparent; border: 0; font-size: 18px; cursor: pointer; color: var(--text-dim);
}
.modal-content {
  padding: 18px 20px; display: flex; flex-direction: column; gap: 12px;
}
.modal-content p { margin: 0; color: var(--text-dim); font-size: 13px; }
.modal-content input {
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 16px; font-family: inherit;
}
#sessionsList { list-style: none; margin: 0; padding: 8px 0; overflow-y: auto; flex: 1; }
#sessionsList li {
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
#sessionsList li:last-child { border-bottom: 0; }
#sessionsList .session-meta { font-size: 12px; color: var(--text-dim); }
#sessionsList a {
  color: var(--accent); text-decoration: none; font-size: 13px;
  padding: 4px 8px; border-radius: 4px; background: var(--accent-soft);
  margin-left: 4px;
}

/* ─────────────── Live Mode modal (window-capture preview) ─────────────── */
.live-mode-modal { background: rgba(0,0,0,0.92); }
.live-mode-content {
  width: 95vw; height: 92vh; max-width: 1600px;
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden;
}
.live-mode-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.live-mode-header h2 { margin: 0; font-size: 15px; }
.live-mode-actions { display: flex; align-items: center; gap: 8px; }
.live-mode-meta { font-size: 12px; color: var(--text-dim); margin-right: 4px; }
.live-mode-image-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: #111; min-height: 0; padding: 6px;
}
.live-mode-image-wrap img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  background: #000;
}
.live-mode-ocr {
  padding: 10px 18px; font-size: 13px; line-height: 1.5;
  border-top: 1px solid var(--border); background: var(--surface);
  max-height: 30vh; overflow-y: auto; flex-shrink: 0;
}
.live-mode-ocr .ocr-en { color: var(--en); margin-bottom: 4px; }
.live-mode-ocr .ocr-vn { color: var(--vn); }
.live-mode-ocr:empty { display: none; }

/* ─────────────── Identity admin modal (#3 host UI) ─────────────── */
.modal-content.identity-admin { gap: 8px; }
.identity-list {
  list-style: none; margin: 0; padding: 0;
  max-height: 50vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2);
}
.identity-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.identity-list li:last-child { border-bottom: 0; }
.identity-list li.placeholder {
  color: var(--text-dim); font-style: italic; text-align: center;
  display: block;
}
.identity-list .user {
  font-family: var(--font-en); font-weight: 600; color: var(--text);
}
.identity-list .reset-btn {
  background: transparent; color: var(--red); border: 1px solid var(--red);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; cursor: pointer;
  transition: all 0.15s ease;
}
.identity-list .reset-btn:hover { background: var(--red); color: white; }
.identity-list .reset-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.identity-actions {
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ─────────────── Preflight (v2.5.5) ─────────────── */
.preflight-content { padding: 8px 0; }
.preflight-hint {
  font-size: 11px; color: var(--itc-dim);
  margin: 0 0 10px; line-height: 1.4;
}
/* v2.24.25: banner full-width thay vì pill nhỏ */
.preflight-status { margin-bottom: 14px; }
.preflight-status .badge {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 700;
  background: var(--itc-surface-2); color: var(--itc-dim);
  border: 1px solid var(--itc-border);
}
.preflight-status .badge.ok {
  background: rgba(16,185,129,0.12); color: #10b981;
  border-color: rgba(16,185,129,0.3);
}
.preflight-status .badge.bad {
  background: rgba(239,68,68,0.10); color: #ef4444;
  border-color: rgba(239,68,68,0.28);
}
.preflight-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
/* pass: compact, viền trái mỏng */
.preflight-row {
  padding: 7px 12px; border-radius: 7px;
  background: var(--itc-surface-2);
  border-left: 3px solid var(--itc-border);
}
.preflight-row.ok {
  border-left-color: rgba(16,185,129,0.5);
  opacity: 0.8;
}
/* fail: nổi bật — viền dày hơn + nền đỏ rõ + padding đủ */
.preflight-row.fail {
  padding: 10px 12px;
  border-left: 4px solid #ef4444;
  background: rgba(239,68,68,0.08);
  border-radius: 7px;
  outline: 1px solid rgba(239,68,68,0.18);
}
.preflight-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600;
}
/* pass: label nhỏ hơn, không cần đậm */
.preflight-row.ok .preflight-head {
  font-size: 12px; font-weight: 500;
}
.preflight-icon { font-size: 15px; }
.preflight-label { flex: 1; }
.preflight-rms {
  font-family: ui-monospace, monospace; font-size: 11px;
  padding: 2px 8px; background: var(--itc-surface);
  border-radius: 10px; color: var(--itc-accent);
}
.preflight-detail {
  font-size: 11px; color: var(--itc-dim);
  margin-top: 4px; line-height: 1.4;
  font-family: ui-monospace, monospace;
}
.preflight-backends {
  display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.preflight-backends .backend-pill {
  font-size: 10px; padding: 2px 8px; border-radius: 10px;
  font-family: ui-monospace, monospace;
}
.preflight-backends .backend-pill.ok {
  background: rgba(16,185,129,0.15); color: #10b981;
}
.preflight-backends .backend-pill.off {
  background: var(--itc-surface); color: var(--itc-dim);
}
.preflight-hint-row {
  margin-top: 8px; padding: 6px 10px;
  background: rgba(6,182,212,0.08);
  border-left: 2px solid var(--itc-accent);
  border-radius: 4px;
  font-size: 11px; line-height: 1.5; color: var(--itc-text);
}

/* v2.23 Phase 1 — audio route display + autofix button */
.preflight-audio-route {
  margin-top: 6px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11px; font-family: ui-monospace, monospace;
}
.preflight-audio-route .route-label {
  color: var(--itc-dim); font-weight: 500;
}
.preflight-audio-route .route-val {
  padding: 2px 8px; border-radius: 4px;
  background: var(--itc-surface);
}
.preflight-audio-route .route-val.ok {
  background: rgba(16,185,129,0.15); color: #10b981;
}
.preflight-audio-route .route-val.bad {
  background: rgba(239,68,68,0.15); color: #ef4444;
}
.preflight-audio-route .route-val.expected {
  background: rgba(6,182,212,0.15); color: var(--itc-accent);
  border: 1px dashed var(--itc-accent);
}
.preflight-audio-route .route-arrow {
  color: var(--itc-dim); font-weight: 700;
}
.preflight-autofix-btn {
  margin-left: auto;
  padding: 4px 12px; border-radius: 6px;
  background: var(--itc-accent); color: white; border: none;
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: opacity 0.15s;
}
.preflight-autofix-btn:hover:not(:disabled) {
  opacity: 0.85;
}
.preflight-autofix-btn:disabled {
  opacity: 0.5; cursor: wait;
}
.preflight-actions {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 14px;
}

/* ─────────────── Responsive ─────────────── */
@media (max-width: 900px) {
  .two-pane { grid-template-columns: minmax(0, 1fr); }
  .mobile-tabs { display: flex; }
  .pane { display: none; }
  .pane.active { display: flex; }

  header { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .brand .tagline { display: none; }
  .header-right { gap: 8px; }
  .control-panel { padding: 0 12px; }
  .controls { grid-template-columns: 1fr; }
  .pane-header { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .pane-toggles { font-size: 11px; }
  .captions { padding: 12px; }
  .cap { grid-template-columns: 50px 1fr 28px; padding: 10px 12px; gap: 8px; }
  .cap .ts { font-size: 10px; }
  .cap .en { font-size: 13px; }
  .cap .vn { font-size: 15px; }
  footer { padding: 6px 12px; flex-wrap: wrap; gap: 8px; font-size: 12px; }
}

/* ════════════════════════════════════════════════════════════════
   v2.3.1 — Window picker thumbnail card dropdown
   ════════════════════════════════════════════════════════════════ */
.window-picker-card-wrap {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}
/* v2.9.3: chưa pick cửa sổ → viền cảnh báo amber + ép user chú ý */
.window-picker-card-wrap.unpicked {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}
.window-picker-card-wrap.unpicked .window-picker-preview { background: rgba(245, 158, 11, 0.08); }
.wp-warn { color: #b45309; }
/* v2.9.3: hint nhắc pick cửa sổ trước khi Bắt đầu phiên */
.window-pick-hint {
  margin: 8px 0 2px;
  padding: 8px 12px;
  font-size: 12.5px; line-height: 1.45;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-left: 3px solid #f59e0b;
  border-radius: var(--radius-md);
  color: var(--text);
}
.window-pick-hint.hidden { display: none; }
.window-picker-preview {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2);
}
.window-picker-thumb {
  width: 96px; height: 54px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden; flex-shrink: 0;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  display: flex; align-items: center; justify-content: center;
  color: #cbd5e1; font-size: 16px;
}
.window-picker-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.window-picker-thumb-placeholder { text-align: center; line-height: 1.2; padding: 4px; }
.window-picker-info { flex: 1; min-width: 0; }
.window-picker-label { font-size: 13px; font-weight: 600; }
.window-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-2);
  padding: var(--space-3);
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.window-picker-grid.hidden { display: none; }
.window-picker-empty {
  grid-column: 1 / -1;
  text-align: center; padding: var(--space-4);
  color: var(--text-dim); font-size: 12px; font-style: italic;
}
.window-picker-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden; cursor: pointer;
  background: var(--surface);
  transition: all 0.15s;
  display: flex; flex-direction: column;
}
.window-picker-card:hover {
  border-color: var(--itc-accent);
  box-shadow: 0 4px 10px rgba(6,182,212,0.18);
  transform: translateY(-1px);
}
.window-picker-card.selected {
  border-color: var(--itc-accent);
  background: var(--itc-accent-soft);
}
.window-picker-card-thumb {
  width: 100%; aspect-ratio: 16/9;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #cbd5e1; font-size: 18px;
}
.window-picker-card-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.window-picker-card-thumb.fullscreen {
  flex-direction: column;
  background: linear-gradient(135deg, var(--accent), var(--itc-accent));
  color: white;
}
.window-picker-card-thumb-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #94a3b8;
}
.window-picker-card-label {
  padding: 6px 10px 2px; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.window-picker-card-sub {
  padding: 0 10px 6px; font-size: 10px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ════════════════════════════════════════════════════════════════
   v2.3.1 — Rail dark mode toggle + minimalist footer
   ════════════════════════════════════════════════════════════════ */
/* v2.3.9 fix: icon intuition — light mode show MOON (= "click to go dark"),
   dark mode show SUN (= "click to go light"). */
.rail-darkmode .ic-sun { display: none; }
.rail-darkmode .ic-moon { display: block; }
body.dark .rail-darkmode .ic-moon { display: none; }
body.dark .rail-darkmode .ic-sun { display: block; }
.rail-darkmode:hover { color: var(--itc-accent); }

/* v2.3.4: Footer min — version chip TRÁI + meta PHẢI (justify-between) */
footer.footer-min {
  padding: 4px 16px;
  min-height: 24px;
  font-size: 11px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-dim);
  gap: 12px;
}
footer.footer-min .meta { display: flex; gap: 8px; align-items: center; }
footer.footer-min .meta .sep { opacity: 0.4; }

/* v2.3.4: Layout C hiện footer (bỏ rule ẩn cũ) — version chip nằm bên trái
   status bar, user muốn thấy ở cả 2 layout. Padding-left của body đẩy footer
   khỏi vùng rail-c + section-col-c. */
body.layout-c > footer { display: flex !important; }

/* ════════════════════════════════════════════════════════════════
   v2.3.1 — Cleanup redundancy: ẩn control-panel + role-badge khi unused
   ════════════════════════════════════════════════════════════════ */
/* control-panel <details> legacy đã chuyển hoàn toàn sang Settings tab.
   Ẩn cứng trên cả Layout B + C (giữ DOM cho Settings UI delegate). */
body.layout-b .control-panel { display: none !important; }
body.layout-c .control-panel { display: none !important; }

/* role-badge: chỉ hiện khi có content (avoid empty "?" badge khi role chưa detect) */
.role-badge:empty { display: none !important; }

/* Header padding compact + brand tagline ẩn ở layout C (rail thay thế identity) */
header { padding: 6px 18px; min-height: 52px; }
body.layout-b header .brand .tagline,
body.layout-c header { /* layout-c hides header entirely already */ }
@media (max-width: 1280px) {
  .brand .tagline { display: none; }
}

/* mobile-tabs: ẩn trên desktop (chỉ relevant <900px) */
@media (min-width: 901px) {
  .mobile-tabs { display: none !important; }
}

/* ════════════════════════════════════════════════════════════════
   v2.3.3 — Version chip (status bar + rail bottom)
   ════════════════════════════════════════════════════════════════ */
.version-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--itc-accent-soft);
  color: var(--itc-accent);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}
.version-chip:hover {
  background: var(--itc-accent);
  color: white;
}
/* v2.3.4: .rail-version-chip removed — version chip giờ chỉ ở status bar bên trái. */

/* ════════════════════════════════════════════════════════════════
   v2.3.7 — Modern chat: group + date sep + smart ts + scroll-to-bottom
   ════════════════════════════════════════════════════════════════ */

/* Date separator (───── Hôm nay ─────) */
.chat-date-sep {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 16px 8px;
  font-size: 11px; color: var(--text-dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.chat-date-sep-line {
  flex: 1; height: 1px; background: var(--border);
}
.chat-date-sep-label {
  flex-shrink: 0; background: var(--surface-2); border-radius: 999px;
  padding: 3px 12px; color: var(--text-dim); font-size: 11px;
}

/* Chat container has relative for absolute new-msg badge */
.chat-pane { position: relative; }

/* ──── Group leader / follower spacing ──── */
.chat-msg {
  margin-bottom: 2px;   /* default tight — only leader gets margin-top */
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  align-items: start;
  animation: chatMsgIn 0.18s ease-out;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg.group-leader { margin-top: 12px; }
.chat-msg.group-leader:first-child { margin-top: 0; }

/* Avatar bigger (36px) for leader; spacer (no DOM) for follower */
.chat-msg .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  color: white; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-en); text-transform: uppercase;
  overflow: hidden; flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.chat-msg .avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.chat-msg.group-follower .avatar { visibility: hidden; }
.chat-msg .avatar-spacer { width: 36px; height: 0; }

/* Bubble: asymmetric border-radius (chat tail style)
   - Leader: top sharp on user side, soft rounded
   - Follower: more compact tail
   Mine vs others — direction inverted */
.chat-msg .bubble {
  padding: 8px 12px;
  background: var(--chat-other-bg);
  word-wrap: break-word; word-break: break-word;
  max-width: 100%;
  position: relative;
  font-size: 14px; line-height: 1.45;
}
/* OTHERS — left side avatar */
.chat-msg.group-leader:not(.mine) .bubble { border-radius: 14px 14px 14px 4px; }
.chat-msg.group-follower:not(.mine) .bubble { border-radius: 14px 14px 14px 4px; }
/* MINE — right side avatar */
.chat-msg.mine { grid-template-columns: 1fr 36px; }
.chat-msg.mine .avatar { order: 2; }
.chat-msg.mine .meta { justify-content: flex-end; }
.chat-msg.mine .bubble {
  background: var(--chat-mine-bg);
  color: var(--text);
}
.chat-msg.mine.group-leader .bubble { border-radius: 14px 14px 4px 14px; }
.chat-msg.mine.group-follower .bubble { border-radius: 14px 14px 4px 14px; }

/* Meta line (only leader shows) — username + smart ts */
.chat-msg .meta {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 3px; font-size: 12px;
}
.chat-msg .meta .user { font-weight: 700; font-size: 13px; }
.chat-msg .meta .ts {
  color: var(--text-dim); font-size: 11px;
  font-family: var(--font-vn);    /* "vừa xong" cần VN font, không phải mono */
  cursor: help;
}

/* Follower ts: inline floating bên phải bubble, hiện khi hover */
.chat-msg .ts-follower {
  position: absolute;
  right: -52px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--text-dim);
  font-family: var(--font-mono);
  opacity: 0; transition: opacity 0.15s;
  white-space: nowrap; pointer-events: none;
}
.chat-msg.mine .ts-follower { right: auto; left: -52px; }
.chat-msg:hover .ts-follower { opacity: 1; }

/* ──── New message badge (floating "↓ N tin mới") ──── */
.chat-new-msg-badge {
  position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%);
  z-index: 10;
  background: var(--itc-accent); color: white;
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 0; cursor: pointer;
  box-shadow: 0 6px 20px rgba(6,182,212,0.35), 0 2px 6px rgba(0,0,0,0.12);
  animation: badgeIn 0.2s ease-out;
}
@keyframes badgeIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.chat-new-msg-badge:hover { background: var(--accent); transform: translateX(-50%) scale(1.05); }

/* Refined hover toolbar — modern position above bubble */
.chat-msg .msg-toolbar {
  top: -16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  opacity: 0; transform: translateY(4px) scale(0.95);
  transition: all 0.15s ease-out;
  display: flex;
  pointer-events: none;
}
.chat-msg:hover .msg-toolbar {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
.chat-msg .msg-toolbar button {
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 14px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-msg .msg-toolbar button:hover {
  background: var(--itc-accent-soft); color: var(--itc-accent);
  transform: scale(1.1);
}

/* Reply ref — modern indent với colored border */
.chat-msg .reply-ref {
  font-size: 12px;
  border-left: 3px solid var(--itc-accent);
  padding: 4px 8px;
  margin-bottom: 6px;
  background: var(--itc-accent-soft);
  border-radius: 0 6px 6px 0;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11px;
}
.chat-msg .reply-ref .ref-en { color: var(--en); font-size: 11px; line-height: 1.3; }
.chat-msg .reply-ref .ref-vn { color: var(--text); font-size: 12px; line-height: 1.3; }
.chat-msg .reply-ref .ref-chat { color: var(--text); font-style: italic; }

/* Group follower bubble — slightly less padding */
.chat-msg.group-follower .bubble { padding: 6px 12px; }

/* ════════════════════════════════════════════════════════════════
   v2.3.11 — Chat "Khác" popover thay khung .zalo-tools
   ════════════════════════════════════════════════════════════════ */

/* Bỏ khung .zalo-tools cũ (vẫn giữ DOM nếu có cho legacy compat,
   không hiện nữa) */
.zalo-tools { display: none !important; }

/* Nút ⋯ Khác trong chat-input-row, cạnh nút 😀 emoji */
.chat-input-row .icon-btn.icon-btn-more {
  font-size: 18px;
  color: var(--text-dim);
  letter-spacing: -1px;
}
.chat-input-row .icon-btn.icon-btn-more:hover {
  color: var(--itc-accent);
  background: var(--itc-accent-soft);
  border-radius: 50%;
}
.chat-input-row .icon-btn.icon-btn-more.active {
  color: var(--itc-accent);
  background: var(--itc-accent-soft);
  border-radius: 50%;
}

/* Popover hiện trên nút Khác — grid 2 cột compact với 7 chip */
.chat-more-pop {
  position: absolute;
  bottom: 56px;             /* phía trên chat-input-row */
  left: 12px;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.08);
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  min-width: 220px;
  max-width: 280px;
  animation: chatMorePopIn 0.15s ease-out;
}
.chat-more-pop.hidden { display: none; }
@keyframes chatMorePopIn {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Each chip in popover — label + icon side by side */
.chat-more-pop .zalo-tool-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-width: 0;
  font-family: var(--font-vn);
  transition: background 0.12s;
}
.chat-more-pop .zalo-tool-btn:hover {
  background: var(--itc-accent-soft);
  color: var(--itc-accent);
}
.chat-more-pop .zalo-tool-btn > span:first-child {
  font-size: 16px;
  width: 20px; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
}
.chat-more-pop .zalo-tool-btn svg {
  width: 16px; height: 16px;
}
.chat-more-pop .zalo-tool-btn .lbl {
  flex: 1; font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-more-pop .zalo-tool-btn .lbl kbd {
  font-size: 9px; padding: 1px 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 3px; margin-left: 4px;
  font-family: var(--font-mono); opacity: 0.7;
}
.chat-more-pop .zalo-tool-btn.active {
  background: var(--itc-accent);
  color: white;
}

/* Backdrop để click outside đóng popover */
.chat-more-pop-backdrop {
  position: fixed; inset: 0;
  z-index: 40;
}
.chat-more-pop-backdrop.hidden { display: none; }

/* ════════════════════════════════════════════════════════════════
   v2.3.12 — Tiện ích host accordion (expand/collapse inline)
   ════════════════════════════════════════════════════════════════ */
.util-accordion {
  display: flex; flex-direction: column;
  gap: 4px;
}
.util-acc-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  transition: background 0.12s;
}
.util-acc-item[open] {
  background: var(--surface-2);
  border-color: var(--itc-accent);
}
.util-acc-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  user-select: none;
  transition: background 0.12s;
}
.util-acc-summary::-webkit-details-marker { display: none; }
.util-acc-summary:hover {
  background: var(--itc-accent-soft);
  color: var(--itc-accent);
}
.util-acc-arrow {
  display: inline-block;
  font-size: 9px;
  color: var(--text-dim);
  width: 12px;
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.util-acc-item[open] .util-acc-arrow {
  transform: rotate(90deg);
  color: var(--itc-accent);
}
.util-acc-icon { font-size: 15px; flex-shrink: 0; }
.util-acc-title {
  flex: 1; min-width: 0;
  text-align: left;
}
.util-acc-body {
  padding: 4px 14px 12px 32px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  border-top: 1px dashed var(--border);
  margin-top: 0;
  animation: utilAccBodyIn 0.18s ease-out;
}
@keyframes utilAccBodyIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.util-acc-body p { margin: 6px 0; }
.util-acc-body ol, .util-acc-body ul {
  margin: 6px 0; padding-left: 18px; line-height: 1.7;
}
.util-acc-body li { margin: 2px 0; }
.util-acc-body kbd {
  font-family: var(--font-mono);
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
  font-size: 11px;
}
.util-acc-body code {
  font-family: var(--font-mono);
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px;
  font-size: 11px;
  color: var(--itc-accent);
}
.util-acc-body a {
  color: var(--accent); text-decoration: none;
  border-bottom: 1px dotted var(--accent);
}
.util-acc-body a:hover { border-bottom-style: solid; }
.util-acc-note {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  font-style: italic;
}
.util-acc-action {
  margin-top: 8px;
  padding: 6px 14px;
  background: var(--itc-accent);
  color: white;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.util-acc-action:hover { filter: brightness(0.92); }

/* ════════════════════════════════════════════════════════════════
   v2.3.13 — Chat header gộp + msg-toolbar sát bubble (Zalo/FB style)
   ════════════════════════════════════════════════════════════════ */

/* Chat header gộp: h2 compact + channel-strip inline + my-user */
.pane-header.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  padding: 6px 12px;
  min-height: 40px;
}
.chat-h2-compact {
  font-size: 13px !important;
  font-weight: 600 !important;
  margin: 0 !important;
  white-space: nowrap;
  /* v2.10.2: cho phép co + cắt "…" thay vì flex-shrink:0 (gây nghẹt
     channel-strip → ló dấu "#" mồ côi khi tiêu đề DM dài). */
  flex-shrink: 1;
  min-width: 0;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
}

/* Channel strip inline trong header (không còn full-width row riêng) */
.chat-pane .channel-strip {
  display: inline-flex;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  background: transparent;
  border-bottom: 0;
  scrollbar-width: none;
}
.chat-pane .channel-strip::-webkit-scrollbar { display: none; }
.chat-pane .channel-strip .ch-btn {
  padding: 3px 10px;
  font-size: 12px;
  flex-shrink: 0;
}

/* my-user gọn hơn — chỉ hiện avatar dot + tên ngắn, ẩn "đổi" trong popover */
/* v2.24.21: role-tag bên trong my-user chip — hiện role dạng badge nhỏ, không standalone */
.my-user .role-tag {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  padding: 1px 5px; border-radius: 4px; line-height: 1.4;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim);
}
body.is-host .my-user .role-tag {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white; border-color: transparent;
}
.my-user .role-tag:empty { display: none; }

/* v2.24.21: my-user nằm trong header-right (giữa search và presence) */
.header-right .my-user {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; transition: background 0.15s;
}
.header-right .my-user:hover { background: var(--itc-accent-soft, #ede9fe); }
.header-right .my-user .my-color { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.header-right .my-user .link-btn { font-size: 11px; padding: 0 3px; color: var(--text-dim); }
/* Layout C: header bị ẩn → escape position:fixed, đặt trước presence */
body.layout-c .header-right .my-user {
  position: fixed; top: 8px; right: 148px; z-index: 200;
  font-size: 12px; padding: 2px 8px;
}

/* Popout ctrl group on chat-header — gọn */
.pane-header.chat-header .pane-ctrl { flex-shrink: 0; }

/* ──── msg-toolbar position FIX: sát đáy bubble (Zalo/FB style) ────
   Trước v2.3.13: top: -16px floating ABOVE message → khi hover phải di
   chuột lên trên + dễ leave hover area khi click → toolbar đóng.
   Sau: toolbar nằm ngay BÊN DƯỚI bubble (sát mép), cùng nhóm hover với
   message → không lost-hover khi nhắm button. */
.chat-msg .msg-toolbar {
  top: 100%;                  /* sát NGAY dưới mép bottom của chat-msg */
  bottom: auto;
  right: auto;
  left: 44px;                 /* indent ngang bubble (avatar 36 + gap 8) */
  margin-top: -6px;           /* overlap 6px vào bubble bottom = dính sát */
  z-index: 6;
}
.chat-msg.mine .msg-toolbar {
  left: auto;
  right: 44px;
}
/* Tăng margin-bottom .chat-msg đủ chỗ chứa toolbar (~28px) khi hover */
.chat-msg { margin-bottom: 22px; }
.chat-msg.group-leader { margin-top: 14px; }
.chat-msg.group-follower { margin-bottom: 22px; }

/* ════════════════════════════════════════════════════════════════
   v2.3.14 — Phụ đề header 1 dòng + Extra lang popover
   ════════════════════════════════════════════════════════════════ */

/* Captions pane-header 1 dòng — không wrap */
#captions-pane > .pane-header {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 4px !important;
  padding: 6px 10px !important;
  min-height: 40px;
}
#captions-pane > .pane-header::-webkit-scrollbar { display: none; }
#captions-pane > .pane-header h2 {
  font-size: 13px !important;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--text-dim);
}
#captions-pane .lang-picker {
  flex-shrink: 0;
  flex-wrap: nowrap;
  margin-left: 6px !important;
}
#captions-pane .lang-picker .lang-chip {
  font-size: 10px;
  padding: 2px 7px;
  white-space: nowrap;
}
#captions-pane .lang-picker .lang-chip.add {
  background: var(--itc-accent-soft);
  border-color: var(--itc-accent);
  color: var(--itc-accent);
  font-weight: 700;
}
#captions-pane .pane-toggles {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
#captions-pane .pane-toggles .toggle {
  font-size: 11px;
  white-space: nowrap;
}
#captions-pane .pane-ctrl { flex-shrink: 0; }

/* Extra lang popover từ nút "+ Thêm" */
.extra-lang-pop {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18), 0 4px 12px rgba(0,0,0,0.08);
  padding: 12px;
  min-width: 260px;
  max-width: 320px;
  animation: extraLangPopIn 0.15s ease-out;
}
.extra-lang-pop.hidden { display: none; }
@keyframes extraLangPopIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.extra-lang-pop-title {
  font-size: 13px; font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}
.extra-lang-pop-hint {
  font-size: 11px; color: var(--text-dim);
  margin: 0 0 10px;
  line-height: 1.4;
}
.extra-lang-pop-chips {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.extra-lang-pop-chips .lang-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  transition: all 0.12s;
}
.extra-lang-pop-chips .lang-chip:hover {
  border-color: var(--itc-accent);
  background: var(--itc-accent-soft);
}
.extra-lang-pop-chips .lang-chip.active {
  background: var(--itc-accent);
  border-color: var(--itc-accent);
  color: white;
  font-weight: 600;
}
.extra-lang-pop-chips .lang-chip.active .extra-lang-name { color: rgba(255,255,255,0.85); }
.extra-lang-pop-chips .extra-lang-code {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.08);
  padding: 1px 5px; border-radius: 3px;
  flex-shrink: 0;
}
.extra-lang-pop-chips .lang-chip.active .extra-lang-code {
  background: rgba(255,255,255,0.2);
}
.extra-lang-pop-chips .extra-lang-name {
  flex: 1; font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ════════════════════════════════════════════════════════════════
   v2.3.16 — Captions toggles compact icon-style
   ════════════════════════════════════════════════════════════════ */
/* v2.3.18: Tự cuộn pill text-only — bỏ dấu tick, ẩn checkbox.
   Click pill toggle. Active cyan-soft, inactive gray. */
.pane-toggles .toggle.toggle-icon {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
  white-space: nowrap;
  position: relative;
}
.pane-toggles .toggle.toggle-icon:hover {
  border-color: var(--itc-accent);
  color: var(--itc-accent);
}
/* Ẩn checkbox hoàn toàn — pill click handle toggle qua native label behavior */
.pane-toggles .toggle.toggle-icon input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
  margin: 0;
  pointer-events: none;
}
.pane-toggles .toggle.toggle-icon:has(input:checked) {
  background: var(--itc-accent-soft);
  border-color: var(--itc-accent);
  color: var(--itc-accent);
  font-weight: 600;
}

/* Slide toggle: chỉ icon 🖼️ as pill, không text */
.pane-toggles .toggle.toggle-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 24px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.12s;
  user-select: none;
  position: relative;
}
.pane-toggles .toggle.toggle-icon-only input[type="checkbox"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.pane-toggles .toggle.toggle-icon-only .toggle-icon {
  font-size: 13px;
  line-height: 1;
  filter: grayscale(0.6);
  opacity: 0.6;
  transition: all 0.12s;
}
.pane-toggles .toggle.toggle-icon-only:has(input:checked) {
  background: var(--itc-accent-soft);
  border-color: var(--itc-accent);
}
.pane-toggles .toggle.toggle-icon-only:has(input:checked) .toggle-icon {
  filter: none;
  opacity: 1;
}
.pane-toggles .toggle.toggle-icon-only:hover {
  border-color: var(--itc-accent);
}
.pane-toggles .toggle.toggle-icon-only:hover .toggle-icon {
  filter: none;
  opacity: 1;
}

/* ════════════════════════════════════════════════════════════════
   v2.3.17 — Live preview window chuyên gia
   ════════════════════════════════════════════════════════════════ */
.live-preview-wrap {
  position: relative;
  background: #000;
}
.live-preview-img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.live-preview-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(239,68,68,0.95);
  color: white;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  animation: livePreviewPulse 1.6s ease-in-out infinite;
  z-index: 2;
}
@keyframes livePreviewPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Window picker grid: thêm hint Chrome tab limitation */
.window-picker-hint {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text-dim);
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--itc-accent);
  margin-bottom: 6px;
  line-height: 1.5;
}
.window-picker-hint strong { color: var(--itc-accent); }

/* ════════════════════════════════════════════════════════════════
   v2.3.21 — Rail icons compact + smooth hover animation
   ════════════════════════════════════════════════════════════════ */
/* Rail-b/c button — gọn 36×36 thay 44×44, indicator active animate */
body.layout-b .rail-b,
body.layout-c .rail-c {
  width: 48px !important;
  padding: var(--space-2) 0;
  gap: 2px;
}
body.layout-b { padding-left: 48px !important; }
body.layout-c { padding-left: 328px !important; }   /* rail 48 + section 280 */

.rail-b-btn, .rail-c-btn {
  width: 36px !important;
  height: 36px !important;
  border-radius: 8px !important;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.rail-b-btn svg, .rail-c-btn svg {
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);  /* spring */
}

/* Hover: gentle scale + background fade */
.rail-b-btn:hover:not(.active), .rail-c-btn:hover:not(.active) {
  background: var(--surface-2);
  color: var(--itc-accent);
  transform: translateX(1px);
}
.rail-b-btn:hover:not(.active) svg, .rail-c-btn:hover:not(.active) svg {
  transform: scale(1.12);
}

/* Active: cyan-soft bg + cyan stroke + crisp left indicator */
.rail-b-btn.active::before, .rail-c-btn.active::before {
  width: 3px !important;
  border-radius: 0 3px 3px 0 !important;
  animation: railActiveIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes railActiveIn {
  0% { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

/* Settings gear icon special animation: rotate on hover */
.rail-b-btn[data-b-tab="settings"]:hover svg,
.rail-c-btn[data-c-tab="settings"]:hover svg {
  transform: rotate(15deg) scale(1.08);
}
/* Help icon: subtle bounce */
.rail-b-btn[data-b-tab="help"]:hover svg,
.rail-c-btn[data-c-tab="help"]:hover svg {
  animation: helpBounce 0.5s ease;
}
@keyframes helpBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.12); }
}
/* Dark mode toggle: rotate sun ↔ moon */
.rail-darkmode:hover svg { transform: rotate(20deg) scale(1.08); }
/* Captions/Live icon: subtle pulse khi active */
.rail-b-btn[data-b-tab="live"].active svg,
.rail-c-btn[data-c-tab="captions"].active svg {
  animation: liveIconPulse 2.2s ease-in-out infinite;
}
@keyframes liveIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

/* Count badge bên trên team icon — slightly smaller cho size mới */
.rail-b-count, .rail-c-count {
  min-width: 14px !important;
  height: 14px !important;
  font-size: 9px !important;
  top: -1px !important;
  right: -1px !important;
}

/* Icon size nhỏ hơn ở mọi nơi khác — pane-ctrl, slide-strip-btn, cap-act-btn */
.pane-ctrl-btn { font-size: 11px !important; padding: 2px 5px !important; }
.slide-strip-btn { font-size: 13px !important; }
.cap-act-btn { width: 22px !important; height: 22px !important; font-size: 11px !important; }
.chat-msg .msg-toolbar button { width: 24px !important; height: 24px !important; font-size: 12px !important; }
.chat-msg .msg-toolbar { padding: 1px !important; }

/* Mobile rail: cũng compact theo */
@media (max-width: 720px) {
  body.layout-b .rail-b, body.layout-c .rail-c {
    height: 48px !important;
    width: auto !important;
  }
  body.layout-b { padding-left: 0 !important; padding-bottom: 48px !important; }
  body.layout-c { padding-left: 0 !important; padding-bottom: 48px !important; }
}

/* ════════════════════════════════════════════════════════════════
   v2.3.26 — Zalo-style compose mode
   ════════════════════════════════════════════════════════════════ */

/* Nút ⤢ Compose mode trong chat-input-row */
.chat-input-row .icon-btn.icon-btn-compose {
  font-size: 14px;
  color: var(--text-dim);
}
.chat-input-row .icon-btn.icon-btn-compose:hover {
  color: var(--itc-accent);
  background: var(--itc-accent-soft);
  border-radius: 50%;
  transform: rotate(45deg);
}
body.chat-compose-mode .icon-btn.icon-btn-compose {
  color: var(--itc-accent);
  background: var(--itc-accent-soft);
  border-radius: 50%;
  transform: rotate(45deg);
}

/* v2.3.26 Compose mode (Zalo-style) — grid 3-row: hint / textarea / toolbar
   Trước stack dọc xấu. Giờ: hint trên · textarea giữa · icon-buttons trái + send phải. */
body.chat-compose-mode .chat-pane .chat-input-row {
  display: grid !important;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 1fr;
  grid-template-areas:
    "hint"
    "textarea"
    "footer";
  gap: 6px;
  padding: 10px 12px 12px;
  background: var(--surface);
  border-top: 1px solid var(--itc-accent);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.04);
  position: relative;
}
body.chat-compose-mode .chat-pane .chat-input-row::before {
  content: "✍️ Soạn thảo · Enter gửi · Shift+Enter xuống dòng · **bold** *ý* · Esc đóng";
  grid-area: hint;
  font-size: 10px;
  color: var(--text-dim);
  padding: 0 2px 4px;
  border-bottom: 1px dashed var(--border);
}
body.chat-compose-mode .chat-pane .chat-input-row textarea#chatInput {
  grid-area: textarea;
  min-height: 120px !important;
  max-height: 240px;
  border-radius: 12px !important;
  font-size: 14px;
  line-height: 1.6;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
}
/* Footer row: icon buttons horizontal trái + send pill phải qua flex wrapper.
   Hack: dùng :is() để cùng group nhiều icon-btn vào 1 grid-area, để chúng flex naturally
   bằng cách dùng subgrid hoặc absolute. Đơn giản hơn: position absolute footer.
   Solution: convert footer thành flex inline với JS wrapper, hoặc dùng order + gap. */
body.chat-compose-mode .chat-pane .chat-input-row .icon-btn,
body.chat-compose-mode .chat-pane .chat-input-row #chatSend,
body.chat-compose-mode .chat-pane .chat-input-row input[type="file"] {
  grid-area: footer;
}
/* All footer items chia row qua flex của grid-area shared — dùng position relative + flex parent...
   Đơn giản nhất: wrap qua JS hoặc absolute. Hack flex inside grid: */
body.chat-compose-mode .chat-pane .chat-input-row::after {
  content: "";
  grid-area: footer;
  display: block;
  pointer-events: none;
}
/* Convert thành flex sub-row inside grid-area "footer" qua trick subgrid simulation —
   simpler: move buttons via absolute position relative to .chat-input-row */
body.chat-compose-mode .chat-pane .chat-input-row #attachBtn {
  position: relative;
  z-index: 2;
  margin-right: 4px;
}
body.chat-compose-mode .chat-pane .chat-input-row #emojiBtn {
  position: relative;
  z-index: 2;
  margin-right: 4px;
}
body.chat-compose-mode .chat-pane .chat-input-row #chatMoreBtn {
  position: relative;
  z-index: 2;
  margin-right: 4px;
}
body.chat-compose-mode .chat-pane .chat-input-row #chatComposeBtn {
  position: relative;
  z-index: 2;
  justify-self: end;
  margin-right: 4px;
}
body.chat-compose-mode .chat-pane .chat-input-row #chatSend {
  position: relative;
  z-index: 2;
  justify-self: end;
  padding: 8px 24px;
  font-size: 13px;
  font-weight: 600;
}
/* Better: instead complex grid, just hide individual icon buttons in compose
   — user use Khác (⋯) popover for emoji/file/etc, và Esc/⤢ close. Send button only. */
body.chat-compose-mode .chat-pane .chat-input-row #attachBtn,
body.chat-compose-mode .chat-pane .chat-input-row #emojiBtn,
body.chat-compose-mode .chat-pane .chat-input-row #chatMoreBtn {
  display: none !important;   /* Compose mode dùng format bar trên cùng — icon thừa */
}
/* Show chatComposeBtn + chatSend ở footer: ⤢ close trái, Gửi phải */
body.chat-compose-mode .chat-pane .chat-input-row #chatComposeBtn {
  justify-self: start;
  display: inline-flex;
}
/* Format bar tự động lộ */
body.chat-compose-mode .zalo-format-bar { display: flex !important; }

/* chat-messages container vẫn scroll trong compose mode — không tăng chiều cao toàn chat-pane */
body.chat-compose-mode .chat-pane .chat-messages {
  flex: 1;
  min-height: 100px;
}

/* ════════════════════════════════════════════════════════════════
   v2.3.27 — Compose close ✕ button (replace ⤢ standalone)
   ════════════════════════════════════════════════════════════════ */
.compose-close-btn {
  grid-area: footer;
  justify-self: start;
  padding: 6px 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-vn);
  transition: all 0.12s;
}
.compose-close-btn:hover {
  background: var(--red);
  color: white;
  border-color: var(--red);
}
/* Compose mode footer: close trái + Gửi phải */
body.chat-compose-mode .chat-pane .chat-input-row #chatSend {
  justify-self: end;
}
/* Ẩn nút ⤢ chatComposeBtn vĩnh viễn (đã hidden trong HTML, double-protect) */
#chatComposeBtn { display: none !important; }

/* Đánh dấu Định dạng button trong Khác popover khi compose active */
.chat-more-pop .zalo-tool-btn#zaloFormatToggle.active {
  background: var(--itc-accent);
  color: white;
}
.chat-more-pop .zalo-tool-btn#zaloFormatToggle.active .lbl kbd {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.3);
  color: white;
}

/* ─────────────────────────────────────────────────────────────
   Phase 1 Session Card (v2.4.0)
   Modal: host khai báo topic/module/audience trước khi /api/start.
   Pill: hiển thị card active trên status bar.
   ───────────────────────────────────────────────────────────── */
.session-card-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* v2.6.11: Fix bug v2.6.9 — domain_scope textarea (rows=3 + hint) đẩy modal
   * cao quá viewport → nút "🚀 Lưu & Bắt đầu phiên" tràn ra ngoài, không click được.
   * Solution: scroll-y trong form (flex:1 + min-height:0 cho flexbox), actions sticky bottom. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.session-card-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.session-card-presets .preset-chip {
  border: 1px solid var(--surface-3, #2a2a35);
  background: var(--surface-2, #18181f);
  color: var(--text, #e4e4e7);
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.session-card-presets .preset-chip:hover {
  border-color: var(--itc-accent, #06b6d4);
  background: var(--itc-accent-soft, rgba(6,182,212,0.15));
}
.session-card-presets .preset-chip.active {
  border-color: var(--itc-accent, #06b6d4);
  background: var(--itc-accent-soft, rgba(6,182,212,0.2));
  color: var(--itc-accent, #06b6d4);
  font-weight: 600;
}
.sc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sc-label {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  font-weight: 500;
}
.sc-label small {
  color: var(--text-dim, #6b7280);
  font-weight: 400;
  margin-left: 4px;
}
.sc-field input,
.sc-field textarea {
  background: var(--surface-2, #18181f);
  border: 1px solid var(--surface-3, #2a2a35);
  color: var(--text, #e4e4e7);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.sc-field input:focus,
.sc-field textarea:focus {
  outline: none;
  border-color: var(--itc-accent, #06b6d4);
  box-shadow: 0 0 0 3px var(--itc-accent-soft, rgba(6,182,212,0.15));
}
/* v2.24.2 — Reverse mode 3-tile picker (Off / Chat / Audio) trong Session Card */
.reverse-mode-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
@media (min-width: 720px) {
  .reverse-mode-tiles { grid-template-columns: repeat(3, 1fr); }
}
.reverse-mode-tile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  font: inherit;
  color: var(--text);
}
.reverse-mode-tile:hover {
  border-color: var(--itc-accent, #06b6d4);
  background: var(--surface-2);
}
.reverse-mode-tile.selected {
  border-color: var(--itc-accent, #06b6d4);
  background: var(--itc-accent-soft, rgba(6,182,212,0.10));
  box-shadow: 0 0 0 2px var(--itc-accent-soft, rgba(6,182,212,0.15));
}
.reverse-mode-tile .rmt-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.reverse-mode-tile .rmt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reverse-mode-tile .rmt-name { font-size: 13px; font-weight: 600; }
.reverse-mode-tile .rmt-desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.35; }
.reverse-mode-tile .rmt-check {
  font-size: 14px;
  color: var(--itc-accent, #06b6d4);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  margin-top: 2px;
}
.reverse-mode-tile.selected .rmt-check { opacity: 1; }
/* Readonly state (phiên đang chạy) */
.session-card-form.readonly .reverse-mode-tile {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.session-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  /* v2.6.11: Sticky bottom — luôn visible kể cả khi form scroll */
  position: sticky;
  bottom: 0;
  background: var(--surface);
  padding: 10px 0;
  border-top: 1px solid var(--border);
  z-index: 2;
}
.session-card-actions .btn-primary {
  background: var(--itc-accent, #06b6d4);
  color: #08141a;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.session-card-actions .btn-primary:hover {
  background: var(--itc-accent-bold, #0891b2);
}
.session-card-actions .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Pill cyan trên status bar khi card active */
.session-card-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--itc-accent-soft, rgba(6,182,212,0.15));
  border: 1px solid var(--itc-accent, #06b6d4);
  color: var(--itc-accent, #06b6d4);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 240px;
}
.session-card-pill:hover {
  background: var(--itc-accent, #06b6d4);
  color: #08141a;
}
.session-card-pill.hidden { display: none; }
.session-card-pill .sc-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.session-card-pill .sc-pill-icon {
  font-size: 12px;
}

/* ─────────────────────────────────────────────────────────────
   Phase 3a (#4): pill click khi running → modal hiển thị banner
   warning + lock inputs cho đến khi user explicit chọn "Edit kế tiếp".
   ───────────────────────────────────────────────────────────── */
.sc-running-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fbbf24;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.sc-running-banner.hidden { display: none; }
.sc-running-banner .link-btn {
  margin-left: auto;
  flex-shrink: 0;
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.5);
  padding: 3px 10px;
  font-size: 11px;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.sc-running-banner .link-btn:hover {
  background: rgba(245, 158, 11, 0.2);
}

/* Readonly state: input/textarea xám + cursor not-allowed */
.session-card-form.readonly .sc-field input,
.session-card-form.readonly .sc-field textarea,
.session-card-form.readonly .sc-field select {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--surface-1, #101015);
  pointer-events: none;
}
.session-card-form.readonly .preset-chip {
  pointer-events: none;
  opacity: 0.5;
}
.session-card-form.readonly .session-card-actions .btn-primary {
  opacity: 0.5;
  cursor: not-allowed;
}

/* code in label hint */
.sc-label code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2, #18181f);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--itc-accent, #06b6d4);
}

/* ─────────────────────────────────────────────────────────────
   Phase 3b (#2): card template row trong session-card modal
   ───────────────────────────────────────────────────────────── */
.session-card-templates {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface-2, #18181f);
  border: 1px solid var(--surface-3, #2a2a35);
  border-radius: 6px;
  font-size: 12px;
}
.sc-templates-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.sc-templates-pick .sc-label {
  margin: 0;
  font-weight: 500;
  white-space: nowrap;
}
.sc-templates-pick select {
  flex: 1;
  /* v2.15.2: theme-aware — trước dùng --surface-1/--surface-3 không tồn tại
     → fallback #101015 (đen) trên mọi theme → text gần như không đọc được
     ở light mode (dark text trên nền đen). Đổi sang --surface-2/--border
     (đã định nghĩa cho cả light + dark). */
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.sc-templates-pick select:focus {
  outline: none;
  border-color: var(--itc-accent, #06b6d4);
}
/* Option list trong dropdown — Safari/Chrome inherit colour từ select,
   nhưng iOS/macOS native menu cần explicit. */
.sc-templates-pick select option {
  background: var(--surface);
  color: var(--text);
}
.sc-templates-pick .link-btn {
  padding: 3px 7px;
  font-size: 13px;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
}
.sc-templates-pick .link-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}
.session-card-templates > .link-btn {
  flex-shrink: 0;
  border: 1px solid var(--itc-accent, #06b6d4);
  color: var(--itc-accent, #06b6d4);
  padding: 4px 10px;
  font-size: 11px;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.session-card-templates > .link-btn:hover {
  background: var(--itc-accent-soft, rgba(6,182,212,0.15));
}

/* Readonly state: cũng disable template row */
.session-card-form.readonly .session-card-templates {
  opacity: 0.55;
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────
   v2.5.1 (#14): Realtime status-bar meters
   ───────────────────────────────────────────────────────────── */
.footer-min { gap: 12px; align-items: center; }

.status-meters {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  margin-right: 12px;
}
.status-meters[hidden] { display: none; }

.meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
}
.meter-label {
  font-size: 11px;
  width: 14px;
  text-align: center;
  line-height: 1;
}
.meter-track {
  position: relative;
  width: 120px;
  height: 8px;
  background: var(--surface-2, #18181f);
  border: 1px solid var(--surface-3, #2a2a35);
  border-radius: 4px;
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  background: linear-gradient(90deg,
    rgba(34,197,94,0.85) 0%,
    rgba(34,197,94,0.85) 60%,
    rgba(245,158,11,0.85) 75%,
    rgba(239,68,68,0.9) 100%);
  transition: width 0.12s ease-out;
  border-radius: 3px;
}
.meter-audio .meter-fill {
  /* Audio: green→amber→red gradient — clip at >100% to red */
}
.meter-recording .meter-fill {
  background: linear-gradient(90deg,
    rgba(239,68,68,0.85) 0%,
    rgba(239,68,68,0.9) 100%);
  animation: meterRecPulse 1.4s ease-in-out infinite;
}
@keyframes meterRecPulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1.0; }
}

/* VAD threshold marker — vạch dọc nhỏ trên track */
.meter-threshold {
  position: absolute;
  left: 5%;   /* ~0.005 RMS sau log scale */
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.25);
  pointer-events: none;
}

.meter-value {
  min-width: 48px;
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  white-space: nowrap;
  color: var(--text, #e4e4e7);
}

/* Audio meter empty state — when RMS=0 */
.meter-audio.silent .meter-fill { background: rgba(100,100,100,0.5); }
.meter-audio.silent .meter-value { color: var(--text-dim, #9ca3af); }

/* Recording stopped state */
.meter-recording.stopped .meter-fill { animation: none; opacity: 0.3; background: rgba(100,100,100,0.5); }
.meter-recording.stopped .meter-value { color: var(--text-dim, #9ca3af); }

/* ───────────── v2.13: Reverse — chip mic 3-state + PTT overlay ─────────────
   Refactor từ reverse-bar (v2.12) → tích hợp vào chat-input-row sẵn có.
   3 trạng thái chip: state-chat (default, muted) / state-text (cam, gõ VI→dịch) / state-voice (đỏ pulse, PTT).
   Mode (off/chat/voice) host set tại Session Card → Chức năng phiên.
   Floor (lượt nói) phản ánh qua data-floor + .reverse-floor-banner sticky.
   PTT overlay slide-in ngay trên chat-input-row khi state=voice. */

.reverse-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--itc-surface, rgba(120,170,255,0.06));
  border: 1px solid var(--itc-border, rgba(125,125,140,0.3));
  border-radius: 16px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}
.reverse-toggle .floor-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #444;
  flex-shrink: 0;
  transition: background 0.12s, box-shadow 0.12s;
}
.reverse-toggle .mic-icon {
  display: inline-flex;
  align-items: center;
  width: 14px;
  height: 14px;
}
.reverse-toggle .mic-icon svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.reverse-toggle .lang-text {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background 0.12s;
}
/* v2.13.1 — lang chip clickable trong state-text (chỉ host); hover affordance */
.reverse-toggle.state-text .lang-text {
  cursor: pointer;
  background: rgba(245,158,11,0.20);
}
.reverse-toggle.state-text .lang-text:hover {
  background: rgba(245,158,11,0.35);
  outline: 1px solid #f59e0b;
}
body:not(.is-host) .reverse-toggle.state-text .lang-text {
  cursor: default;
  background: transparent;
}
body:not(.is-host) .reverse-toggle.state-text .lang-text:hover {
  background: transparent;
  outline: none;
}

/* v2.13.1 — Lang target picker popover (anchored to lang chip) */
.reverse-lang-popover {
  position: fixed;
  z-index: 10005;
  background: linear-gradient(180deg, #1a3050 0%, #0a1929 100%);
  border: 1px solid #22d3ee;
  border-radius: 10px;
  padding: 6px;
  min-width: 220px;
  max-width: 280px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.55), 0 0 0 4px rgba(34,211,238,0.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: tourFadeIn 0.2s ease-out;
}
.reverse-lang-popover .rlp-title {
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #22d3ee;
  padding: 4px 8px 6px;
  border-bottom: 1px solid rgba(34,211,238,0.2);
  margin-bottom: 4px;
}
.reverse-lang-popover .rlp-item {
  background: transparent;
  border: 1px solid transparent;
  color: #e0e7ef;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.10s, border-color 0.10s;
  font-family: inherit;
}
.reverse-lang-popover .rlp-item:hover {
  background: rgba(34,211,238,0.12);
  border-color: rgba(34,211,238,0.3);
}
.reverse-lang-popover .rlp-item.active {
  background: rgba(34,211,238,0.20);
  border-color: #22d3ee;
  color: #22d3ee;
  font-weight: 600;
}

/* state-chat: muted default */
.reverse-toggle.state-chat {
  background: var(--itc-surface, rgba(120,170,255,0.06));
  border-color: var(--itc-border, rgba(125,125,140,0.3));
  color: var(--text-dim, #9ca3af);
}
.reverse-toggle.state-chat:hover {
  background: rgba(120,170,255,0.12);
  border-color: #22d3ee;
  color: var(--text, #e4e4e7);
}

/* state-text: amber */
.reverse-toggle.state-text {
  background: rgba(245,158,11,0.15);
  border-color: #f59e0b;
  color: #f59e0b;
}
.reverse-toggle.state-text:hover { background: rgba(245,158,11,0.22); }

/* state-voice: red pulse */
.reverse-toggle.state-voice {
  background: rgba(239,68,68,0.18);
  border-color: #ef4444;
  color: #ef4444;
  animation: reverseChipPulse 1.2s ease-in-out infinite;
}
.reverse-toggle.state-voice .floor-dot {
  background: #ef4444;
  box-shadow: 0 0 4px #ef4444;
}
@keyframes reverseChipPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Floor dot semantics via data-floor (independent of state) — v2.15.12 SI-1:
   pulse realtime để báo "đang có người giữ lượt" rõ ràng (không chỉ tĩnh). */
.reverse-toggle[data-floor="self"]:not(.state-voice) .floor-dot {
  background: #10b981;
  box-shadow: 0 0 4px #10b981;
  animation: floorDotSelf 1.8s ease-in-out infinite;
}
.reverse-toggle[data-floor="other"]:not(.state-voice) .floor-dot {
  background: #f87171;
  animation: floorDotOther 1.4s ease-in-out infinite;
}
@keyframes floorDotSelf {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  50%      { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}
@keyframes floorDotOther {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.55); }
  50%      { box-shadow: 0 0 0 5px rgba(248,113,113,0); }
}

/* Chip disabled when host mode=off */
.reverse-toggle:disabled,
.reverse-toggle.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* v2.15.12 SI-4: processing pill — feedback tức thì khi gửi reverse */
.reverse-proc-pill {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(8px);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(245,158,11,0.95), rgba(217,119,6,0.95));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(217,119,6,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reverse-proc-pill.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.reverse-proc-pill .proc-spin {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: procSpin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes procSpin { to { transform: rotate(360deg); } }

/* Chat input + send when in TEXT state */
#chatInput.reverse-mode {
  border-color: #f59e0b !important;
  background: rgba(245,158,11,0.06) !important;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.12) !important;
}
#chatSend.reverse-btn {
  background: #f59e0b !important;
  border-color: #d97706 !important;
  color: #1a1a1a !important;
  font-weight: 700;
}
#chatSend.reverse-btn:hover { background: #d97706 !important; }

/* PTT overlay — slide-in trên chat-input-row khi state=voice */
.ptt-overlay {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 0 8px 4px;
  background: linear-gradient(90deg, rgba(239,68,68,0.22), rgba(239,68,68,0.06));
  border: 1px solid #ef4444;
  border-radius: 8px;
  color: var(--text, #e4e4e7);
  font-size: 12px;
  animation: pttSlideIn 0.18s ease-out;
}
.ptt-overlay[hidden] { display: none; }
@keyframes pttSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ptt-overlay .ptt-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  animation: pttDotPulse 0.9s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pttDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.4); }
}
.ptt-overlay .ptt-text { color: var(--text, #e4e4e7); }
.ptt-overlay .ptt-time {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: #ef4444;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ptt-overlay .ptt-floor-info {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
}
/* v2.15.0 #6 — Voice level visualizer: 5 bars RMS realtime */
.ptt-viz {
  display: inline-flex; align-items: flex-end;
  gap: 3px; height: 18px; width: 36px;
  margin: 0 8px;
}
.ptt-viz-bar {
  flex: 1; min-width: 3px;
  background: linear-gradient(180deg, #ef4444 0%, #f59e0b 60%, #22d3ee 100%);
  border-radius: 2px;
  height: 10%;
  transition: height 60ms linear;
}
.ptt-overlay .ptt-spacer { flex: 1; }
.ptt-overlay .ptt-hint {
  font-size: 11px;
  opacity: 0.85;
}
.ptt-overlay kbd {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* Floor banner — sticky chip khi người khác giữ lượt */
.reverse-floor-banner {
  margin: 0 8px 4px;
  padding: 6px 12px;
  background: rgba(248,113,113,0.10);
  border: 1px solid rgba(248,113,113,0.4);
  border-radius: 6px;
  font-size: 11px;
  color: #fca5a5;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reverse-floor-banner[hidden] { display: none; }
.reverse-floor-banner.self {
  background: rgba(16,185,129,0.10);
  border-color: rgba(16,185,129,0.4);
  color: #6ee7b7;
}
.reverse-floor-banner .release-link {
  margin-left: auto;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 11px;
  font-family: inherit;
  padding: 0;
}
.reverse-floor-banner .release-link:hover { opacity: 0.7; }

/* First-time discoverability tour tooltip */
.reverse-chip-tour {
  position: fixed;
  background: linear-gradient(135deg, #1a3050, #0a1929);
  color: #e0e7ef;
  border: 1px solid #22d3ee;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12px;
  z-index: 10001;
  max-width: 320px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 0 4px rgba(34,211,238,0.15);
  animation: tourFadeIn 0.3s ease-out;
  line-height: 1.5;
}
.reverse-chip-tour::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 24px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #22d3ee;
}
.reverse-chip-tour kbd {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.reverse-chip-tour.out { animation: tourFadeOut 0.4s ease-in forwards; }
@keyframes tourFadeIn {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes tourFadeOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* Floor reject toast (used when can't acquire / pre-check fail) */
.reverse-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239,68,68,0.95);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(239,68,68,0.35);
  z-index: 10002;
  animation: toastSlideUp 0.25s ease-out;
}
.reverse-toast.ok { background: rgba(16,185,129,0.95); box-shadow: 0 8px 24px rgba(16,185,129,0.35); }
.reverse-toast.warn { background: rgba(245,158,11,0.95); box-shadow: 0 8px 24px rgba(245,158,11,0.35); }
.reverse-toast.out { animation: toastSlideDown 0.3s ease-in forwards; }
@keyframes toastSlideUp { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastSlideDown { to { opacity: 0; transform: translate(-50%, 12px); } }

/* ───────────── v2.12.4: pane restore bar ─────────────
   Sticky strip trên top của view-b-live. Hiển thị pill cho từng pane đã đóng.
   Click pill → mở lại pane. Hidden hoàn toàn khi không có pane đóng. */
.pane-restore-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 12px;
  margin: 0 8px 4px;
  border: 1px solid var(--itc-border, rgba(125,125,140,0.25));
  background: linear-gradient(90deg,
    rgba(34,211,238,0.08) 0%,
    rgba(120,170,255,0.05) 100%);
  border-radius: 8px;
  border-left: 3px solid var(--itc-accent, #22d3ee);
  font-size: 12px;
}
.pane-restore-bar[hidden] { display: none; }
.prb-label {
  font-weight: 600;
  color: var(--itc-accent, #22d3ee);
  letter-spacing: 0.02em;
}
.prb-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1px solid var(--itc-border, rgba(125,125,140,0.3));
  background: var(--itc-surface, rgba(255,255,255,0.6));
  color: var(--text, #1f2937);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}
.prb-pill:hover {
  background: var(--itc-accent, #22d3ee);
  color: #022;
  border-color: #0891b2;
  transform: translateY(-1px);
}
.prb-pill[hidden] { display: none; }
.prb-pill-all {
  margin-left: auto;
  font-weight: 600;
  color: var(--itc-accent, #22d3ee);
  border-color: var(--itc-accent, #22d3ee);
}
body.dark .prb-pill { background: rgba(255,255,255,0.05); color: var(--text, #e4e4e7); }

/* ───────────── v2.19: Chat header buttons + group manage + notify ───────────── */
.chat-hdr-btn {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
  font-size: 14px; cursor: pointer; transition: background .12s, border-color .12s;
}
.chat-hdr-btn:hover { background: var(--itc-accent-soft, rgba(6,182,212,.12)); border-color: var(--itc-accent, #06b6d4); }
/* v2.24.30: Mac speaker TTS button active state */
#macTtsBtn.active { background: rgba(59,130,246,0.18); color: #3b82f6; border-color: #3b82f6; }

/* ─── TTS Help Modal (platform setup guide, remote member) ─── */
.tts-help-content { overflow-y: auto; max-height: 60vh; gap: 8px; }
.tts-help-platform {
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.tts-help-platform summary {
  padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 13px;
  background: var(--surface-2); list-style: none;
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.tts-help-platform summary::-webkit-details-marker { display: none; }
.tts-help-platform summary::before { content: "▶"; font-size: 9px; opacity: 0.5; margin-right: 2px; }
.tts-help-platform[open] summary::before { content: "▼"; }
.tts-help-platform[open] summary { border-bottom: 1px solid var(--border); }
.tts-help-platform ol {
  margin: 0; padding: 12px 14px 12px 32px;
  display: flex; flex-direction: column; gap: 6px;
}
.tts-help-platform li { font-size: 13px; line-height: 1.5; }
.tts-help-note {
  margin: 0 14px 12px; font-size: 12px;
  color: var(--text-dim); font-style: italic;
}

.chat-notify-toast {
  position: fixed; bottom: 64px; right: 20px; max-width: 320px;
  background: var(--surface, #1f2937); color: var(--text, #f9fafb);
  border: 1px solid var(--itc-accent, #06b6d4); border-left: 3px solid var(--itc-accent, #06b6d4);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.4;
  box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.3)); z-index: 1200;
  animation: chatNotifyIn .18s ease-out;
}
@keyframes chatNotifyIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.group-manage-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 1300;
}
.group-manage-panel {
  width: min(420px, 92vw); max-height: 80vh; overflow-y: auto;
  background: var(--surface, #fff); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow, 0 12px 40px rgba(0,0,0,.35)); padding: 16px 18px;
}
.gm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.gm-title { font-weight: 700; font-size: 15px; }
.gm-close { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--text-dim, #9ca3af); }
.gm-row { display: flex; gap: 8px; margin-bottom: 12px; }
.gm-input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text); font-size: 13px; }
.gm-btn { padding: 7px 12px; border: 1px solid var(--itc-accent, #06b6d4); border-radius: 8px;
  background: var(--itc-accent-soft, rgba(6,182,212,.12)); color: var(--text); cursor: pointer; font-size: 13px; }
.gm-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim, #9ca3af); margin: 10px 0 6px; }
.gm-members { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.gm-members li { display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.gm-you { color: var(--itc-accent, #06b6d4); font-size: 11px; }
.gm-x { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 13px; }
.gm-add { display: flex; flex-wrap: wrap; gap: 6px; }
.gm-add-btn { padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 12px; }
.gm-add-btn:hover { border-color: var(--itc-accent, #06b6d4); }
.gm-foot { margin-top: 14px; display: flex; justify-content: flex-end; }
.gm-leave { padding: 7px 14px; border: 1px solid #ef4444; border-radius: 8px;
  background: rgba(239,68,68,.1); color: #ef4444; cursor: pointer; font-size: 13px; }

/* ═══════════ v2.20: WYSIWYG compose editor — trình soạn thảo nhỏ gọn thực thụ ═══════════ */
.compose-wrap { display: flex; flex-direction: column; margin: 6px 8px 4px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 6px 22px rgba(0,0,0,.10); overflow: hidden; }
.compose-wrap[hidden] { display: none !important; }   /* v2.21.1: 'display:flex' nuốt [hidden] → nút Đóng không ẩn được editor */
.compose-wrap:focus-within { border-color: var(--itc-accent, #06b6d4); box-shadow: 0 0 0 3px var(--itc-accent-soft, rgba(6,182,212,.18)); }
.compose-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 5px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.compose-btn { min-width: 30px; height: 30px; padding: 0 7px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text); font-size: 14px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .12s, border-color .12s, transform .08s; }
.compose-btn:hover { background: var(--itc-accent-soft, rgba(6,182,212,.12)); border-color: var(--border); }
.compose-btn:active { transform: scale(.92); }
.compose-btn.cb-b { font-weight: 800; }
.compose-btn.cb-i { font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.compose-btn.cb-u { text-decoration: underline; }
.compose-btn.cb-s { text-decoration: line-through; }
.compose-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; flex: 0 0 auto; }
.compose-editor { position: relative; min-height: 118px; max-height: 300px; overflow-y: auto; padding: 12px 14px; font-size: 15px; line-height: 1.55; color: var(--text); outline: none; word-break: break-word; }
.compose-wrap.is-empty .compose-editor::before { content: attr(data-placeholder); position: absolute; left: 14px; top: 12px; right: 14px; color: var(--text-dim, #99a0ad); pointer-events: none; font-size: 14px; }
.compose-editor strong { font-weight: 700; }
.compose-editor em { font-style: italic; }
.compose-editor u { text-decoration: underline; }
.compose-editor del, .compose-editor s, .compose-editor strike { text-decoration: line-through; opacity: .82; }
.compose-editor code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-family: ui-monospace, Menlo, monospace; font-size: .92em; }
.compose-editor pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-family: ui-monospace, Menlo, monospace; font-size: .9em; }
.compose-editor ul, .compose-editor ol { margin: 4px 0; padding-left: 24px; }
.compose-editor li { margin: 2px 0; }
.compose-editor blockquote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--itc-accent, #06b6d4); background: var(--itc-accent-soft, rgba(6,182,212,.07)); border-radius: 0 8px 8px 0; }
.compose-editor a { color: var(--itc-accent, #06b6d4); text-decoration: underline; }
.compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; background: var(--surface-2); border-top: 1px solid var(--border); }
.compose-hint { font-size: 11px; color: var(--text-dim, #99a0ad); flex: 1 1 auto; }
.compose-acts { display: flex; gap: 8px; flex: 0 0 auto; }
.compose-x { padding: 7px 16px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer; transition: background .12s; }
.compose-x:hover { background: var(--surface-2); }
.compose-send { padding: 7px 22px; border: none; border-radius: 20px; background: var(--itc-accent, #06b6d4); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 2px 8px var(--itc-accent-soft, rgba(6,182,212,.4)); transition: filter .12s, transform .08s; }
.compose-send:hover { filter: brightness(1.08); }
.compose-send:active { transform: scale(.96); }
body.chat-composing #chatForm { display: none !important; }
@media (max-width: 640px) { .compose-editor { min-height: 96px; max-height: 220px; } .compose-btn { min-width: 28px; height: 28px; } }
/* render-side: danh sách / trích dẫn trong bong bóng chat (renderMarkdown v2.20) */
.md-list { margin: 4px 0; padding-left: 22px; }
.md-list li { margin: 1px 0; }
.md-quote { margin: 5px 0; padding: 3px 11px; border-left: 3px solid var(--itc-accent, #06b6d4); background: var(--itc-accent-soft, rgba(6,182,212,.08)); border-radius: 0 7px 7px 0; }

/* ═══════════════ v2.21: rich compose toolbar (TextEdit/Word-like) + rich chat body ═══════════════ */
.compose-select { height: 26px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font-size: 12px; padding: 0 4px; cursor: pointer; max-width: 108px; }
.compose-select:hover { border-color: var(--itc-accent, #06b6d4); }
.compose-select option { background: var(--surface); color: var(--text); }
.compose-color { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 26px; border-radius: 7px; cursor: pointer; position: relative; border: 1px solid transparent; }
.compose-color:hover { background: var(--itc-accent-soft, rgba(6,182,212,.16)); }
.compose-color .cc-ico { font-weight: 800; font-size: 14px; line-height: 1; pointer-events: none; }
.compose-color.cc-fore .cc-ico { border-bottom: 3px solid #e11d48; padding-bottom: 1px; }
.compose-color.cc-back .cc-ico { background: #fde047; border-radius: 3px; padding: 0 3px; color: #1f2430; }
.compose-color input[type=color] { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: none; padding: 0; }
.compose-btn.cb-svg { padding: 0; }
.compose-btn.cb-svg svg { width: 15px; height: 15px; fill: currentColor; display: block; }
.compose-editor h1 { font-size: 1.5em; font-weight: 700; margin: .3em 0 .2em; line-height: 1.25; }
.compose-editor h2 { font-size: 1.28em; font-weight: 700; margin: .3em 0 .2em; line-height: 1.3; }
.compose-editor h3 { font-size: 1.12em; font-weight: 700; margin: .3em 0 .15em; }
.compose-editor blockquote { border-left: 3px solid var(--itc-accent, #06b6d4); margin: .3em 0; padding: .1em .7em; color: var(--text-dim, #5b6472); background: var(--itc-accent-soft, rgba(6,182,212,.08)); border-radius: 0 6px 6px 0; }
.compose-editor ul, .compose-editor ol { margin: .25em 0; padding-left: 1.4em; }
.compose-editor li { margin: .08em 0; }
.compose-editor hr { border: none; border-top: 1px solid var(--border); margin: .55em 0; }
.compose-editor a { color: var(--itc-accent, #0891b2); text-decoration: underline; }
.compose-editor pre { background: rgba(127,127,127,.12); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-family: ui-monospace, Menlo, monospace; font-size: .9em; }

/* render side — thân tin chat dạng rich-HTML (sanitize) */
.chat-msg .text h1 { font-size: 1.32em; font-weight: 700; margin: .25em 0 .15em; line-height: 1.3; }
.chat-msg .text h2 { font-size: 1.18em; font-weight: 700; margin: .25em 0 .15em; }
.chat-msg .text h3 { font-size: 1.06em; font-weight: 700; margin: .2em 0 .1em; }
.chat-msg .text blockquote { border-left: 3px solid var(--itc-accent, #06b6d4); margin: .25em 0; padding: .08em .6em; opacity: .92; }
.chat-msg .text ul, .chat-msg .text ol { margin: .2em 0; padding-left: 1.35em; }
.chat-msg .text li { margin: .05em 0; }
.chat-msg .text hr { border: none; border-top: 1px solid var(--border); margin: .4em 0; }
.chat-msg .text a { color: var(--itc-accent, #0891b2); text-decoration: underline; word-break: break-all; }
.chat-msg .text code { background: rgba(127,127,127,.16); border-radius: 5px; padding: 1px 5px; font-family: ui-monospace, Menlo, monospace; font-size: .92em; }
.chat-msg .text pre { background: rgba(127,127,127,.12); border-radius: 8px; padding: 8px 10px; overflow-x: auto; font-family: ui-monospace, Menlo, monospace; font-size: .88em; margin: .3em 0; }
.chat-msg .text p, .chat-msg .text div { margin: 0; }

/* ═══════════════════════════════════════════════════════════════════
   v2.22.0 FIX A3 — Mobile = Layout C cứng + iPhone notch safe-area
   + 44px touch target tối thiểu (Apple HIG) + ẩn layout switcher.
   ═══════════════════════════════════════════════════════════════════ */

/* iPhone notch / Dynamic Island — header padding-top dùng env(safe-area-inset-top).
   Áp khi body có class is-mobile (set bởi app.js applyLayoutPref). */
body.is-mobile header {
  padding-top: max(8px, env(safe-area-inset-top));
}
body.is-mobile .chat-input-row,
body.is-mobile #chatForm {
  padding-bottom: max(6px, env(safe-area-inset-bottom));
}
body.is-mobile {
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Mobile: ẩn Layout B switcher trong Settings (user mobile bị ép layout C) */
body.is-mobile [data-layout-switcher],
body.is-mobile #settings-layout-switcher,
body.is-mobile .settings-layout-row {
  display: none !important;
}

/* Mobile: touch target tối thiểu 44px cho nút icon (Apple HIG)
   — chip mic PTT + buttons trong toolbar */
@media (max-width: 768px) {
  body.is-mobile .reverse-toggle,
  body.is-mobile .reverse-toggle.state-chat,
  body.is-mobile .reverse-toggle.state-text,
  body.is-mobile .reverse-toggle.state-voice {
    min-width: 44px;
    min-height: 44px;
  }
  body.is-mobile button,
  body.is-mobile .btn,
  body.is-mobile .rail-c-btn,
  body.is-mobile .pane-ctrl button {
    min-height: 40px;
  }
  body.is-mobile .rail-c-btn {
    min-width: 44px;
  }
}

/* Zalo WebView KHÔNG hỗ trợ getUserMedia → ẩn nút PTT, chỉ cho TEXT-REVERSE */
body.is-zalo-webview .reverse-toggle.state-voice,
body.is-zalo-webview [data-ptt-only] {
  display: none !important;
}

/* Zalo WebView: banner cảnh báo trên top (chèn bởi JS sau khi detect) */
body.is-zalo-webview::before {
  content: "💡 Mở link này trong Safari/Chrome để dùng PTT voice (Zalo WebView không hỗ trợ mic)";
  display: block;
  background: #f59e0b;
  color: #1f2430;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 12px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 9999;
}


/* ───────────── v2.24.5: Recording control buttons (status bar bottom) ─────────────
 * 3 nút icon-only bên trái thanh tiến trình recording. Match chiều cao status meter
 * (~18px). Mặc định CHÌM (opacity 0.45, no bg) — chỉ hiện rõ khi hover. Icon + màu
 * phản ánh state recorder (idle/recording/paused) qua data-state trên .meter-recording.
 *
 * Logic enable/disable:
 *   data-state="idle"      → Start active, Pause/Stop dim+disabled
 *   data-state="recording" → Stop+Pause active (red pulse trên Stop khi hover),
 *                            Start dim+disabled
 *   data-state="paused"    → Start (resume) + Stop active, Pause swap sang ▶ icon
 *                            (CSS .meter-recording[data-state="paused"] handle hidden swap)
 */
.rec-ctrls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0 4px 0 0;
}
.rec-ctrl-btn {
  --rc-fg: var(--text-dim, #9ca3af);
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--rc-fg);
  opacity: 0.45;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.rec-ctrl-btn svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
  stroke: none;
  pointer-events: none;
}
.rec-ctrl-btn:hover:not(:disabled) {
  opacity: 1;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--rc-fg);
}
.rec-ctrl-btn:active:not(:disabled) {
  transform: scale(0.92);
}
.rec-ctrl-btn:disabled,
.rec-ctrl-btn[aria-disabled="true"] {
  opacity: 0.18;
  cursor: not-allowed;
  pointer-events: none;
}
.rec-ctrl-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.6);
  outline-offset: 1px;
}

/* State-driven — unified main btn (Start/Pause/Resume) + Stop. */
/* idle: main=▶ xanh, stop dim */
.meter-recording[data-state="idle"] .rec-ctrl-main { opacity: 0.7; color: var(--green, #22c55e); }
.meter-recording[data-state="idle"] .rec-ctrl-main:hover { background: rgba(34, 197, 94, 0.14); border-color: rgba(34, 197, 94, 0.35); }
.meter-recording[data-state="idle"] .rec-ctrl-stop { opacity: 0.22; pointer-events: none; }

/* recording: main=⏸ vàng, stop=■ đỏ */
.meter-recording[data-state="recording"] .rec-ctrl-main { opacity: 0.7; color: #f59e0b; }
.meter-recording[data-state="recording"] .rec-ctrl-main:hover { background: rgba(245, 158, 11, 0.16); border-color: rgba(245, 158, 11, 0.4); }
.meter-recording[data-state="recording"] .rec-ctrl-stop { opacity: 0.7; color: #ef4444; }
.meter-recording[data-state="recording"] .rec-ctrl-stop:hover { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.4); }

/* paused: main=▶ xanh (resume), stop=■ đỏ vẫn active */
.meter-recording[data-state="paused"] .rec-ctrl-main { opacity: 0.8; color: var(--green, #22c55e); }
.meter-recording[data-state="paused"] .rec-ctrl-main:hover { background: rgba(34, 197, 94, 0.16); border-color: rgba(34, 197, 94, 0.4); }
.meter-recording[data-state="paused"] .rec-ctrl-stop { opacity: 0.7; color: #ef4444; }
.meter-recording[data-state="paused"] .rec-ctrl-stop:hover { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.4); }

/* SVG visibility per state — chỉ 1 icon hiện tại mỗi lúc */
.rec-ctrl-svg-start, .rec-ctrl-svg-pause, .rec-ctrl-svg-resume { display: none; }
.meter-recording[data-state="idle"]      .rec-ctrl-svg-start  { display: inline-block; }
.meter-recording[data-state="recording"] .rec-ctrl-svg-pause  { display: inline-block; }
.meter-recording[data-state="paused"]    .rec-ctrl-svg-resume { display: inline-block; }

/* Paused: nhãn pill + meter-fill dim amber pulse nhẹ */
.meter-recording[data-state="paused"] .meter-fill {
  animation: meterRecPaused 2s ease-in-out infinite;
  background: linear-gradient(90deg, rgba(245,158,11,0.6), rgba(245,158,11,0.8));
}
@keyframes meterRecPaused {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.85; }
}


/* ───────────── v2.24.6: Recording status dot (Sony camera convention) ─────────────
 * Chấm tròn 10px phản ánh state recorder — visual semantic giống nút REC của
 * máy quay Sony chuyên nghiệp:
 *   - recording → đỏ NHẤP NHÁY 1Hz (giống "● REC" trên viewfinder)
 *   - paused    → đỏ STATIC (không nhấp nháy — báo state khác "đang ghi")
 *   - idle      → xám/đen static (không thu hút mắt)
 */
.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #3a3a45;             /* idle: đen-xám */
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
  transition: background-color 0.2s, box-shadow 0.2s;
}
.meter-recording[data-state="recording"] .rec-dot {
  background: #ef4444;             /* đỏ rực */
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.55), inset 0 0 0 1px rgba(0,0,0,0.25);
  animation: recDotBlink 1s steps(2, end) infinite;
}
.meter-recording[data-state="paused"] .rec-dot {
  background: #ef4444;             /* đỏ static, không blink — Sony "PAUSE" */
  box-shadow: 0 0 3px rgba(239, 68, 68, 0.35), inset 0 0 0 1px rgba(0,0,0,0.3);
  /* KHÔNG animation */
}
@keyframes recDotBlink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0.25; }
}


/* v2.24.8: ô Nhãn phiên rỗng — red border + subtle pulse, prompt user nhập */
input.label-empty-warn,
input.label-empty-warn:focus {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25), 0 0 6px rgba(239, 68, 68, 0.18);
  animation: labelWarnPulse 1.8s ease-in-out infinite;
}
@keyframes labelWarnPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.25), 0 0 4px rgba(239, 68, 68, 0.12); }
  50%      { box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.45), 0 0 8px rgba(239, 68, 68, 0.28); }
}


/* ───────────── v2.24.10: Rename hover-edit + Group by topic ─────────────
 * Pencil icon ẩn mặc định, chỉ hiện khi hover lên row chứa nó.
 * Tránh click nhầm vào tên — chỉ click vào icon mới mở rename.
 */
.rec-name-wrap { position: relative; }
.rec-name { user-select: text; }
.rec-name-edit-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim, #9ca3af);
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.rec-name-edit-btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
/* Hover lên row chứa rec-name → show pencil */
.recording-row:hover .rec-name-edit-btn,
li[data-session]:hover .rec-name-edit-btn,
.rec-name-edit-btn:focus-visible {
  opacity: 0.55;
  transform: scale(1);
}
.rec-name-edit-btn:hover {
  opacity: 1 !important;
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}
.rec-name-edit-btn:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.6);
  outline-offset: 1px;
}

/* Group by topic — collapsible section */
.rec-group {
  margin-bottom: 12px;
  border: 1px solid var(--border, #2a2a35);
  border-radius: var(--radius-lg, 8px);
  overflow: hidden;
  background: var(--surface-2, #18181f);
}
.rec-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  background: var(--surface-2, #18181f);
  border-bottom: 1px solid var(--border, #2a2a35);
  transition: background-color 0.15s;
}
.rec-group-header:hover {
  background: rgba(59, 130, 246, 0.06);
}
.rec-group-caret {
  display: inline-block;
  width: 14px;
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
  transition: transform 0.2s;
}
.rec-group.collapsed .rec-group-caret {
  transform: rotate(-90deg);
}
.rec-group.collapsed .rec-group-body {
  display: none;
}
.rec-group.collapsed .rec-group-header {
  border-bottom-color: transparent;
}
.rec-group-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text, #e4e4e7);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rec-group-meta {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
  flex-shrink: 0;
}
.rec-group-body {
  padding: 10px 12px 4px;
  background: var(--surface, #1a1a22);
}
.rec-group-body .recording-row-wrap:last-child {
  margin-bottom: 0;
}


/* ───────────── v2.24.11: Upload Drive badges + Copy buttons + Merge UI ───────────── */
.upload-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  font-family: var(--font-mono, monospace);
  flex-shrink: 0;
  border: 1px solid transparent;
  text-decoration: none;
}
.upload-queued { background: rgba(245, 158, 11, 0.16); color: #f59e0b; border-color: rgba(245, 158, 11, 0.4); }
.upload-progress {
  background: rgba(59, 130, 246, 0.16);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.4);
  animation: uploadPulse 1.4s ease-in-out infinite;
}
.upload-done {
  background: rgba(34, 197, 94, 0.16);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.4);
}
.upload-done:hover {
  background: rgba(34, 197, 94, 0.28);
  text-decoration: underline;
}
.upload-failed {
  background: rgba(239, 68, 68, 0.16);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}
@keyframes uploadPulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

/* Copy buttons trong file row */
.rec-file-copy-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-dim, #9ca3af);
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.rec-file-row:hover .rec-file-copy-btn { opacity: 0.6; }
.rec-file-copy-btn:hover {
  opacity: 1 !important;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

/* Merge buttons + upload-trigger button trong group/session */
.rec-group-merge-btn,
.rec-merge-btn,
.rec-upload-btn {
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
}
.rec-group-merge-btn:hover,
.rec-merge-btn:hover {
  background: var(--itc-accent-soft, rgba(59, 130, 246, 0.14)) !important;
  color: var(--itc-accent, #60a5fa) !important;
}
.rec-upload-btn:hover {
  background: rgba(59, 130, 246, 0.14) !important;
  color: #60a5fa !important;
}
.rec-group-merge-btn:active,
.rec-merge-btn:active,
.rec-upload-btn:active { transform: scale(0.97); }
.rec-group-merge-btn[disabled],
.rec-merge-btn[disabled],
.rec-upload-btn[disabled] { opacity: 0.5; cursor: not-allowed; }


/* v2.24.13: Edit topic icon trên group header — hover hiện, click edit inline */
.rec-group-edit-btn {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 3px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim, #9ca3af);
  opacity: 0;
  transition: opacity 0.15s, background-color 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  margin-left: 4px;
}
.rec-group-edit-btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.rec-group-header:hover .rec-group-edit-btn {
  opacity: 0.6;
}
.rec-group-edit-btn:hover {
  opacity: 1 !important;
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.rec-move-topic-btn:hover {
  background: rgba(168, 85, 247, 0.14) !important;
}
.rec-move-topic-btn:active { transform: scale(0.97); }

#recBulkMerge:hover:not(:disabled) {
  background: var(--itc-accent-soft, rgba(6, 182, 212, 0.14)) !important;
}


/* v2.24.14: Đánh dấu phiên đã được gộp / là phiên gộp */
.rec-merged-badge {
  margin: 4px 0 0 !important;
  font-size: 11px !important;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid transparent;
  cursor: help;
}
.merged-into-badge {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b !important;
  border-color: rgba(245, 158, 11, 0.4);
}
.merged-into-badge a {
  color: #f59e0b;
  text-decoration: underline;
  font-weight: 700;
}
.merged-into-badge a:hover { color: #d97706; }

.merged-from-badge {
  background: rgba(168, 85, 247, 0.12);
  color: #a855f7 !important;
  border-color: rgba(168, 85, 247, 0.4);
}

/* Phiên nguồn đã gộp — dim + viền cam nhạt báo "có thể xoá an toàn" */
.recording-row.is-merged-source {
  opacity: 0.72;
  border-color: rgba(245, 158, 11, 0.35) !important;
  background: rgba(245, 158, 11, 0.025) !important;
}
.recording-row.is-merged-source:hover { opacity: 0.92; }

/* Phiên gộp — viền tím nhạt làm điểm nhấn */
.recording-row.is-merged-target {
  border-color: rgba(168, 85, 247, 0.45) !important;
  background: rgba(168, 85, 247, 0.04) !important;
}

#recBulkDeleteMerged:hover {
  background: rgba(245, 158, 11, 0.12) !important;
}


/* v2.24.15: Drive copy link button cạnh badge ✓ Drive */
.upload-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.upload-badge-group .upload-badge {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}
.upload-copy-btn {
  appearance: none;
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.40);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-radius: 0 10px 10px 0;
  padding: 1px 6px;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #22c55e;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.upload-copy-btn svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.upload-copy-btn:hover {
  background: rgba(34, 197, 94, 0.22);
  border-color: rgba(34, 197, 94, 0.6);
}
.upload-copy-btn:active { transform: scale(0.92); }

/* Course-rename input — clearer visual when editing */
.rec-group-title-input:focus { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25); }


/* ───────────── v2.24.17: Unified inline-editable text ─────────────
 * Click trực tiếp vào text để đổi tên — bỏ icon ✏️. Subtle hover: cursor +
 * underline mờ + bg tint nhẹ → user biết clickable mà KHÔNG ồn ào visually.
 */
.inline-editable {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 3px;
  margin: 0 -3px;     /* offset padding để layout không lệch */
  transition: background-color 0.12s, box-shadow 0.12s;
}
.inline-editable:hover {
  background: rgba(59, 130, 246, 0.10);
  box-shadow: inset 0 -1px 0 0 rgba(59, 130, 246, 0.45);
}
.inline-editable[data-editing="1"] {
  background: transparent;
  box-shadow: none;
  cursor: text;
  padding: 0;
  margin: 0;
}
.inline-rename-input {
  font-family: inherit !important;
  /* width/style set inline ở JS — đo bằng getBoundingClientRect */
}

/* Hide legacy pencil button styles — không còn render */
.rec-name-edit-btn,
.rec-group-edit-btn { display: none !important; }

/* ── v2.26 Interpreter Mode "Phiên dịch" — accent cyan/teal (khác cam reverse) ── */
:root { --interp-accent: #06b6d4; --interp-accent-dim: rgba(6,182,212,0.12); }

/* Pane visibility: #interpreter-pane ẩn mặc định, chỉ hiện ở tab interpreter (layout-c).
   Các pane khác visible-by-default → phải ẩn tường minh khi c-tab-interpreter active. */
#interpreter-pane { display: none; }
body.layout-c.c-tab-interpreter #view-b-live #interpreter-pane { display: flex; flex-direction: column; }
body.layout-c.c-tab-interpreter #view-b-live #captions-pane,
body.layout-c.c-tab-interpreter #view-b-live #chat-pane,
body.layout-c.c-tab-interpreter #view-b-live .slide-strip { display: none !important; }

/* Layout B: tab "Phiên dịch" dùng lại #view-b-live, chỉ hiện #interpreter-pane
   (override grid 3-pane training). rail-b button + setBView thêm body.b-tab-interpreter. */
body.layout-b.b-tab-interpreter #view-b-live { display: flex !important; }
body.layout-b.b-tab-interpreter #view-b-live > .pane { display: none !important; }
body.layout-b.b-tab-interpreter #view-b-live > #interpreter-pane {
  display: flex !important; flex: 1; flex-direction: column; min-width: 0;
}

/* Status line (cột section) + pane header status */
.interp-status { display:flex; align-items:center; gap:8px; padding:8px 10px; font-size:13px; color: var(--text-dim, #64748b); }
.interp-dot { width:9px; height:9px; border-radius:50%; background:#94a3b8; flex:0 0 auto; }
.interp-dot.on { background: var(--interp-accent); box-shadow:0 0 0 3px var(--interp-accent-dim); }
.interp-pane-status { display:flex; align-items:center; gap:6px; font-size:12px; color: var(--text-dim,#64748b); }

/* Direction selector */
.interp-dir { display:flex; gap:6px; padding:4px 10px 10px; }
.interp-dir-btn { flex:1; padding:6px 4px; border:1px solid var(--border,#e2e8f0); border-radius:8px; background:transparent; font-size:12px; cursor:pointer; color:inherit; }
.interp-dir-btn.active { background: var(--interp-accent); border-color: var(--interp-accent); color:#fff; font-weight:600; }

/* Power button */
.interp-power { width:calc(100% - 20px); margin:4px 10px; padding:10px; border:none; border-radius:10px; background: var(--interp-accent); color:#fff; font-size:14px; font-weight:600; cursor:pointer; display:flex; align-items:center; justify-content:center; gap:8px; }
.interp-power.on { background:#ef4444; }

/* Mic-active indicator (pulse) */
.interp-mic { display:flex; align-items:center; gap:8px; margin:6px 10px; padding:6px 10px; border-radius:8px; background: var(--interp-accent-dim); font-size:12px; color: var(--interp-accent); }
.interp-mic-dot { width:8px; height:8px; border-radius:50%; background: var(--interp-accent); animation: interpPulse 1.1s ease-in-out infinite; }
@keyframes interpPulse { 0%,100%{opacity:1;} 50%{opacity:.3;} }

/* Caption song ngữ */
.interp-captions { flex:1; overflow-y:auto; padding:10px; }
.interp-cap { display:flex; gap:10px; padding:8px 10px; border-radius:10px; border-left:3px solid var(--interp-accent); background: var(--interp-accent-dim); margin-bottom:8px; }
.interp-cap.new { animation: interpFadeIn .35s ease; }
@keyframes interpFadeIn { from{opacity:0; transform:translateY(4px);} to{opacity:1;} }
.interp-cap-meta { display:flex; flex-direction:column; align-items:center; gap:3px; flex:0 0 auto; font-size:11px; color: var(--text-dim,#64748b); }
/* v2.33: badge chiều dịch nguồn→đích trên mỗi caption (vd FR→VI) */
.interp-cap-dir { font-size:10px; font-weight:800; letter-spacing:.2px; color:#fff;
  background:var(--interp-accent,#06b6d4); border-radius:5px; padding:1px 6px; white-space:nowrap; }
.interp-cap-text { flex:1; min-width:0; }
.interp-line { line-height:1.5; word-wrap:break-word; }
.interp-line.src { font-size:13px; color: var(--text-dim,#64748b); }
.interp-line.tgt { font-size:15px; font-weight:600; }
.interp-lang-tag { display:inline-block; min-width:24px; margin-right:6px; font-size:10px; font-weight:700; color: var(--interp-accent); border:1px solid var(--interp-accent); border-radius:4px; padding:0 4px; text-align:center; }
.interp-cap-actions { flex:0 0 auto; opacity:0; transition:opacity .15s; }
.interp-cap:hover .interp-cap-actions { opacity:1; }

/* Ô gõ chữ */
.interp-textbar { display:flex; gap:8px; padding:10px; border-top:1px solid var(--border,#e2e8f0); }
.interp-text-input { flex:1; padding:8px 12px; border:1px solid var(--border,#e2e8f0); border-radius:8px; font-size:14px; background:transparent; color:inherit; }
.interp-text-input:focus { outline:none; border-color: var(--interp-accent); box-shadow:0 0 0 3px var(--interp-accent-dim); }
.interp-send-btn { padding:8px 16px; border:none; border-radius:8px; background: var(--interp-accent); color:#fff; font-weight:600; cursor:pointer; }
.interp-send-btn:hover { background:#0598b0; color:#fff; filter:none; }

/* ── v2.27: sub-tab "Lưu trữ phiên" — Huấn luyện / Đàm thoại ──────────────── */
.rec-subtabs { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--border,#e2e8f0); }
.rec-subtab { padding:8px 16px; border:none; background:transparent; font-size:14px; font-weight:600;
  color:var(--text-dim,#64748b); cursor:pointer; border-bottom:2px solid transparent; margin-bottom:-1px; }
.rec-subtab.active { color:var(--interp-accent,#06b6d4); border-bottom-color:var(--interp-accent,#06b6d4); }
.rec-subtab:hover:not(.active) { color:inherit; }

/* ── v2.27.1: thanh điều khiển phiên dịch — 1 hàng gọn, hiện đại ──────────── */
.interp-bar { display:flex; flex-wrap:wrap; align-items:center; gap:8px;
  padding:8px 12px; border-bottom:1px solid var(--border,#e2e8f0); }

/* Nút Bật/Tắt — xanh lá (mời bật) → đỏ (đang chạy). Hover: đậm hơn + nhấc nhẹ + shadow màu. */
.interp-bar .interp-power { width:auto; margin:0; flex:0 0 auto; height:32px;
  padding:0 14px; border:none; border-radius:8px; font-size:13px; font-weight:600;
  display:inline-flex; align-items:center; gap:6px; cursor:pointer;
  background:#10b981; color:#fff; box-shadow:0 1px 2px rgba(0,0,0,.10);
  transition:background .18s ease, box-shadow .18s ease, transform .12s ease; }
.interp-bar .interp-power:hover { background:#0d9f6e; color:#fff; transform:translateY(-1px);
  box-shadow:0 4px 12px rgba(16,185,129,.42); }
.interp-bar .interp-power:active { transform:translateY(0) scale(.97);
  box-shadow:0 1px 2px rgba(0,0,0,.14); }
.interp-bar .interp-power.on { background:#ef4444; }
.interp-bar .interp-power.on:hover { background:#dc2626; color:#fff;
  box-shadow:0 4px 12px rgba(239,68,68,.45); }
.interp-bar .interp-power-ic { font-size:10px; line-height:1; }

/* v2.33: khối điều khiển chiều dịch thống nhất — Auto (switch) + cặp ngôn ngữ, có vạch ngăn. */
.interp-dir-group { display:inline-flex; flex:0 0 auto; align-items:center; gap:8px;
  height:34px; padding:0 7px; border:1px solid var(--border,#e2e8f0); border-radius:10px;
  background:var(--surface); }
.interp-dir-group .interp-lang-row { padding-left:8px;
  border-left:1px solid var(--border,#e2e8f0); }

/* Nút Auto = SWITCH on/off (chấm sáng + nền cyan khi BẬT auto; viền mờ khi TẮT = cố định). */
.interp-seg { display:inline-flex; flex:0 0 auto; }
.interp-seg .interp-dir-btn { flex:0 0 auto; height:26px; padding:0 11px; border:1px solid transparent;
  border-radius:7px; background:transparent; font-size:12.5px; font-weight:600;
  color:var(--text-dim,#64748b); cursor:pointer; white-space:nowrap;
  display:inline-flex; align-items:center; gap:6px;
  transition:background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .1s ease; }
.interp-seg .interp-dir-btn::before { content:""; width:7px; height:7px; border-radius:50%;
  background:currentColor; opacity:.45; transition:opacity .18s ease, background .18s ease; }
.interp-seg .interp-dir-btn:not(.active) { border-color:var(--border,#e2e8f0); }   /* TẮT: outline rõ là bấm được */
.interp-seg .interp-dir-btn:hover:not(.active) {
  background:var(--interp-accent-dim,rgba(6,182,212,.14)); color:var(--interp-accent,#06b6d4);
  border-color:var(--interp-accent,#06b6d4); }
.interp-seg .interp-dir-btn:active { transform:scale(.95); }
.interp-seg .interp-dir-btn.active { background:var(--interp-accent,#06b6d4); color:#fff;
  border-color:var(--interp-accent,#06b6d4); box-shadow:0 1px 4px rgba(6,182,212,.45); }
.interp-seg .interp-dir-btn.active::before { opacity:1; background:#fff; }   /* BẬT: chấm sáng trắng */
.interp-seg .interp-dir-btn.active:hover { background:#0598b0; color:#fff;
  box-shadow:0 2px 9px rgba(6,182,212,.55); }

/* v2.34: "Đọc to" = công tắc toggle on/off (track + knob trượt, phản hồi nhấn/nhả rõ). */
.interp-tts { display:inline-flex; flex:0 0 auto; align-items:center; gap:8px;
  height:32px; padding:0 11px 0 9px; border:1px solid var(--border,#e2e8f0); border-radius:8px;
  font-size:12.5px; font-weight:500; color:inherit; cursor:pointer; user-select:none;
  transition:background .18s ease, border-color .18s ease, box-shadow .18s ease; }
.interp-tts:hover { background:var(--interp-accent-dim,rgba(6,182,212,.10));
  border-color:var(--interp-accent,#06b6d4); box-shadow:0 2px 8px rgba(6,182,212,.18); }
/* ẩn checkbox native nhưng giữ chức năng + accessibility */
.interp-tts input { position:absolute; opacity:0; width:0; height:0; margin:0; pointer-events:none; }
/* track công tắc */
.interp-tts-track { position:relative; flex:0 0 auto; width:36px; height:20px; border-radius:10px;
  background:var(--surface-2,#cbd5e1); border:1px solid var(--border,#e2e8f0);
  transition:background .22s ease, border-color .22s ease, box-shadow .15s ease; }
/* knob trượt */
.interp-tts-knob { position:absolute; top:2px; left:2px; width:14px; height:14px;
  border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.35);
  transition:left .22s cubic-bezier(.34,1.56,.64,1), width .14s ease, background .22s ease; }
/* BẬT (checked): track cyan + quầng sáng, knob trượt sang phải */
.interp-tts input:checked ~ .interp-tts-track { background:var(--interp-accent,#06b6d4);
  border-color:var(--interp-accent,#06b6d4);
  box-shadow:0 0 0 3px var(--interp-accent-dim,rgba(6,182,212,.14)), 0 1px 4px rgba(6,182,212,.4); }
.interp-tts input:checked ~ .interp-tts-track .interp-tts-knob { left:18px; }
/* icon đổi theo trạng thái: 🔇 (tắt) → 🔊 (bật) */
.interp-tts-ic { margin-right:4px; }
.interp-tts-ic::before { content:"🔇"; font-size:13px; }
.interp-tts input:checked ~ .interp-tts-label .interp-tts-ic::before { content:"🔊"; }
/* nhấn (active): knob bè ra như nút thật — phản hồi nhấn/nhả sinh động */
.interp-tts:active .interp-tts-track .interp-tts-knob { width:18px; }
.interp-tts input:checked:active ~ .interp-tts-track .interp-tts-knob { left:14px; width:18px; }
.interp-tts:active .interp-tts-track { box-shadow:inset 0 1px 3px rgba(0,0,0,.18); }
/* focus bàn phím */
.interp-tts input:focus-visible ~ .interp-tts-track {
  box-shadow:0 0 0 3px var(--interp-accent-dim,rgba(6,182,212,.3)); }
/* nhãn: mờ khi TẮT, sáng accent khi BẬT → trạng thái rõ ràng */
.interp-tts-label { transition:color .2s ease, opacity .2s ease; white-space:nowrap; }
.interp-tts input:not(:checked) ~ .interp-tts-label { opacity:.5; }
.interp-tts input:checked ~ .interp-tts-label { color:var(--interp-accent,#06b6d4); font-weight:600; }

/* v2.28→v2.30: cặp ngôn ngữ gọn — nhóm inline trong .interp-bar (host-only).
   Collapsed chỉ hiện MÃ (VN/EN/JA…) + caret; bấm mở danh sách native đầy đủ. */
.interp-lang-row { display:inline-flex; flex:0 0 auto; align-items:center; gap:5px; }
.interp-lang-dd { position:relative; display:inline-flex; align-items:center;
  height:32px; border:1px solid var(--border,#e2e8f0); border-radius:8px;
  background:var(--surface); transition:border-color .18s ease, box-shadow .18s ease; }
.interp-lang-dd:hover { border-color:var(--interp-accent,#06b6d4); }
.interp-lang-dd:focus-within { border-color:var(--interp-accent,#06b6d4);
  box-shadow:0 0 0 2px var(--interp-accent-dim,rgba(6,182,212,.25)); }
/* select trong suốt nhưng vẫn bấm được → mở popup native (= danh sách đầy đủ) */
.interp-lang-select { appearance:none; -webkit-appearance:none; border:none; outline:none;
  background:transparent; color:transparent; width:58px; height:30px; padding:0;
  font-size:12px; cursor:pointer; }
.interp-lang-select option { color:var(--text); }   /* popup vẫn đọc được */
.interp-lang-face { position:absolute; inset:0; display:flex; align-items:center;
  justify-content:center; gap:4px; pointer-events:none; }
.interp-lang-code { font-size:13px; font-weight:700; color:var(--text);
  letter-spacing:.3px; }
.interp-lang-caret { font-size:10px; line-height:1; color:var(--text-dim); }
/* v2.33: mũi tên đảo cặp — to + rõ, hover xoay 180° gợi ý "bấm để đảo". */
.interp-lang-swap { width:34px; height:32px; flex:0 0 auto; border:1px solid var(--border,#e2e8f0);
  border-radius:8px; background:var(--surface); color:var(--interp-accent,#06b6d4);
  font-size:18px; font-weight:800; cursor:pointer; line-height:1;
  transition:background .18s ease, border-color .18s ease, transform .25s ease, box-shadow .18s ease; }
.interp-lang-swap:hover { background:var(--interp-accent-dim,rgba(6,182,212,.14));
  border-color:var(--interp-accent,#06b6d4); transform:rotate(180deg) scale(1.06); }
.interp-lang-swap:active { transform:rotate(180deg) scale(.92); }
.interp-lang-hint { font-size:11px; color:var(--text-dim); font-style:italic; min-width:0; }

/* v2.31→v2.33: trạng thái FIXED (dịch cố định 1 chiều) — cặp ngôn ngữ sáng accent,
   mũi tên → nền cyan ĐẶC + đậm; auto → mũi tên ⇄ viền trung tính (tương phản rõ). */
.interp-lang-row.fixed .interp-lang-dd { border-color:var(--interp-accent,#06b6d4); }
.interp-lang-row.fixed .interp-lang-swap { background:var(--interp-accent,#06b6d4);
  color:#fff; border-color:var(--interp-accent,#06b6d4);
  box-shadow:0 2px 8px rgba(6,182,212,.5); }
.interp-lang-row.fixed .interp-lang-swap:hover { background:#0598b0; border-color:#0598b0; }

/* v2.35: nhóm ghi audio — dot trạng thái + Start/Pause + Stop + đồng hồ, đẩy mép phải.
   Trạng thái cả nhóm ở #interpRecRow[data-state] = idle | recording | paused. */
.interp-rec-row { display:inline-flex; flex:0 0 auto; align-items:center; gap:7px;
  margin-left:auto; }

/* Dot trạng thái: idle xám · recording đỏ nhấp nháy · paused hổ phách (đứng yên) */
.interp-rec-dot { width:9px; height:9px; border-radius:50%; flex-shrink:0;
  background:var(--text-dim,#94a3b8); transition:background .3s; }
.interp-rec-row[data-state="recording"] .interp-rec-dot { background:#ef4444;
  animation:rec-blink 1.2s ease-in-out infinite; }
.interp-rec-row[data-state="paused"] .interp-rec-dot { background:#f59e0b; }
@keyframes rec-blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* Nút tròn chung (Start/Pause + Stop) */
.interp-rec-btn, .interp-rec-stop { display:flex; align-items:center; justify-content:center;
  width:28px; height:28px; border-radius:50%; border:1px solid var(--border,#e2e8f0); cursor:pointer;
  background:var(--surface); color:var(--text-dim); line-height:1;
  transition:background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease; }
.interp-rec-btn span, .interp-rec-stop span { line-height:1; display:inline-block; }
.interp-rec-btn:active:not(:disabled), .interp-rec-stop:active:not(:disabled) { transform:scale(.9); }

/* v2.37: icon vẽ bằng CSS để KHÔNG bị font fallback → ❚❚ ra hình vuông lẫn với Stop.
   Start/Pause: ▶ tam giác (ghi/tiếp tục) khi idle/paused; ‖ hai vạch (tạm dừng) khi recording. */
.interp-rec-btn .interp-rec-ic-play  { flex:0 0 auto; width:0; height:0; border-style:solid;
  border-width:5px 0 5px 8px; border-color:transparent transparent transparent currentColor;
  margin-left:2px; }
.interp-rec-btn .interp-rec-ic-pause { flex:0 0 auto; display:inline-flex; align-items:center; gap:3px; }
.interp-rec-btn .interp-rec-ic-pause::before,
.interp-rec-btn .interp-rec-ic-pause::after { content:""; display:block;
  width:3px; height:11px; border-radius:1px; background:currentColor; }
.interp-rec-row[data-state="recording"] .interp-rec-btn .interp-rec-ic-play  { display:none; }
.interp-rec-row:not([data-state="recording"]) .interp-rec-btn .interp-rec-ic-pause { display:none; }
.interp-rec-btn { color:#10b981; border-color:rgba(16,185,129,.45); }
.interp-rec-btn:hover { background:rgba(16,185,129,.14); border-color:#10b981; transform:scale(1.08); }
.interp-rec-row[data-state="recording"] .interp-rec-btn { color:#f59e0b; border-color:rgba(245,158,11,.5); }
.interp-rec-row[data-state="recording"] .interp-rec-btn:hover { background:rgba(245,158,11,.16); border-color:#f59e0b; }

/* Stop: ■ vuông đỏ (vẽ CSS); mờ + khoá khi chưa ghi (idle) */
.interp-rec-stop { color:#ef4444; border-color:rgba(239,68,68,.45); }
.interp-rec-stop .interp-rec-ic-stop { flex:0 0 auto; display:block; width:10px; height:10px;
  border-radius:2px; background:currentColor; }
.interp-rec-stop:hover:not(:disabled) { background:rgba(239,68,68,.16); border-color:#ef4444; transform:scale(1.08); }
.interp-rec-stop:disabled { color:var(--text-dim,#cbd5e1); border-color:var(--border,#e2e8f0);
  cursor:default; opacity:.45; }

.interp-rec-value { font-size:11px; color:var(--text-dim); font-variant-numeric:tabular-nums; white-space:nowrap; }
.interp-rec-value.live { color:var(--text-primary); }

/* v2.30: VU meter mic — nằm gọn trong nhóm ghi audio (chỉ hiện khi đang chạy) */
.interp-rec-row .interp-mic { margin:0; padding:0; background:transparent; height:auto;
  flex:0 0 auto; display:flex; align-items:center; gap:0; }
.interp-mic-label { white-space:nowrap; }
/* VU meter — báo mức audio vào mic (v2.27.2) */
.interp-meter { display:inline-block; width:54px; height:6px; border-radius:3px;
  background:var(--border,#e2e8f0); overflow:hidden; }
.interp-meter-fill { display:block; height:100%; width:0%; border-radius:3px;
  background:var(--interp-accent,#06b6d4); transition:width .1s linear, background .2s; }
