/* ITC Web UI — Trắng-xanh kiểu Bootstrap thân thiện + dark mode. */

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --border: #d8e0ea;
  --text: #0a1929;
  --text-dim: #4a5b70;
  --accent: #0d6efd;
  --accent-soft: #e7f0ff;
  --en: #0a3a8c;
  --vn: #b91c1c;
  --vn-bg: #fff5f5;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --chat-mine-bg: #e7f0ff;
  --chat-other-bg: #f0f3f7;
  --shadow: 0 1px 3px rgba(10,25,41,0.08), 0 1px 2px rgba(10,25,41,0.04);
  --radius: 10px;
  --gap: 12px;
  --font-en: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-vn: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Be Vietnam Pro", sans-serif;
  --header-h: 56px;
  --footer-h: 40px;
  --tabs-h: 0px;
}

body.dark {
  --bg: #0b1220;
  --surface: #121a2b;
  --surface-2: #0e1626;
  --border: #1d2a44;
  --text: #e6edf7;
  --text-dim: #94a3b8;
  --accent: #4ea1ff;
  --accent-soft: #142036;
  --en: #93c5fd;
  --vn: #fda4af;
  --vn-bg: #261213;
  --chat-mine-bg: #142036;
  --chat-other-bg: #0e1626;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

* { 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; }

/* ─────────────── 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: 14px; }
.brand .logo { font-size: 26px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.brand .tagline { margin: 0; font-size: 12px; 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: 560px; margin: 50px auto; text-align: center; color: var(--text-dim);
}
.placeholder h3 { font-weight: 600; font-size: 20px; color: var(--text); }
.placeholder.small { margin: 30px auto; }
.placeholder .hint {
  margin-top: 20px; font-size: 13px; padding: 12px 16px;
  background: var(--accent-soft); border-radius: var(--radius); display: inline-block;
}

.cap {
  margin: 0 auto 14px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid; grid-template-columns: 64px 1fr 30px; gap: 12px; align-items: start;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.cap.new { animation: slideIn 0.25s ease-out; border-color: var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.cap.bookmarked { border-left: 3px solid #facc15; background: linear-gradient(to right, #fef9c3 0%, var(--surface) 30%); }
body.dark .cap.bookmarked { background: linear-gradient(to right, #422006 0%, var(--surface) 30%); }
.cap .ts {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--text-dim); padding-top: 3px; line-height: 1.4;
}
.cap .ts .end { color: var(--text-dim); opacity: 0.6; font-size: 10px; }
.cap .body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cap .en { font-family: var(--font-en); color: var(--en); font-size: 14px; line-height: 1.5; }
.cap .vn {
  font-family: var(--font-vn); color: var(--text); font-weight: 500;
  font-size: 16px; line-height: 1.55;
  padding: 5px 9px; background: var(--vn-bg);
  border-left: 3px solid var(--vn); border-radius: 4px;
}
.cap .actions-mini {
  display: flex; flex-direction: column; gap: 2px; align-items: center; padding-top: 2px;
}
.cap .star, .cap .copy, .cap .reply-btn {
  background: transparent; border: 0; font-size: 16px; padding: 3px;
  opacity: 0.4; cursor: pointer; transition: all 0.15s;
}
.cap .star:hover, .cap .copy:hover, .cap .reply-btn:hover { opacity: 1; transform: scale(1.2); }
.cap.bookmarked .star { opacity: 1; color: #f59e0b; }

body.hide-en .cap .en { display: none; }
body.hide-vn .cap .vn { display: none; }
body.hide-slides .slide-strip { display: none; }

/* ─────────────── 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; border-radius: 8px; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 16px; cursor: pointer; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }

/* ───── 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; }

/* ───── 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); }

/* ───── Reactions pill row dưới mỗi bubble ───── */
.reactions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.reaction {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; cursor: pointer; transition: all 0.15s;
}
.reaction:hover { transform: scale(1.05); }
.reaction.mine { background: var(--accent-soft); border-color: var(--accent); }
.reaction .count { font-weight: 700; font-size: 11px; }

/* ───── 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 ───── */
.chat-input-row .icon-btn { flex-shrink: 0; }

/* ───── 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; }

/* 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; }


/* ─────────────── 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: 10px;
  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; }

.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 {
  flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit;
}
.chat-input-row input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.chat-input-row button { border-radius: 18px; padding: 8px 18px; }

/* ─────────────── 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;
}
.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;
}

/* ─────────────── 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; }
}
