/* cfharness web — UX v3 "giống claude.ai": nền kem ấm, chữ nâu-xám, nhấn cam đất, serif cho tiêu đề + hội thoại.
 * Sáng/tối theo hệ thống. Sidebar thu gọn được (desktop), chỉ icon (tablet), tab đáy (mobile).
 * Không phụ thuộc CDN/font ngoài (chỉ font hệ thống). Không style inline (CSP style-src 'self'). Icon: /static/icons.svg (sprite). */

/* ============================================================ token */
:root {
  /* nền + bề mặt (kem ấm) */
  --bg: #faf9f5; --side-bg: #f5f4ed; --surface: #ffffff; --surface-2: #f5f4ed; --surface-3: #efede4;
  --bubble: #f0eee6; --composer: #ffffff;
  /* chữ */
  --text: #1f1e1d; --text-2: #3d3929; --muted: #6b6a64; --faint: #8a887d;
  --line: #e8e6dc; --line-2: #dad7cb;
  /* nhấn "cam đất" */
  --accent: #b85a3a; --accent-hover: #a44f33; --accent-soft: #f7ebe4; --accent-text: #a24c2b; --on-accent: #ffffff; --accent-mark: #d97757;
  /* trạng thái — dịu, ấm */
  --ok: #46733d; --ok-soft: #edf3e8; --ok-line: #cadcbf; --on-ok: #ffffff;
  --warn: #975a10; --warn-soft: #fbf1e1; --warn-line: #ecd3a8;
  --danger: #b5412f; --danger-soft: #fbece8; --danger-line: #efc6bd; --on-danger: #ffffff;
  --info: #3f6d8c; --info-soft: #ebf2f6; --info-line: #c6d9e6;
  --ask: #7b5ea7; --ask-soft: #f2eef8; --ask-line: #d9cdea; --on-ask: #ffffff;
  --nav-active-bg: #ebe8dc;
  --code-bg: #f0eee6; --code-text: #3d3929;
  --shadow-sm: 0 1px 2px rgba(60, 50, 30, .04);
  --shadow: 0 1px 3px rgba(60, 50, 30, .06), 0 1px 2px rgba(60, 50, 30, .04);
  --shadow-lg: 0 14px 36px rgba(60, 50, 30, .13), 0 2px 6px rgba(60, 50, 30, .05);
  --shadow-composer: 0 4px 20px rgba(60, 50, 30, .06), 0 0 0 .5px rgba(60, 50, 30, .04);
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 22px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --fs-xs: 12px; --fs-sm: 13px; --fs: 14.5px; --fs-md: 15.5px; --fs-lg: 18px; --fs-xl: 24px; --fs-2xl: 28px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", "Noto Serif", serif;
  --side-w: 264px; --set-w: 232px; --set-content-w: 720px; --rail-w: 60px; --tab-h: 62px; --read-w: 768px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262624; --side-bg: #1f1e1d; --surface: #30302e; --surface-2: #2b2a28; --surface-3: #3a3936;
    --bubble: #141413; --composer: #30302e;
    --text: #f5f4ee; --text-2: #e3e1d8; --muted: #a6a398; --faint: #8b897f;
    --line: #3d3c38; --line-2: #4b4a45;
    --accent: #d97757; --accent-hover: #e2876a; --accent-soft: #3d2c24; --accent-text: #e9a084; --on-accent: #1f1e1d; --accent-mark: #d97757;
    --ok: #8fbf7f; --ok-soft: #273024; --ok-line: #3c4c35; --on-ok: #1a2216;
    --warn: #e0a85a; --warn-soft: #352b1d; --warn-line: #5a4628;
    --danger: #e98b78; --danger-soft: #3a2420; --danger-line: #633630; --on-danger: #1f1e1d;
    --info: #8db8d6; --info-soft: #222d35; --info-line: #344a5a;
    --ask: #bba3df; --ask-soft: #2e2838; --ask-line: #4a3f5e; --on-ask: #1f1e1d;
    --nav-active-bg: #3a3936;
    --code-bg: #1f1e1d; --code-text: #e3e1d8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25); --shadow: 0 1px 3px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
    --shadow-composer: 0 4px 20px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(255, 255, 255, .04);
    color-scheme: dark;
  }
}

/* ============================================================ nền */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs)/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-family: var(--serif); font-size: var(--fs-xl); line-height: 1.25; margin: 0; letter-spacing: -.01em; font-weight: 500; }
h2 { font-size: var(--fs-md); margin: 0 0 var(--s3); font-weight: 600; letter-spacing: -.005em; }
h3 { font-size: var(--fs); margin: var(--s4) 0 var(--s2); font-weight: 640; }
p { margin: 0 0 var(--s3); }
code, pre, .pre, kbd { font-family: var(--mono); font-size: .86em; }
code { background: var(--code-bg); color: var(--code-text); padding: .1em .38em; border-radius: 5px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); color: var(--code-text); padding: var(--s3) var(--s4); border-radius: var(--r); overflow: auto; white-space: pre-wrap; word-break: break-word; margin: var(--s2) 0; line-height: 1.5; }
.pre { white-space: pre-wrap; word-break: break-word; }
ul, ol { margin: 0 0 var(--s3); padding-left: 1.3rem; }
.muted { color: var(--muted); } .faint { color: var(--muted); } .small { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); }
.strong { font-weight: 650; }
.ok-t { color: var(--ok); } .warn-t { color: var(--warn); } .danger-t { color: var(--danger); } .info-t { color: var(--info); }
.inline { display: inline; } .inline-h { display: inline; margin: 0; }
.row { display: flex; align-items: center; } .gap { gap: var(--s2); } .row.end { justify-content: flex-end; } .between { justify-content: space-between; }
.wrap-row { flex-wrap: wrap; gap: var(--s2); }
.grow { flex: 1 1 14rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num, .tnum { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.wordmark { font-family: var(--serif); font-weight: 500; letter-spacing: -.015em; }

/* icon */
.ic { width: 18px; height: 18px; flex: 0 0 auto; vertical-align: -.22em; }
.ic.sm { width: 15px; height: 15px; } .ic.lg { width: 22px; height: 22px; } .ic.xl { width: 28px; height: 28px; }

/* ============================================================ khung: sidebar + main + tab đáy */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; background: linear-gradient(to right, var(--side-bg) calc(var(--side-w) - 1px), var(--line) calc(var(--side-w) - 1px), var(--line) var(--side-w), var(--bg) var(--side-w)); }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--side-bg); border-right: 1px solid var(--line); padding: 10px 10px 10px; overflow: hidden; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 4px 2px 10px 6px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 19px; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand .ic { width: 26px; height: 26px; color: var(--accent-mark); flex: 0 0 auto; }
.side-toggle { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.side-toggle:hover { background: var(--surface-3); color: var(--text); }
/* nút chuyển 2D/3D (#view-toggle — docs/dev-notes/office-3d.md): chữ "3D"/"2D", bật = nền nhấn */
.view-toggle { min-width: 32px; height: 32px; padding: 0 7px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 12px; font-weight: 650; letter-spacing: .02em; line-height: 1; font-variant-numeric: tabular-nums; }
.view-toggle:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.view-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.view-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.side-view { margin-left: auto; }
.side-new { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px; margin: 2px 0 8px; border-radius: 10px; color: var(--text); font-weight: 560; white-space: nowrap; }
.side-new:hover { background: var(--surface-3); text-decoration: none; }
.side-new-ic { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; transition: transform .15s; }
.side-new:hover .side-new-ic { transform: scale(1.06) rotate(90deg); }
.side-new-ic .ic { width: 16px; height: 16px; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 0 1 auto; overflow-y: auto; min-height: 0; }
.nav-group { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); padding: 12px 10px 4px; white-space: nowrap; }
.nav-group:first-child { padding-top: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px 0 10px; border-radius: 8px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 450; white-space: nowrap; }
.nav a .ic { color: var(--muted); width: 17px; height: 17px; }
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--nav-active-bg); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav a.on .ic { color: var(--accent-mark); }
.nav .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 650; color: var(--on-accent); background: var(--accent); font-variant-numeric: tabular-nums; }
.badge.danger { background: var(--danger); color: var(--on-danger); } .badge.ask { background: var(--ask); color: var(--on-ask); }
.side-recents { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.side-recents .mgr-convs a { padding: 6px 10px; }
.side-recents .mgr-convs .cm { display: none; }
.side-recents .mgr-convs .ct { font-weight: 450; }
.side-none { padding: 6px 10px; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); }
.side-foot form { margin: 0; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 2px 6px; min-width: 0; }
.side-av { width: 30px; height: 30px; border-radius: 50%; background: var(--text-2); color: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; font-size: 13px; flex: 0 0 auto; }
.side-user-t { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.side-user-t .nm { font-weight: 600; font-size: var(--fs-sm); }
.daemon-st { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.daemon-st .ic { width: 9px; height: 9px; color: var(--ok); }
.daemon-st.down .ic { color: var(--danger); } .daemon-st.down { color: var(--danger); }
.side-btn { justify-content: flex-start !important; }
.side-foot > .side-btn { width: 100%; }
/* chat-first: vùng HỘI THOẠI trên mọi trang (_side_convs.html), mục tạm "Cài đặt › …" khi đang ở trang cấu hình */
.side-recents .side-more .ct { color: var(--muted); font-weight: 450; }
/* Dừng khẩn cấp — luôn hiện ở chân thanh bên */
.estop-ctl { display: flex; gap: 6px; margin: 0; width: 100%; }
.estop-ctl .side-btn, .estop-ctl.side-btn { flex: 1 1 auto; min-width: 0; }
.estop-ctl .btn { height: 32px; }
.estop-btn { width: 100%; background: transparent; box-shadow: none; }
.estop-on .estop-off { flex: 0 0 auto; }
/* menu người dùng (khối "Bạn" ở chân) — mở lên trên */
.side-menu { display: block; width: 100%; }
.side-menu > summary.side-user { cursor: pointer; border-radius: 10px; padding: 6px 6px 6px 6px; }
.side-menu > summary.side-user:hover, .side-menu[open] > summary.side-user { background: var(--surface-3); }
.side-user-more .ic { color: var(--muted); width: 16px; height: 16px; }
.side-menu .side-menu-pop { top: auto; bottom: calc(100% + 6px); left: 0; right: 0; min-width: 232px; }
.side-menu-pop a.item.on { background: var(--nav-active-bg); font-weight: 600; }
.side-menu-pop .item-sub { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); font-weight: 450; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.menu-dot.off, .upd-flag.off { display: none; }
.upd-flag { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
/* ============================================================ khu Cài đặt (layout 2 cột: cột nav con thay thanh bên chính) */
.shell.set { grid-template-columns: var(--set-w) minmax(0, 1fr); background: linear-gradient(to right, var(--side-bg) calc(var(--set-w) - 1px), var(--line) calc(var(--set-w) - 1px), var(--line) var(--set-w), var(--bg) var(--set-w)); }
.sset { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--side-bg); border-right: 1px solid var(--line); padding: 12px 10px 10px; overflow: hidden; }
.set-back { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border-radius: 8px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.set-back:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.set-back .ic { width: 16px; height: 16px; color: var(--muted); }
.set-h { display: block; padding: 10px 10px 6px; font-size: 18px; font-weight: 650; color: var(--text); letter-spacing: -.01em; }
.set-h:hover { text-decoration: none; color: var(--accent-text); }
.snav { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 8px; }
.snav-g { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding: 14px 10px 4px; white-space: nowrap; }
.snav a { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 8px 6px 10px; border-radius: 8px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 450; line-height: 1.25; }
.snav a .ic { color: var(--muted); width: 16px; height: 16px; flex: 0 0 auto; }
.snav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.snav a.on { background: var(--nav-active-bg); color: var(--text); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.snav a.on .ic { color: var(--accent-mark); }
/* chân cột: nút Dừng khẩn cấp luôn đủ chữ (không theo luật thanh bên thu gọn / màn vừa) */
.shell.set .sset .sset-foot { align-items: stretch; width: auto; }
.shell.set .sset .estop-ctl { flex-direction: row; align-items: stretch; }
.shell.set .sset .estop-ctl .side-btn, .shell.set .sset .estop-ctl.side-btn, .shell.set .sset .side-foot .side-btn { width: auto; flex: 1 1 auto; padding: 0 12px; justify-content: flex-start !important; }
.shell.set .sset .estop-off { display: block; }
.shell.set .sset .lbl { display: inline; }
/* nội dung một tab: tối đa ~720px, giữa vùng còn lại */
.set-page { max-width: var(--set-content-w); margin: 0 auto; }
.set-page code { overflow-wrap: anywhere; }
.set-page .card { box-shadow: none; }
.set-mback { display: none; align-items: center; gap: 6px; margin: 0 0 var(--s2) -4px; padding: 6px 4px; color: var(--accent-text); font-size: var(--fs-sm); font-weight: 550; }
.set-mback .ic { width: 16px; height: 16px; }
/* trang danh mục /settings: danh sách kiểu iOS Settings */
.set-group { margin-bottom: var(--s5); }
.set-group-h { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 6px 4px; }
.set-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.set-list li + li { border-top: 1px solid var(--line); }
.set-anchor { display: block; height: 0; scroll-margin-top: 80px; }
.set-row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; color: var(--text); }
.set-row:hover { background: var(--surface-2); text-decoration: none; }
.set-row > .ic { width: 18px; height: 18px; color: var(--accent-mark); flex: 0 0 auto; }
.set-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.set-t b { font-weight: 600; font-size: var(--fs-sm); }
.set-d { color: var(--muted); font-size: var(--fs-xs); }
.set-row .set-chev { width: 16px; height: 16px; color: var(--muted); flex: 0 0 auto; }
/* Vùng nguy hiểm (tab Chung & an toàn) */
.danger-zone { border-color: var(--danger-line); }
.danger-zone > h2 { color: var(--danger); }
.danger-zone > h2 .ic { color: var(--danger); }
.danger-zone.on { background: linear-gradient(0deg, var(--danger-soft), var(--surface) 80%); }
.dz-item { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; scroll-margin-top: 80px; }
.dz-t { flex: 1 1 260px; min-width: 0; }
.dz-t h3 { display: flex; align-items: center; gap: var(--s2); margin: 0 0 4px; font-size: var(--fs-md, 15.5px); }
.dz-t p { margin: 4px 0 0; }
.dz-act { display: flex; flex-direction: column; gap: var(--s2); align-items: stretch; flex: 0 0 auto; }
.dz-act .btn { width: 100%; justify-content: center; }
/* hàng cấu hình: nhãn + gợi ý trái, ô nhập + Lưu phải (cột 280px, mọi ô rộng bằng nhau) */
.cfg-rows { display: flex; flex-direction: column; }
.cfg-row { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: var(--s3); align-items: center; padding: 10px 0; }
.cfg-row + .cfg-row { border-top: 1px solid var(--line); }
.cfg-lbl { min-width: 0; }
.cfg-lbl code { overflow-wrap: anywhere; }
.cfg-ctl { display: flex; gap: var(--s2); align-items: flex-start; margin: 0; min-width: 0; }
.cfg-ctl > select, .cfg-ctl > input, .cfg-ctl > .msel { flex: 1 1 auto; min-width: 0; width: 100%; max-width: none; }
.cfg-ctl > .btn { flex: 0 0 auto; }
.cfg-ctl .msel textarea { width: 100%; margin-top: 4px; }

.shell.noside { display: block; background: var(--bg); }
.main { min-width: 0; display: flex; flex-direction: column; }
.mtop { display: none; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 28px 32px 64px; }
.tabbar { display: none; }

/* thanh bên thu gọn (bấm nút, nhớ theo người xem) — cùng luật với màn vừa bên dưới */
@media (min-width: 761px) {
  html.side-min { --side-w: var(--rail-w); }
  html.side-min .side { padding: 10px 8px; align-items: center; }
  html.side-min .side-top { flex-direction: column; padding: 4px 0 8px; gap: 6px; }
  html.side-min .side-view { margin-left: 0; }
  html.side-min .lbl, html.side-min .nav-group, html.side-min .side-recents { display: none; }
  html.side-min .side-new { padding: 0; width: 40px; justify-content: center; }
  html.side-min .nav { width: 100%; align-items: stretch; }
  html.side-min .nav a { justify-content: center; padding: 0; position: relative; height: 38px; }
  html.side-min .nav a .badge { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  html.side-min .nav-sep { display: block; height: 1px; background: var(--line); margin: 6px 6px; }
  html.side-min .side-foot { align-items: center; width: 100%; }
  html.side-min .side-user { flex-direction: column; padding: 0; gap: 6px; }
  html.side-min .side-btn { justify-content: center !important; width: 36px; padding: 0; }
  html.side-min .estop-ctl { flex-direction: column; align-items: center; }
  html.side-min .estop-off, html.side-min .menu-dot { display: none; }
  html.side-min .side-menu .side-menu-pop { left: 0; right: auto; }
}

/* ============================================================ đầu trang */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head .ph-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-head h1 { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: var(--fs-sm); }
.page-head h1 { font-size: 28px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s2); flex-wrap: wrap; }
.crumbs a { color: var(--muted); } .crumbs a:hover { color: var(--text); }
.crumbs .ic { width: 13px; height: 13px; }
.lead { color: var(--text-2); margin: -12px 0 var(--s5); max-width: 70ch; }

/* ============================================================ thẻ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: var(--s4); box-shadow: var(--shadow-sm); }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 560px; margin: var(--s6) auto; }
.card.narrow.wide { max-width: 820px; }
.card.attention { border-color: var(--danger-line); box-shadow: 0 0 0 3px var(--danger-soft), var(--shadow-sm); }
.card.notice { border-color: var(--info-line); box-shadow: 0 0 0 3px var(--info-soft), var(--shadow-sm); }
.card.archived, tr.archived { opacity: .6; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); flex-wrap: wrap; }
.card-head h2 { margin: 0; display: flex; align-items: center; gap: var(--s2); }
.card-head h2 .ic { color: var(--accent-mark); }
h2 > .ic { color: var(--accent-mark); }
.card-sub { color: var(--muted); font-size: var(--fs-sm); margin: -6px 0 var(--s3); }
details.card > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--s2); }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-right: 4px; }
details.card[open] > summary::before { transform: rotate(45deg); }
details.card[open] > summary { margin-bottom: var(--s3); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s4); align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0 var(--s4); align-items: start; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin: var(--s5) 0 var(--s3); }
.section-title h2 { margin: 0; }

/* trống */
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); padding: 28px var(--s4); font-size: var(--fs-sm); }
.empty .ic { width: 30px; height: 30px; color: var(--faint); }
.empty b { color: var(--text-2); font-size: var(--fs); }
.empty.ok .ic { color: var(--ok); }
.empty.compact { padding: var(--s4); flex-direction: row; justify-content: center; }
.empty.compact .ic { width: 20px; height: 20px; }

/* số liệu */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat { position: relative; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); color: var(--text); }
a.stat:hover { border-color: var(--line-2); text-decoration: none; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.stat-l { color: var(--muted); font-size: var(--fs-sm); font-weight: 520; }
.stat-n { font-family: var(--serif); font-size: var(--fs-2xl); font-weight: 500; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-s { color: var(--muted); font-size: var(--fs-xs); }
.stat-ic { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--muted); }
.stat-ic .ic { width: 18px; height: 18px; }
.stat.tone-ok .stat-ic { background: var(--ok-soft); color: var(--ok); }
.stat.tone-ask .stat-ic { background: var(--ask-soft); color: var(--ask); }
.stat.tone-accent .stat-ic { background: var(--accent-soft); color: var(--accent); }
.stat.alert { border-color: var(--danger-line); background: linear-gradient(0deg, var(--danger-soft), var(--surface) 70%); }
.stat.alert .stat-n { color: var(--danger); } .stat.alert .stat-ic { background: var(--danger-soft); color: var(--danger); }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
progress.meter { width: 100%; appearance: none; -webkit-appearance: none; border: 0; display: block; }
progress.meter::-webkit-progress-bar { background: var(--surface-3); }
progress.meter::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress.meter::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* ============================================================ nhãn */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 550; white-space: nowrap; background: var(--surface-3); color: var(--muted); border: 1px solid transparent; line-height: 1; vertical-align: middle; }
.pill .ic { width: 12px; height: 12px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); } .pill.info { background: var(--info-soft); color: var(--info); }
.pill.ask { background: var(--ask-soft); color: var(--ask); } .pill.accent { background: var(--accent-soft); color: var(--accent-text); }
.pill.outline { background: transparent; border-color: var(--line-2); color: var(--text-2); }
.pill.strong { font-weight: 700; } .pill.danger.strong { background: var(--danger); color: var(--on-danger); }
.pill.lg { height: 26px; font-size: var(--fs-sm); padding: 0 11px; }
.pill.ok .ic.pulse, .live-dot .ic { animation: pulse 1.6s ease-in-out infinite; }
a.pill:hover { text-decoration: none; filter: brightness(.97); }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; margin: 0 4px 4px 0; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 560; }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); }
@keyframes pulse { 50% { opacity: .35; } }
.live-dot { animation: none; }

/* ============================================================ nút */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--line-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.btn.ok:hover { filter: brightness(1.07); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger-line); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 12px; font-size: var(--fs-xs); border-radius: 999px; }
.btn.sm .ic { width: 14px; height: 14px; }
.btn.lg { height: 42px; padding: 0 18px; font-size: var(--fs); }
.btn.icon { width: 36px; padding: 0; } .btn.sm.icon { width: 30px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }
.htmx-request .btn[type=submit], form.htmx-request button { opacity: .6; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* menu "⋯" (details) */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; }
.menu-pop form { display: block; margin: 0; }
.menu-pop .btn, .menu-pop a.item { width: 100%; justify-content: flex-start; border: 0; box-shadow: none; background: transparent; height: 34px; color: var(--text); font-weight: 520; border-radius: 7px; padding: 0 10px; display: flex; align-items: center; gap: 8px; }
.menu-pop .btn:hover, .menu-pop a.item:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .btn.danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ============================================================ bảng */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.tbl th { text-align: left; font-weight: 550; color: var(--muted); font-size: var(--fs-xs); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .actions form { display: inline; }
.tbl .title-cell { max-width: 32rem; }
.tbl .title-cell .t { color: var(--text); font-weight: 520; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .title-cell .s { color: var(--muted); font-size: var(--fs-xs); }
.card.flush .tbl th:first-child, .card.flush .tbl td:first-child { padding-left: 20px; }
.card.flush .tbl th:last-child, .card.flush .tbl td:last-child { padding-right: 20px; }
.id { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); }
.task-cell { max-width: 28rem; }

/* ============================================================ form */
.form label, .filters label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: var(--s3); }
input, select, textarea { font: inherit; font-size: var(--fs); color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 11px; width: 100%; min-height: 38px; transition: border-color .12s, box-shadow .12s; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; line-height: 1.5; }
select[multiple] { min-height: 5rem; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--accent); margin: 0; flex: 0 0 auto; }
.check { flex-direction: row !important; align-items: flex-start; gap: var(--s2) !important; font-weight: 450 !important; color: var(--text) !important; }
.check input { margin-top: 3px; }
.hint { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s4); min-width: 0; }
legend { font-weight: 680; margin-bottom: var(--s2); font-size: var(--fs-md); padding: 0; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s4); }
.fgrid .span2, .kv .span2 { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-end; margin-bottom: var(--s4); }
.filters label { margin: 0; } .filters select, .filters input { width: auto; }
.filters .btn, .filters select, .filters input:not([type=checkbox]):not([type=radio]) { height: 38px; min-height: 38px; }
.inline-f { margin: 0; } .inline-f select { width: auto; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s2); }
.checks .check { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin: 0; background: var(--surface); }
.checks .check > span { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.checks .check span span { display: inline; }
.checks .check .pill { display: inline-flex; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s2); }
.tpl { position: relative; display: block !important; margin: 0 !important; cursor: pointer; }
.tpl input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tpl-body { display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; height: 100%; background: var(--surface); font-weight: 400; transition: border-color .12s, background .12s; }
.tpl:hover .tpl-body { border-color: var(--line-2); }
.tpl input:checked + .tpl-body { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
.tpl input:focus-visible + .tpl-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.cfg input { max-width: 16rem; }
.cfg select, .cfg .msel { max-width: 16rem; }
.cfg-group { border-top: 1px solid var(--line); padding: var(--s2) 0; }
.cfg-group > summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: var(--s2); }
.cfg-group[open] > summary { margin-bottom: var(--s2); }
.msel { position: relative; width: 100%; }
.msel > summary { cursor: pointer; list-style: none; border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 11px; min-height: 38px; background: var(--surface); }
.msel > summary::-webkit-details-marker { display: none; }
.msel > summary::after { content: "▾"; float: right; color: var(--muted); }
.msel-list { position: absolute; z-index: 20; left: 0; min-width: 100%; max-height: 18rem; overflow: auto; margin-top: 4px; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-lg); }
.msel-list .check { margin: 4px 0; white-space: nowrap; }
.cmd { user-select: all; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 4px 12px; border-radius: 999px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 560; }
.seg a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg a:hover { text-decoration: none; color: var(--text); }

/* ============================================================ thông báo (toast — tự ẩn bằng CSS, không cần JS) */
.toasts { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: var(--s2); max-width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.flash { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toast-in .2s ease-out; }
.flash .ic { margin-top: 1px; }
.flash.ok .ic { color: var(--ok); } .flash.error .ic { color: var(--danger); }
.flash.error { border-color: var(--danger-line); }
.flash.ok { animation: toast-in .2s ease-out, toast-out .4s ease-in 6s forwards; }
.flash .t { flex: 1; overflow-wrap: anywhere; }
.toast-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; height: 24px; width: 24px; flex: 0 0 auto; margin: -2px -4px -2px 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.toast-x:hover { background: var(--surface-3); color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); visibility: hidden; } }
.mgr-err.flash { position: static; box-shadow: none; animation: none; margin: var(--s2) 0 0; }
.banner { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--r); margin-bottom: var(--s4); border: 1px solid transparent; font-size: var(--fs-sm); flex-wrap: wrap; }
.banner .ic { flex: 0 0 auto; }
.banner.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.banner.info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.banner a { color: inherit; font-weight: 650; text-decoration: underline; }
.banner a.btn { text-decoration: none; }
.banner a.btn.primary { color: var(--on-accent); }
.banner form { display: inline; }

/* ============================================================ "Cần bạn": duyệt + câu hỏi */
.need { display: flex; flex-direction: column; gap: var(--s3); }
.need-strip { margin-bottom: var(--s4); }
.need-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); }
.need-head h2 { margin: 0; display: flex; gap: var(--s2); align-items: center; }
.xcard { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); padding: 16px 18px; position: relative; }
.xcard::before { content: ""; position: absolute; left: -1px; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--warn); }
.xcard.human::before { background: var(--danger); }
.xcard.ask::before { background: var(--ask); }
.xcard.done { opacity: .78; } .xcard.done::before { background: var(--ok); }
.xcard-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.xcard-ic { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; background: var(--warn-soft); color: var(--warn); }
.xcard.human .xcard-ic { background: var(--danger-soft); color: var(--danger); }
.xcard.ask .xcard-ic { background: var(--ask-soft); color: var(--ask); }
.xcard.done .xcard-ic { background: var(--ok-soft); color: var(--ok); }
.xcard-title { flex: 1; min-width: 0; }
.xcard-title .t { font-weight: 650; font-size: var(--fs); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.xcard-title .m { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.xcard-why { color: var(--muted); font-size: var(--fs-sm); margin: 8px 0 0; }
.xcard-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: 14px; align-items: center; }
.xcard-actions form { display: inline; margin: 0; }
.xcard .spacer { flex: 1; }
.approval-what { margin: .25rem 0; }
.action-full { margin: 4px 0; }
.cmd-full { max-height: 14rem; overflow: auto; margin: 6px 0; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; border: 1px solid var(--line); background: var(--code-bg); }
.cmd-full.long { max-height: 20rem; }
.cmd-full mark { background: var(--warn-soft); color: var(--warn); font-weight: 700; border-radius: 3px; padding: 0 .1em; outline: 1px solid var(--warn-line); }
.cmd-full mark.ctl { background: var(--danger); color: var(--on-danger); outline: 0; }
.action-meta { color: var(--muted); font-size: var(--fs-xs); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* câu hỏi */
.q-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; font-family: var(--serif); font-size: 16.5px; line-height: 1.55; color: var(--text); margin: 4px 0 12px; }
.q-note { display: flex; gap: 8px; align-items: flex-start; background: var(--surface-2); border-radius: var(--r); padding: 9px 12px; font-size: var(--fs-sm); color: var(--text-2); margin-bottom: 12px; }
.q-note .ic { color: var(--muted); margin-top: 2px; }
.q-note .pre { flex: 1; }
.q-opts { display: grid; gap: 8px; margin: 0 0 12px; }
.q-opt { display: flex; align-items: flex-start; gap: 11px; border: 1px solid var(--line-2); border-radius: var(--r); padding: 11px 13px; cursor: pointer; background: var(--surface); transition: border-color .12s, background .12s, box-shadow .12s; }
.q-opt:hover { border-color: var(--ask); }
.q-opt input { margin-top: 3px; accent-color: var(--ask); }
.q-opt:has(input:checked) { border-color: var(--ask); background: var(--ask-soft); box-shadow: 0 0 0 1px var(--ask) inset; }
.q-opt-k { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.q-opt:has(input:checked) .q-opt-k { background: var(--ask); color: var(--on-ask); }
.q-opt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.q-opt-l { font-weight: 600; overflow-wrap: anywhere; white-space: pre-wrap; }
.q-opt-d { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; white-space: pre-wrap; }
.q-free textarea { min-height: 64px; }
.q-free label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.q-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.q-quick form { display: inline; margin: 0; }
.q-quick .btn { height: auto; min-height: 34px; padding: 6px 12px; white-space: normal; text-align: left; justify-content: flex-start; max-width: 100%; }
.q-quick .q-opt-k { margin-right: 2px; }
.q-answer { display: flex; gap: 8px; align-items: flex-start; background: var(--ok-soft); color: var(--text); border-radius: var(--r); padding: 10px 12px; font-size: var(--fs-sm); }
.q-answer .ic { color: var(--ok); margin-top: 2px; }
.q-answer .pre { flex: 1; }

/* ============================================================ agent (lưới thẻ) */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.acard { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); min-width: 0; position: relative; }
.acard.st-working { border-color: var(--ok-line); }
.acard.st-waiting_human, .acard.st-waiting { border-color: var(--danger-line); }
.acard.st-asking { border-color: var(--ask-line); }
.acard-top { display: flex; gap: 11px; align-items: center; }
.acard-st { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 600; font-size: 16px; background: var(--accent-soft); color: var(--accent-text); flex: 0 0 auto; text-transform: uppercase; }
.avatar.c1 { background: var(--ok-soft); color: var(--ok); } .avatar.c2 { background: var(--info-soft); color: var(--info); }
.avatar.c3 { background: var(--ask-soft); color: var(--ask); } .avatar.c4 { background: var(--warn-soft); color: var(--warn); }
.acard-name { min-width: 0; flex: 1; }
.acard-name a { color: var(--text); font-weight: 650; font-size: var(--fs); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acard-name .r { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acard-doing { font-size: var(--fs-sm); color: var(--text-2); min-height: 2.9em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.acard-doing.idle { color: var(--muted); }
.acard-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); border-top: 1px solid var(--line); padding-top: 10px; margin-top: auto; }
.acard-foot .k { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }

/* ============================================================ run */
.run-head { display: flex; flex-direction: column; gap: 14px; }
.run-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.run-title .who { font-size: var(--fs-lg); font-weight: 680; color: var(--text); }
.run-title-text { color: var(--text-2); font-size: var(--fs); overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 18px; margin: 0; }
.kv.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv.one { grid-template-columns: minmax(0, 1fr); }
.kv dt { color: var(--muted); font-size: var(--fs-xs); font-weight: 560; margin-bottom: 2px; }
.kv dd { margin: 0; font-weight: 560; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dd .small, .kv dd .muted { font-weight: 450; }
.chips-kv { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-kv .chip { height: 26px; font-size: var(--fs-sm); padding: 0 10px; background: var(--surface-2); border: 1px solid var(--line); }
.chips-kv .chip b { font-weight: 650; color: var(--text); }
.chips-kv .chip .ic { width: 14px; height: 14px; color: var(--muted); }

.transcript { display: flex; flex-direction: column; gap: 10px; max-height: 72vh; overflow: auto; padding: 2px 4px 2px 0; scroll-behavior: smooth; }
.ti { border-radius: var(--r); }
.ti.msg { padding: 2px 2px; }
.ti.msg .md { font-family: var(--serif); font-size: 16px; line-height: 1.65; color: var(--text); }
.ti.prompt, .ti.steer { background: var(--bubble); padding: 11px 16px; border: 1px solid transparent; margin-left: 12%; border-radius: 18px; }
.ti.steer { background: var(--info-soft); }
.ti-label { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ti.prompt .pre, .ti.steer .pre { font-family: inherit; font-size: var(--fs); }
.ti.start { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.ti.start::before, .ti.start::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.ti.tool { background: var(--surface-2); border: 1px solid var(--line); padding: 7px 11px; font-size: var(--fs-sm); }
.ti.tool.running { border-color: var(--info-line); background: var(--info-soft); }
.ti.tool.err { border-color: var(--danger-line); background: var(--danger-soft); }
.ti.tool.sub { margin-left: 22px; }
.tool-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tool-line .ic { align-self: center; color: var(--muted); width: 14px; height: 14px; }
.ti.tool.err .tool-line .ic { color: var(--danger); } .ti.tool.running .tool-line .ic { color: var(--info); }
.tool-name { font-family: var(--mono); font-weight: 700; font-size: 12.5px; }
.tool-args { font-family: var(--mono); color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; flex: 1; min-width: 0; }
.tool-res { margin-top: 4px; }
.tool-res summary { color: var(--muted); font-size: var(--fs-xs); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.tool-res pre { max-height: 18rem; font-size: 12px; }
.spin { color: var(--info); font-size: var(--fs-xs); animation: pulse 1.2s ease-in-out infinite; }
.diff { font-size: 12px; padding: 8px 10px; margin: 6px 0 0; }
.diff .add { color: var(--ok); } .diff .del { color: var(--danger); } .diff .more { color: var(--muted); }
.diff span { display: inline; }
.ti.approval-ti, .ti.question-ti { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--warn-line); background: var(--warn-soft); font-size: var(--fs-sm); }
.ti.approval-ti .ic { color: var(--warn); margin-top: 2px; }
.ti.approval-ti.human { border-color: var(--danger-line); background: var(--danger-soft); } .ti.approval-ti.human .ic { color: var(--danger); }
.ti.approval-ti.resolved { border-color: var(--line); background: var(--surface-2); } .ti.approval-ti.resolved .ic { color: var(--muted); }
.ti.question-ti { border-color: var(--ask-line); background: var(--ask-soft); } .ti.question-ti .ic { color: var(--ask); }
.ti.question-ti.answered { border-color: var(--ok-line); background: var(--ok-soft); } .ti.question-ti.answered .ic { color: var(--ok); }
.ti-body { flex: 1; min-width: 0; }
.ti-body .pre { overflow-wrap: anywhere; }
.ti.end { display: flex; gap: 10px; align-items: center; font-weight: 600; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-sm); }
.ti.end.ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok-line); }
.ti.end.danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.ti.end.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.ti.end.muted { color: var(--muted); }
.ti.end .small { font-weight: 450; }
.ti.note { font-size: var(--fs-sm); color: var(--muted); display: flex; gap: 6px; align-items: baseline; padding: 0 4px; }
.ti.note.danger { color: var(--danger); } .ti.note.ok { color: var(--ok); } .ti.note.info { color: var(--info); } .ti.note.warn { color: var(--warn); }
.ti.reasoning summary { color: var(--muted); font-style: italic; font-size: var(--fs-sm); cursor: pointer; }
.ti.reasoning pre { font-style: italic; color: var(--muted); max-height: 14rem; font-family: var(--sans); }
.ti.msg.streaming .md { white-space: pre-wrap; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .4rem 0; } .md ul, .md ol { margin: .35rem 0; padding-left: 1.4rem; }
.md h1, .md h2, .md h3 { font-size: var(--fs-md); margin: .8rem 0 .3rem; }
.md table { border-collapse: collapse; } .md td, .md th { border: 1px solid var(--line); padding: .25rem .5rem; }
.md pre { font-size: 12.5px; }
.result { padding: 2px 0 10px; }
.soul { max-height: 24rem; font-size: 12.5px; }
.sticky-bottom { position: sticky; bottom: 12px; z-index: 5; box-shadow: var(--shadow-lg); }
.composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); align-items: end; background: var(--composer); border: 1px solid var(--line-2); border-radius: var(--r-xl); padding: 8px 8px 8px 14px; box-shadow: var(--shadow-composer); }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow-composer), 0 0 0 1px var(--accent); }
.composer textarea { min-height: 40px; border: 0; background: transparent; box-shadow: none; resize: none; padding: 8px 0; }
.composer textarea:focus { box-shadow: none; }
.composer .btn { height: 38px; }
.sticky-bottom.card { border-radius: var(--r-xl); }

/* hoạt động */
.feed { list-style: none; margin: 0; padding: 0; max-height: 26rem; overflow: auto; font-size: var(--fs-sm); }
.fl { padding: 8px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; }
.fl:last-child { border-bottom: 0; }
.fl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); align-self: center; justify-self: center; }
.fl.ok .fl-dot { background: var(--ok); } .fl.danger .fl-dot { background: var(--danger); } .fl.warn .fl-dot { background: var(--warn); }
.fl.info .fl-dot { background: var(--info); } .fl.ask .fl-dot { background: var(--ask); }
.fl-main { min-width: 0; overflow-wrap: anywhere; color: var(--text-2); }
.fl-agent { font-weight: 650; color: var(--text); margin-right: 4px; }
.fl-text { overflow-wrap: anywhere; }
.fl.danger .fl-text { color: var(--danger); }
.fl-ts { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed .empty { padding: 20px 0; }

/* ============================================================ kanban + task */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: var(--s3); overflow-x: auto; padding-bottom: var(--s2); }
.kanban .col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 10px; min-height: 9rem; }
.kanban h3 { margin: 2px 2px 10px; display: flex; justify-content: space-between; align-items: center; font-size: var(--fs-sm); }
.tcard { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: 8px; color: var(--text); box-shadow: var(--shadow-sm); transition: border-color .12s, transform .12s; }
.tcard:hover { border-color: var(--accent); text-decoration: none; }
.tcard.tcard-changed { border-color: var(--accent); animation: tcard-flash 1.6s ease-out; }  /* thẻ vừa đổi (bảng realtime, app.js) */
@keyframes tcard-flash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: var(--shadow-sm); } }
@media (prefers-reduced-motion: reduce) { .tcard.tcard-changed { animation: none; outline: 2px solid var(--accent); outline-offset: -1px; } }
.tcard-title { font-weight: 620; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.tcard .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-xs); }
.tcard .ask-t { color: var(--ask); font-weight: 600; font-size: var(--fs-xs); display: flex; gap: 4px; align-items: center; }
.empty-col { text-align: center; padding: 14px 4px; color: var(--muted); font-size: var(--fs-xs); }
.dag { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.dag-node { display: inline-flex; gap: 8px; align-items: center; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: var(--fs-sm); }
.dag-node.self { border-color: var(--accent); background: var(--accent-soft); }
.dag-arrow { color: var(--faint); padding-left: 14px; }
.comment { border-bottom: 1px solid var(--line); padding: 10px 0; }
.comment:last-of-type { border-bottom: 0; }
.comment-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); margin-bottom: 4px; }
.comment.answer { background: var(--ok-soft); border-radius: var(--r); padding: 10px 12px; border: 0; margin: 6px 0; }

/* ============================================================ chi phí */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 6.5rem 1fr 4.5rem; gap: 10px; align-items: center; font-size: var(--fs-sm); }
.bar-v { text-align: right; font-variant-numeric: tabular-nums; }
progress.bar { width: 100%; height: 8px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
progress.bar::-webkit-progress-bar { background: var(--surface-3); border-radius: 99px; }
progress.bar::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress.bar::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

/* ============================================================ hộp xác nhận */
.dlg { border: 1px solid var(--line); border-radius: var(--r-xl); padding: 22px 24px; max-width: min(540px, calc(100vw - 32px)); width: 100%; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dlg::backdrop { background: rgba(31, 30, 29, .45); backdrop-filter: blur(2px); }
.dlg h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; }
.dlg-msg, .confirm-msg { white-space: pre-wrap; font-size: var(--fs); margin-top: 0; overflow-wrap: anywhere; }
.dlg-msg { max-height: 50vh; overflow: auto; font-family: var(--mono); font-size: 13px; background: var(--surface-2); border-radius: var(--r); padding: 12px; }
.dlg textarea { margin: 6px 0 14px; }
.dlg label { font-size: var(--fs-sm); font-weight: 600; }
.login .cmd { font-size: 1rem; }
.totp-qr { width: min(260px, 100%); margin: var(--s3) auto; padding: 8px; background: #fff; border-radius: 8px; }
.totp-qr svg { display: block; width: 100%; height: auto; }
.login h1 { margin-bottom: var(--s3); font-size: 22px; }
.login-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 48px auto -8px; text-align: center; }
.login-hero .wordmark { font-size: 34px; color: var(--text); }
.login-tag { color: var(--muted); font-family: var(--serif); font-size: 17px; margin: 0; }
.hero-mark { width: 52px; height: 52px; color: var(--accent-mark); }

/* ============================================================ Điều phối (chat kiểu claude.ai) — chữ của điều phối viên là dữ liệu: pre-wrap */
/* Danh sách cuộc trò chuyện (thanh bên + menu màn hẹp) */
.mgr-convs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.mgr-convs li a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text-2); overflow: hidden; }
.mgr-convs li a:hover { background: var(--surface-3); text-decoration: none; }
.mgr-convs li a.on { background: var(--surface-3); color: var(--text); }
.mgr-convs .ct { display: block; font-weight: 500; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mgr-convs .cm { display: block; color: var(--muted); font-size: var(--fs-xs); }
.mgr-convs-m { display: none; }
.mgr-convs-m .menu-pop { left: 0; right: auto; width: min(320px, calc(100vw - 32px)); max-height: 60vh; overflow: auto; }
/* Luồng việc (docs/dev-notes/workstreams.md): hàng tab luồng trên khung chat, hội thoại của luồng ở thanh bên, tiến độ/ghi chú ở panel phải */
.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ws-add { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; color: var(--muted); padding: 0 6px; border-radius: 6px; font-size: var(--fs-sm); }
.ws-add:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.ws-bar { display: flex; align-items: center; gap: 6px; padding: 6px 16px 8px; border-bottom: 1px solid var(--line); position: relative; }
.ws-tabs { display: flex; gap: 4px; overflow-x: auto; min-width: 0; flex: 0 1 auto; scrollbar-width: none; }
.ws-tabs::-webkit-scrollbar { display: none; }
.ws-tab { display: inline-flex; align-items: center; gap: 6px; flex: none; max-width: 220px; padding: 5px 12px; border-radius: 999px;
  font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
  border: 1px solid transparent; list-style: none; }
.ws-tab::-webkit-details-marker { display: none; }
.ws-tab:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.ws-tab.on { background: var(--surface-3); color: var(--text); font-weight: 500; border-color: var(--line); }
.ws-tab.closed { opacity: .7; }
.ws-tab.add { color: var(--accent-text); }
.ws-tab.more { color: var(--muted); }
.ws-pop-wrap { flex: none; position: relative; }
.ws-pop-wrap > .ws-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(340px, calc(100vw - 32px)); }
.ws-pop { display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.ws-pop.ws-inline { flex-direction: row; }
.ws-pop .mgr-convs { max-height: 50vh; overflow: auto; }
.ws-inline { display: flex; gap: 6px; align-items: center; }
.ws-inline input, .ws-inline select { flex: 1 1 auto; min-width: 0; font: inherit; font-size: var(--fs-sm); padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.ws-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.ws-dot.ok { background: var(--ok); }
.ws-dot.danger { background: var(--danger); }
.ws-dot.done { background: var(--muted); opacity: .6; }
/* đang chạy: chấm xanh có vòng lan ra; đã xong: dấu ✓ nhỏ; chưa có việc: không chấm */
/* vòng lan bằng ::after transform + opacity (chạy trên compositor) — KHÔNG animation box-shadow vô hạn (vẽ lại mỗi khung hình) */
.ws-dot.run { background: var(--ok); position: relative; }
.ws-dot.run::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--ok); opacity: .6; animation: ring-ping 1.4s ease-out infinite; }
.ws-dot.done { width: 9px; height: 9px; background: none; opacity: 1; position: relative; }
.ws-dot.done::after { content: ""; position: absolute; left: 2px; top: 0; width: 3px; height: 6px; border: solid var(--muted);
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.ws-dot.none { display: none; }
.mgr-convs .ct .ws-dot { display: inline-block; margin-right: 6px; vertical-align: middle; }
@keyframes ring-ping { from { transform: scale(1); opacity: .55; } to { transform: scale(2.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ws-dot.run::after { animation: none; opacity: 0; } }
/* đổi tab/hội thoại không tải lại trang: mờ khung chat trong lúc chờ */
.ws-unread { flex: none; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.mgr-convs .ct .ws-unread { display: inline-block; margin-left: 6px; }
.conv-menu .menu-pop { right: 0; left: auto; }
.ws-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; list-style: none; cursor: default; }
.ws-side-head h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-info { gap: 10px; }
.ws-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: var(--fs-sm); }
.ws-meta dt { color: var(--muted); }
.ws-meta dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ws-state > summary { cursor: pointer; }
.ws-state > summary::-webkit-details-marker { display: none; }
.ws-state[open] .btn { display: none; }
.ws-progress { width: 100%; height: 6px; margin: 10px 0 4px; appearance: none; border: 0; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.ws-progress::-webkit-progress-bar { background: var(--surface-3); }
.ws-progress::-webkit-progress-value { background: var(--ok); }
.ws-progress::-moz-progress-bar { background: var(--ok); }
.ws-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ws-form textarea { font-family: var(--mono, monospace); font-size: var(--fs-xs); min-height: 160px; }
.ws-state-pre { white-space: pre-wrap; word-break: break-word; font-size: var(--fs-xs); background: var(--surface-3); border-radius: 8px;
  padding: 8px 10px; margin: 8px 0 0; max-height: 280px; overflow: auto; }
.ws-tasks { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.ws-tasks li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ws-tasks li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-tasks li.done { opacity: .6; }
.ws-side .btn-row { margin-top: 8px; }
.danger-t { color: var(--danger); }
@media (max-width: 720px) { .ws-bar { padding: 6px 10px 8px; } .ws-pop-wrap { position: static; } .ws-pop-wrap > .ws-pop { left: 10px; right: 10px; width: auto; } }

/* Bố cục: trang chat chiếm trọn chiều cao, log cuộn bên trong, ô nhập dính đáy */
.chat-page .main { height: 100vh; height: 100dvh; }
.chat-page .wrap { max-width: none; padding: 0; flex: 1 1 auto; min-height: 0; display: flex; }
.mgr-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; flex: 1 1 auto; min-height: 0; width: 100%; }
html.mgr-info-closed .mgr-grid { grid-template-columns: minmax(0, 1fr) 0; }
html.mgr-info-closed .mgr-side { display: none; }
.mgr-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; position: relative; }
.chat-head { display: flex; align-items: center; gap: var(--s2); padding: 10px 16px; min-height: 56px; background: var(--bg); position: relative; z-index: 3; }
.chat-head::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 18px; background: linear-gradient(var(--bg), transparent); pointer-events: none; }
.chat-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; padding-left: 4px; }
.chat-title .ct { font-weight: 550; font-size: var(--fs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.chat-sub { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 2px; }
.chat-tools { display: flex; align-items: center; gap: 4px; }
.chat-tools .btn.icon, .chat-head .btn.icon { color: var(--muted); }
.chat-tools .btn.icon:hover { color: var(--text); }
#mgr-live { margin-right: 4px; }

/* KHÔNG scroll-behavior: smooth trên log (giật khi chữ chạy) — cuộn mượt chỉ ở nút "↓ Tin mới nhất"; overflow-anchor: none để
   trình duyệt không tự neo cuộn khi khung "đang trả lời" lớn dần (app.js tự bám đáy khi người đang ở đáy) */
.mgr-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-anchor: none; display: flex; flex-direction: column; gap: 22px;
  padding: 20px max(20px, calc((100% - var(--read-w)) / 2)) 28px; }
.mgr-log > *, .transcript > * { flex-shrink: 0; }

/* tin nhắn: người = bong bóng xám ấm căn phải; điều phối viên = không bong bóng, chữ serif */
.mm { max-width: 100%; }
.mm-who { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mm-who a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 2px; }
.mm-text { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.mm.user { align-self: flex-end; max-width: min(85%, 640px); display: flex; flex-direction: column; align-items: flex-end; }
.mm.user .mm-text { background: var(--bubble); color: var(--text); border-radius: 18px; padding: 10px 16px; font-size: 15px; line-height: 1.55; }
.mm.mgr { align-self: stretch; }
/* P0-5: chữ điều phối viên = markdown (present.md) trong tx_msg; tin liên tiếp của điều phối viên không lặp dòng tên */
.mm-md .md { font-family: var(--serif); font-size: 16.5px; line-height: 1.7; color: var(--text); }
.mm-md { padding: 0; }
.mm.mgr + .mm.mgr:not(.notify) > .mm-who { display: none; }
/* P1-5: hàng thao tác dưới tin — hiện khi rê chuột/focus; tin cuối và màn cảm ứng luôn hiện */
/* tệp điều phối viên nhắc tới (đường dẫn tuyệt đối trong chữ) → chip Xem/Mở/Thư mục — file-open.md §6 */
.mm-files { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; }
.mm-file { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.mm-file > code { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.mm-foot { display: flex; align-items: center; gap: 2px; margin-top: 4px; min-height: 28px; font-size: var(--fs-xs); color: var(--muted); opacity: 0; transition: opacity .15s; }
.mm-foot > time, .mm-foot > a { padding: 0 6px; white-space: nowrap; }
.mm-foot > a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 2px; }
.mm:hover > .mm-foot, .mm:focus-within > .mm-foot, .mm.mgr.last > .mm-foot { opacity: 1; }
@media (hover: none) { .mm-foot { opacity: 1; } }
.mm.user > .mm-foot { flex-direction: row-reverse; margin-right: 2px; }
.mm-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.mm-btn:hover, .mm-btn:focus-visible { background: var(--surface-3); color: var(--text); }
.mm-btn.done { color: var(--ok); }
.mm-retry { display: none; }
.mm.mgr.last .mm-retry { display: inline-flex; }
.mm-src { display: none; }
.mm-mark { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; color: var(--accent-mark); margin-right: 2px; }
.mm-mark .ic { width: 18px; height: 18px; }
.mm.mgr.notify { border-left: 3px solid var(--warn); padding-left: 14px; }
/* khung "đang trả lời": suy nghĩ gập (P1-4), chữ chạy (nháp markdown do server vẽ + đuôi delta thô), dòng "Đang dùng …" */
.mm-live .md:empty { display: none; }
.mm.pending:not(.has-text) .mm-live { display: none; }
.mm.pending.has-text .mm-state { display: none; }
.mm.pending.has-text .mm-live::after { content: ""; display: inline-block; width: .55em; height: 1.05em; margin-left: 2px; vertical-align: -.15em; border-radius: 2px; background: var(--accent-mark); animation: caret 1s steps(2) infinite; }
.mm-think { margin: 2px 0 8px; font-size: var(--fs-sm); color: var(--muted); }
.mm-think > summary { cursor: pointer; width: fit-content; padding: 2px 8px 2px 0; }
.mm-think > summary:hover { color: var(--text); }
.mm-think pre { margin: 6px 0 0; padding: 4px 0 4px 12px; border-left: 2px solid var(--line-2); background: transparent; color: var(--muted); font-family: var(--sans); font-size: var(--fs-sm); white-space: pre-wrap; max-height: 16rem; overflow: auto; }
.mm-tool { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); font-size: var(--fs-sm); min-width: 0; }
.mm-tool[hidden] { display: none; }
.mm-tool-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mm-mark.thinking .ic { animation: think-spin 2.4s cubic-bezier(.45, .05, .55, .95) infinite; }
.mm.pending .mm-who { font-size: var(--fs-sm); }
.mm.pending .spin { color: var(--muted); font-size: var(--fs-sm); background: linear-gradient(90deg, var(--muted) 30%, var(--text) 50%, var(--muted) 70%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shimmer 1.8s linear infinite; }
@keyframes think-spin { 0% { transform: rotate(0) scale(1); } 50% { transform: rotate(180deg) scale(.82); } 100% { transform: rotate(360deg) scale(1); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes caret { 50% { opacity: 0; } }

/* P1-3: chip "✓ Đã làm N việc ›" không viền; mở ra = danh sách gọn có vạch trái; đang chạy = vòng quay + việc mới nhất */
.mm-acts { align-self: flex-start; max-width: 100%; font-size: var(--fs-sm); }
.mm-acts > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 10px 4px 6px; margin-left: -6px; border-radius: 999px; color: var(--muted); }
.mm-acts > summary:hover { background: var(--surface-2); color: var(--text-2); }
.mm-acts > summary::-webkit-details-marker { display: none; }
.mm-acts-ic { display: inline-flex; align-items: center; color: var(--ok); }
.mm-acts.err .mm-acts-ic { color: var(--danger); }
.mm-acts-ic .tx-spin { display: none; }
.mm-acts.running .mm-acts-ic .tx-spin { display: inline-block; }
.mm-acts.running .mm-acts-ic .ic { display: none; }
.mm-acts-n { white-space: nowrap; font-weight: 550; }
.mm-acts-last { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-acts-last:empty { display: none; }
.mm-acts-last::before { content: "· "; }
.mm-acts:not(.running)[open] .mm-acts-last { display: none; }
.mm-acts .chev { flex: 0 0 auto; transition: transform .15s; }
.mm-acts[open] .chev { transform: rotate(90deg); }
.mm-acts-list { margin: 6px 0 2px 9px; padding-left: 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.mm-act { display: flex; gap: 9px; align-items: flex-start; padding: 9px 14px; }
.mm-acts-list .mm-act { padding: 0; }
.mm-act-ic { color: var(--ok); margin-top: 2px; } .mm-act.err .mm-act-ic { color: var(--danger); }
.mm-act-body { min-width: 0; flex: 1; }
.mm-act-sum { overflow-wrap: anywhere; font-weight: 500; }
.mm-act-meta { font-size: var(--fs-xs); color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-top: 2px; }
.mgr-log > .mm-act { align-self: flex-start; max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.mgr-log > .mm-act.err { border-color: var(--danger-line); }
.mgr-log .xcard { max-width: 100%; align-self: stretch; }
.mm-note { align-self: center; font-size: var(--fs-xs); color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; }
.mm-note.danger { color: var(--danger); } .mm-note.warn { color: var(--warn); }

/* màn trống: lời chào lớn giữa màn + logo; ô nhập dồn lên giữa */
.mgr-hero { padding: 0 0 6px; gap: 14px; color: var(--muted); }
.mgr-hero .hero-mark { width: 46px; height: 46px; color: var(--accent-mark); animation: hero-in .6s ease-out; }
.mgr-hero b { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 4.2vw, 40px); line-height: 1.2; color: var(--text); letter-spacing: -.015em; }
.mgr-hero span { max-width: 560px; font-size: var(--fs-sm); line-height: 1.55; }
@keyframes hero-in { from { opacity: 0; transform: rotate(-60deg) scale(.7); } }
.mgr-chat:has(#mgr-empty) .mgr-log { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.mgr-chat:has(#mgr-empty) .composer-wrap { margin-bottom: auto; padding-bottom: 48px; }
.mgr-chat:not(:has(#mgr-empty)) .mgr-suggest { display: none; }

/* ô nhập lớn bo tròn dính đáy, nút gửi tròn màu cam */
.composer-wrap { flex: 0 0 auto; padding: 0 max(16px, calc((100% - var(--read-w)) / 2)) 10px; background: linear-gradient(transparent, var(--bg) 18px); position: relative; z-index: 2; }
.mgr-form { display: flex; flex-direction: column; gap: 4px; background: var(--composer); border: 1px solid var(--line-2); border-radius: var(--r-xl); padding: 12px 12px 10px 16px; box-shadow: var(--shadow-composer); transition: border-color .15s, box-shadow .15s; }
.mgr-form:focus-within { border-color: var(--accent); box-shadow: var(--shadow-composer), 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.mgr-form textarea { border: 0; background: transparent; padding: 4px 0; min-height: 28px; max-height: 15rem; resize: none; box-shadow: none; font-size: 15.5px; line-height: 1.5; }
.mgr-form textarea:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.composer-hint { color: var(--muted); font-size: var(--fs-xs); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-bar .btn.attach { flex: 0 0 auto; margin-left: -6px; cursor: pointer; }
.mgr-files { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mgr-files li { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 4px 4px 6px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); font-size: var(--fs-sm); }
.mgr-files img { width: 32px; height: 32px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.mgr-files .fi-ic { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; background: var(--bubble); color: var(--text-2); font-size: 10px; font-weight: 600; text-transform: uppercase; flex: 0 0 auto; }
.mgr-files .fi-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mgr-files .fi-size { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.mgr-files button { border: 0; background: transparent; color: var(--text-2); cursor: pointer; padding: 2px 6px; border-radius: 6px; font: inherit; line-height: 1; }
.mgr-files button:hover { background: var(--bubble); }
.mgr-form.drop { border-color: var(--accent); border-style: dashed; }
.btn.send { width: 34px; height: 34px; padding: 0; border-radius: 50%; flex: 0 0 auto; box-shadow: none; margin-left: auto; }
.btn.send .ic { width: 18px; height: 18px; }
.btn.send[disabled] { opacity: .45; }
/* P0-6: nút gửi biến thành nút Dừng (ô trống + đang trả lời) */
.btn.send .i-stop { display: none; }
.btn.send.stop .i-send { display: none; }
.btn.send.stop .i-stop { display: inline-block; width: 14px; height: 14px; }
.btn.send.stop { background: var(--text); border-color: var(--text); color: var(--bg); }
/* nút "↓ Tin mới nhất" nổi trên ô nhập */
.mgr-jump { position: absolute; left: 50%; top: -42px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px 6px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--composer); color: var(--text-2); font: inherit; font-size: var(--fs-sm); box-shadow: var(--shadow-composer); cursor: pointer; white-space: nowrap; }
.mgr-jump:hover { color: var(--text); }
.mgr-jump[hidden] { display: none; }
.mgr-suggest { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 14px 0 0; }
.mgr-suggest button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 6px 13px; font: inherit; font-size: var(--fs-sm); font-weight: 450; cursor: pointer; transition: background .12s, border-color .12s; }
.mgr-suggest button .ic { color: var(--muted); }
.mgr-suggest button:hover { background: var(--surface-2); color: var(--text); }
.mgr-err.flash { position: static; box-shadow: none; animation: none; margin: var(--s2) 0 0; }
.chat-disclaimer { text-align: center; color: var(--muted); font-size: var(--fs-xs); margin: 8px 0 0; }

/* cột phải: thông tin điều phối viên */
.mgr-side { border-left: 1px solid var(--line); background: var(--bg); overflow-y: auto; padding: 14px 18px 24px; min-width: 0; }
.mgr-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mgr-side-head h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 18px; }
.mgr-side-sec { padding: 12px 0 16px; border-bottom: 1px solid var(--line); }
.mgr-side-sec:last-child { border-bottom: 0; }
.mgr-side-sec h3 { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--muted); font-weight: 550; }
#mgr-info-close { display: none; }
.mgr-ctl { margin-top: var(--s3); }
.mgr-side .feed { max-height: none; }
.mgr-st { display: flex; flex-direction: column; gap: 12px; }
.mgr-st-who { display: flex; align-items: center; gap: 10px; }
.mgr-intro ul { padding-left: 1.2rem; }
.mgr-mini-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s4); align-items: start; }
.mgr-mini .mgr-form { margin-top: var(--s3); flex-direction: row; align-items: flex-end; padding: 8px 8px 8px 14px; box-shadow: none; }
.mgr-mini .mgr-form textarea { flex: 1; }
.mgr-mini .mgr-form .btn { border-radius: 50%; width: 36px; height: 36px; }

/* màn < 1280: cột thông tin thành ngăn kéo bên phải (cần JS; không JS → cột cố định) */
@media (max-width: 1279px) {
  html.js .mgr-grid, html.js.mgr-info-closed .mgr-grid { grid-template-columns: minmax(0, 1fr); }
  html.js .mgr-side { display: block; position: fixed; z-index: 50; top: 0; right: 0; bottom: 0; width: min(360px, 92vw); box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .22s ease; visibility: hidden; }
  html.js.mgr-info-open .mgr-side { transform: none; visibility: visible; }
  html.js #mgr-info-close { display: inline-flex; }
}

/* ============================================================ màn vừa: sidebar chỉ icon */
@media (max-width: 1100px) and (min-width: 761px) {
  :root { --side-w: var(--rail-w); }
  .side { padding: 10px 8px; align-items: center; }
  .side-top { flex-direction: column; padding: 4px 0 8px; gap: 6px; }
  .side-toggle { display: none; }
  .side-view { margin-left: 0; }
  .side .lbl, .nav-group, .side-recents { display: none; }
  .side-new { padding: 0; width: 40px; justify-content: center; }
  .nav { width: 100%; align-items: stretch; }
  .nav a { justify-content: center; padding: 0; position: relative; height: 38px; }
  .nav a .badge { position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .nav-sep { height: 1px; background: var(--line); margin: 6px 6px; }
  .side-foot { align-items: center; width: 100%; }
  .side-user { flex-direction: column; padding: 0; gap: 6px; }
  .side-btn { justify-content: center !important; width: 36px; padding: 0; }
  .estop-ctl { flex-direction: column; align-items: center; }
  .estop-off, .menu-dot { display: none; }
  .side-menu .side-menu-pop { left: 0; right: auto; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1101px) { .nav-sep { display: none; } html.side-min .nav-sep { display: block; } }

/* ============================================================ màn nhỏ */
@media (max-width: 900px) {
  .grid2, .fgrid, .kv.cols, .mgr-mini-grid, .grid-main { grid-template-columns: minmax(0, 1fr); }
  .mgr-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .shell { display: block; background: var(--bg); }
  .side { display: none; }
  .mtop { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; justify-content: space-between; gap: var(--s2); padding: 8px 12px 8px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .mtop .brand { padding: 0; font-size: 18px; }
  .mtop .brand .ic { width: 24px; height: 24px; }
  .mtop-right { display: flex; gap: 6px; align-items: center; }
  .wrap { padding: var(--s4) 16px calc(var(--tab-h) + 32px); }
  .page-head { margin-bottom: var(--s4); }
  .page-head h1 { font-size: 23px; }
  .card { padding: 15px 16px; border-radius: var(--r-lg); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .stat { padding: 12px; } .stat-n { font-size: 23px; } .stat-ic { display: none; }
  .agent-grid { grid-template-columns: minmax(0, 1fr); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--side-bg); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar summary { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 550; position: relative; cursor: pointer; list-style: none; height: var(--tab-h); }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar a .ic, .tabbar summary .ic { width: 22px; height: 22px; }
  .tabbar a.on { color: var(--accent-text); font-weight: 650; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
  .tab-more { position: relative; }
  .tab-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + 8px + env(safe-area-inset-bottom)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 8px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .tab-sheet a { height: 64px; border-radius: 12px; color: var(--text-2) !important; }
  .tab-sheet a.on { background: var(--accent-soft); color: var(--accent-text) !important; }
  .shell.set { display: block; background: var(--bg); }
  .sset { display: none; }
  .set-mback { display: inline-flex; }
  .cfg-row { grid-template-columns: minmax(0, 1fr); gap: var(--s2); }
  .tabbar summary.on { color: var(--accent-text); font-weight: 650; }
  .tab-sheet .tab-estop { grid-column: 1 / -1; display: flex; }
  .tab-sheet .tab-estop .btn { height: 44px; font-size: var(--fs-sm); flex: 1 1 auto; justify-content: center !important; }
  .tab-sheet .tab-estop .estop-off .btn { flex: 0 0 auto; }
  .tab-sheet .tab-estop .estop-off { display: flex; }
  .tab-sheet .tab-out { display: contents; }
  .tab-sheet .tab-out button { height: 64px; border: 0; background: transparent; border-radius: 12px; font: inherit; font-size: 11px; font-weight: 550; color: var(--text-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; }
  .tab-sheet .tab-out button .ic { width: 22px; height: 22px; }
  .tab-sheet .tab-out button:hover { background: var(--surface-2); }
  /* trang chat: header chat của island thay .mtop (bớt một tầng thanh; ESTOP/mất kết nối đã hiện trong khung chat) */
  .chat-page .mtop { display: none; }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tab-h) + 12px); max-width: none; }
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td { display: block; width: 100%; }
  .tbl.stack tr { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 8px; padding: 8px 12px; background: var(--surface); }
  .tbl.stack tbody tr:hover td { background: transparent; }
  .tbl.stack td { border: 0; padding: 4px 0 !important; display: flex; gap: 12px; justify-content: space-between; text-align: right; }
  .tbl.stack td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); text-align: left; flex: 0 0 auto; font-weight: 550; }
  .tbl.stack td.actions { justify-content: flex-end; padding-top: 8px !important; }
  .tbl .title-cell { max-width: none; } .tbl .title-cell .t { white-space: normal; }
  .card.flush { padding: 8px; } .card.flush .tbl.stack tr:last-child { margin-bottom: 0; }
  .task-cell { max-width: none; }
  .kanban { grid-auto-columns: 82%; }
  .transcript { max-height: none; }
  .ti.prompt, .ti.steer { margin-left: 0; }
  .bar-row { grid-template-columns: 5rem 1fr 4rem; }
  .xcard { padding: 14px; }
  .xcard-actions .btn { flex: 1 1 auto; }
  .sticky-bottom { bottom: calc(var(--tab-h) + 8px); }
  .menu-pop { right: auto; left: 0; }
  /* chat trên điện thoại */
  .chat-page .main { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .chat-head { padding: 6px 8px 6px 6px; min-height: 48px; }
  .chat-sub, .composer-hint { display: none; }
  .mgr-convs-m { display: block; }
  .mgr-log { padding: 12px 16px 20px; gap: 18px; }
  .mm.user { max-width: 88%; }
  .mm.mgr .mm-text { font-size: 16px; }
  .composer-wrap { padding: 0 10px 8px; }
  .mgr-form { border-radius: 20px; padding: 10px 10px 8px 14px; }
  .chat-disclaimer { display: none; }
  .mgr-hero b { font-size: 28px; }
  .mgr-chat:has(#mgr-empty) .composer-wrap { padding-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; } }

/* ============================================================ trang bổ sung: tìm kiếm, lịch chạy, diff run, sức khoẻ (extra_pages.py) */
.side-search { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); }
.side-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.side-search .ic { width: 16px; height: 16px; flex: 0 0 auto; }
.side-search input { border: 0; background: transparent; padding: 0; min-height: 0; height: 100%; box-shadow: none !important; font-size: var(--fs-sm); }
.search-form { margin-bottom: var(--s4); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); margin-bottom: var(--s3); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.search-box > .ic { color: var(--muted); width: 18px; height: 18px; flex: 0 0 auto; }
.search-box input { border: 0; padding: 4px 0; box-shadow: none !important; background: transparent; }
.search-head { padding: 14px 20px 0; }
.hits { list-style: none; margin: 0; padding: 0; }
.hit { padding: 12px 20px; border-top: 1px solid var(--line); }
.hit:first-child { border-top: 0; }
.hit-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.hit-snip { margin: 6px 0 4px; overflow-wrap: anywhere; line-height: 1.55; }
.hit-snip mark, .udiff mark { background: var(--accent-soft); color: var(--accent-text); border-radius: 3px; padding: 0 .1em; font-weight: 600; }
.hit-link { display: inline-flex; align-items: center; gap: 2px; }
.hit-link .ic { width: 14px; height: 14px; }
.hit-groups { list-style: none; margin: 0; padding: 0; }
.hit-group { border-top: 1px solid var(--line); padding-top: 4px; }
.hit-group:first-child { border-top: 0; }
.hit-ghead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 20px 0; font-weight: 550; }
.hit-ghead > .ic { color: var(--muted); }
.hit-group .hit { border-top: 0; padding-top: 8px; padding-left: 44px; }
@media (max-width: 760px) { .hit-group .hit { padding-left: 20px; } }
.pager { padding: 10px 20px 14px; }
.sched-prompt { margin-top: 4px; } .sched-prompt .pre { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sched-tbl td.actions { white-space: normal; }
.sched-tbl td.actions form { margin: 2px 0 2px 4px; }
.dfiles { display: flex; flex-direction: column; gap: 6px; margin: var(--s2) 0; }
.dfile { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.dfile.touched { border-color: var(--danger-line); }
.dfile > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; }
.dpath { overflow-wrap: anywhere; font-size: 12.5px; }
.udiff { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); max-height: 32rem; overflow: auto; font-size: 12px; line-height: 1.45; padding: 6px 0; }
.udiff .dl { display: block; padding: 0 12px; white-space: pre; min-height: 1.45em; }
.udiff .dl.add { background: var(--ok-soft); color: var(--ok); }
.udiff .dl.del { background: var(--danger-soft); color: var(--danger); }
.udiff .dl.hunk { color: var(--info); background: var(--info-soft); }
.udiff .dl.meta { color: var(--muted); font-style: italic; }
.diff-actions { margin-top: var(--s3); }
.health { list-style: none; margin: 0 0 var(--s2); padding: 0; display: grid; gap: 6px; }
.hc { display: grid; grid-template-columns: 18px minmax(9rem, auto) 1fr; gap: 10px; align-items: baseline; font-size: var(--fs-sm); }
.hc .ic { width: 16px; height: 16px; align-self: center; }
.hc.ok .ic { color: var(--ok); } .hc.warn .ic { color: var(--warn); } .hc.danger .ic { color: var(--danger); }
.hc-n { font-weight: 600; } .hc-d { color: var(--text-2); overflow-wrap: anywhere; }
@media (max-width: 1100px) and (min-width: 761px) { .side-search { display: none; } }
@media (min-width: 761px) { html.side-min .side-search { display: none; } }
@media (max-width: 760px) {
  .hit, .pager, .search-head { padding-left: 12px; padding-right: 12px; }
  .hc { grid-template-columns: 18px 1fr; } .hc-d { grid-column: 2; }
  .udiff .dl { white-space: pre-wrap; overflow-wrap: anywhere; }
}

/* MCP (web/mcp_pages.py): danh sách chỉ đọc theo tài khoản claude */
.mcp-help > summary { cursor: pointer; }
.mcp-target code { overflow-wrap: anywhere; }
/* Slack 2 chiều (Cài đặt): mã ghép nối + khung cài app */
.pairbox { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 12px 14px; margin: var(--s3) 0; background: var(--bubble); }
.pairbox p { margin: 0 0 var(--s2); }
.pairbox .pair-code code { font-size: 1.25em; font-weight: 700; letter-spacing: .06em; user-select: all; }
.slack2-setup { margin-top: var(--s3); }
.slack2-setup > summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; }
/* Tài khoản Claude (Cài đặt, _accounts.html) */
.acct-rename > summary { list-style: none; display: inline-flex; }
.acct-rename > summary::-webkit-details-marker { display: none; }
.acct-rename[open] > form { margin-top: var(--s2); }
.acct-rename input[name="label"] { min-width: 0; width: 14em; max-width: 100%; }
.acct-connector { overflow-wrap: anywhere; } /* email dài không làm tràn ngang /settings ở 390px */
.acct-login { border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3); background: var(--surface); }
#acct-switch select { max-width: 100%; }
@media (max-width: 760px) { #acct-switch form { width: 100%; } #acct-switch select { flex: 1 1 auto; } }

/* ---- quản lý skill (web/skill_pages.py) ---- */
.skill-src { max-height: 70vh; font-size: 12.5px; }
.file-list { list-style: none; padding: 0; margin: 0 0 var(--s3); }
.file-list li { padding: 3px 0; overflow-wrap: anywhere; }
.form label.row { flex-direction: row; align-items: center; font-weight: 560; margin-bottom: var(--s2); }
.form .tier-pick select { width: auto; }
.filters label.row { flex-direction: row; align-items: center; }

/* ---- memory + graph memory (web/memory_pages.py, static/memory_graph.js) ---- */
.card.flush > .card-head.pad, .pad { padding: 12px 16px; }
.mem-usage { min-width: 140px; }
.mem-usage.warn progress.meter::-webkit-progress-value { background: var(--warn); }
.mem-usage.warn progress.meter::-moz-progress-bar { background: var(--warn); }
.mem-usage.danger progress.meter::-webkit-progress-value { background: var(--danger); }
.mem-usage.danger progress.meter::-moz-progress-bar { background: var(--danger); }
.mem-tiers tr.tier-first td { border-top: 1px solid var(--line-2); }
.mem-entries { list-style: none; padding: 0; margin: var(--s3) 0; counter-reset: me; }
.mem-entry { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-bottom: var(--s2); background: var(--surface); }
.mem-entry.pinned { border-color: var(--info-line); background: var(--info-soft); }
.mem-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.mem-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.mem-meta .spacer { flex: 1; }
.mem-add textarea, .mem-entry textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain > li { padding: 4px 0; overflow-wrap: anywhere; }
.g-edge { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.g-rel { font-family: var(--mono); font-size: 12px; color: var(--accent-text); background: var(--accent-soft); border-radius: 6px; padding: 0 6px; }
.graph-tbl .title-cell .t { white-space: pre-wrap; overflow-wrap: anywhere; }
.fact-text { font-family: var(--serif); font-size: var(--fs-md); white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: var(--s3); }
details.flagged > summary { cursor: pointer; }
.cons-ops li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.filters label.grow { flex: 1 1 260px; }
.filters label.grow input { width: 100%; }
.mg-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s4); align-items: start; }
.mg-card { padding: 10px; }
.mg-tools { flex-wrap: wrap; margin-bottom: 8px; }
.mg-tools .spacer { flex: 1; }
.mg-canvas { position: relative; height: 68vh; min-height: 420px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); overflow: hidden; touch-action: none; }
.mg-status { position: absolute; left: 12px; top: 8px; margin: 0; }
.mg-svg { display: block; width: 100%; height: 100%; cursor: grab; user-select: none; }
.mg-svg:active { cursor: grabbing; }
.mg-edge { fill: none; stroke: var(--line-2); stroke-width: 1.4; }
.mg-edge.invalid { stroke-dasharray: 5 4; opacity: .7; }
.mg-edge.blocked { stroke: var(--danger); }
.mg-elabel { font: 10px var(--mono); fill: var(--muted); pointer-events: none; }
.mg-elabel.invalid { opacity: .6; }
.hide-invalid .mg-edge.invalid, .hide-invalid .mg-elabel.invalid, .hide-labels .mg-elabel { display: none; }
.mg-node { cursor: pointer; }
.mg-node circle { stroke: var(--surface); stroke-width: 2; }
.mg-node.t-agent circle, .mg-dot.t-agent { fill: var(--accent); background: var(--accent); }
.mg-node.t-team circle, .mg-dot.t-team { fill: var(--info); background: var(--info); }
.mg-node.t-global circle, .mg-dot.t-global { fill: var(--ok); background: var(--ok); }
.mg-node.blocked circle { stroke: var(--danger); stroke-dasharray: 3 2; }
.mg-node.center circle { stroke: var(--text); stroke-width: 2.5; }
.mg-node.sel circle { stroke: var(--warn); stroke-width: 3.5; }
.mg-node:focus { outline: none; }
.mg-node:focus-visible circle { stroke: var(--warn); stroke-width: 3; }
.mg-nlabel { font: 11px var(--sans); fill: var(--text-2); paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; pointer-events: none; }
.mg-legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.mg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.mg-side { position: sticky; top: 12px; max-height: 80vh; overflow: auto; }
.mg-side h2 { overflow-wrap: anywhere; }
.mg-facts li { border-top: 1px solid var(--line); padding: 8px 0; }
.mg-f-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-bottom: 3px; }
.mg-f-text { display: block; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
@media (max-width: 1100px) { .mg-wrap { grid-template-columns: 1fr; } .mg-side { position: static; max-height: none; } .mg-canvas { height: 56vh; } }
.mem-tiers code { white-space: nowrap; }

/* quản trị máy (web/admin_pages.py): biểu đồ SVG vẽ phía server — không script, không style inline */
.admin-chart { margin: 0 0 var(--s4); }
.admin-chart figcaption { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 4px; }
.chart-svg { width: 100%; max-width: 720px; height: auto; display: block; }
.chart-bar { fill: var(--accent); }
.chart-axis { stroke: var(--line-2); stroke-width: 1; }
.chart-lbl { fill: var(--muted); font-size: 10px; }
/* ============================================================ transcript dùng chung (.tx-*) — trang run, sau này cả Điều phối
   (docs/dev-notes/plan-chat-ui-claude.md mục 2). Màu token code = CLASS pygments `tk-*` (CSP chặn style=). */
:root {
  --tk-kw: #8a3ffc; --tk-str: #2f7d32; --tk-com: #8a877c; --tk-num: #b5540b; --tk-fn: #1f5f99; --tk-type: #0f766e;
  --tk-builtin: #a1386b; --tk-op: #5c5a52; --tk-tag: #b0332b; --tk-attr: #8a6d0b; --tk-err: #b5412f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tk-kw: #c4a7ff; --tk-str: #9fd28f; --tk-com: #8f8c82; --tk-num: #f0a868; --tk-fn: #8cc4f2; --tk-type: #72d3c4;
    --tk-builtin: #f09ac4; --tk-op: #c9c6bb; --tk-tag: #f0907c; --tk-attr: #e8c872; --tk-err: #f08a78;
  }
}
.tx-code { margin: .55rem 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--code-bg); overflow: hidden; font-family: var(--sans); }
.tx-code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 12px; border-bottom: 1px solid var(--line);
  font-size: var(--fs-xs); color: var(--muted); }
.tx-lang { font-family: var(--mono); }
.tx-copy { border: 0; background: transparent; color: var(--muted); font: inherit; padding: 3px 8px; border-radius: 6px; cursor: pointer; min-height: 26px; }
.tx-copy:hover, .tx-copy:focus-visible { background: var(--surface-3); color: var(--text); }
.tx-code pre { margin: 0; border-radius: 0; background: transparent; white-space: pre; word-break: normal; overflow-x: auto; padding: 10px 12px; font-size: 12.5px; line-height: 1.55; }
.tx-code pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; }
.tx-code [class^="tk-k"] { color: var(--tk-kw); }
.tx-code [class^="tk-s"], .tx-code .tk-dl { color: var(--tk-str); }
.tx-code [class^="tk-c"], .tx-code .tk-ch, .tx-code .tk-cm { color: var(--tk-com); font-style: italic; }
.tx-code [class^="tk-m"], .tx-code .tk-il { color: var(--tk-num); }
.tx-code .tk-nf, .tx-code .tk-fm, .tx-code .tk-nd { color: var(--tk-fn); }
.tx-code .tk-nc, .tx-code .tk-nn, .tx-code .tk-kt { color: var(--tk-type); }
.tx-code .tk-nb, .tx-code .tk-bp, .tx-code .tk-nv, .tx-code .tk-vg, .tx-code .tk-vi { color: var(--tk-builtin); }
.tx-code .tk-o, .tx-code .tk-ow { color: var(--tk-op); }
.tx-code .tk-nt { color: var(--tk-tag); }
.tx-code .tk-na, .tx-code .tk-nl { color: var(--tk-attr); }
.tx-code .tk-err { color: var(--tk-err); }
.tx-code .tk-gi { color: var(--ok); } .tx-code .tk-gd { color: var(--danger); } .tx-code .tk-gh, .tx-code .tk-gu { color: var(--info); font-weight: 650; }
.tx-code .tk-ge { font-style: italic; } .tx-code .tk-gs { font-weight: 650; }
.tx-table { overflow-x: auto; margin: .55rem 0; max-width: 100%; }
.tx-table table { border-collapse: collapse; font-family: var(--sans); font-size: var(--fs-sm); }
.tx-table th, .tx-table td { border: 1px solid var(--line); padding: .3rem .6rem; vertical-align: top; }
.tx-table th { background: var(--surface-2); font-weight: 650; text-align: left; }
.tx-table .al-left { text-align: left; } .tx-table .al-right { text-align: right; } .tx-table .al-center { text-align: center; }
.md a.ext { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.md .ext-host { color: var(--muted); font-family: var(--sans); font-size: var(--fs-xs); }
.md .contains-task-list { list-style: none; padding-left: .4rem; }
.md .task-list-item-checkbox { margin: 0 .4rem 0 0; vertical-align: -1px; }
.md s { color: var(--muted); }
.md blockquote { margin: .5rem 0; padding: 0 0 0 .9rem; border-left: 3px solid var(--line-2); color: var(--text-2); }
.tx-cut { color: var(--muted); font-size: var(--fs-xs); font-weight: 450; }
.tx-copy-buf { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; }

/* dòng tool một dòng kiểu Claude: <details class="tx-tool"><summary> trạng thái · động từ · đích · meta · thời gian · chip file */
.ti.tool.tx-tool { background: transparent; border: 0; padding: 0; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.ti.tool.tx-tool.sub { margin-left: 22px; padding-left: 10px; border-left: 2px solid var(--line); border-radius: 0; }
.tx-tool-sum { display: flex; align-items: center; gap: 7px; min-width: 0; cursor: pointer; list-style: none; padding: 3px 6px; border-radius: var(--r-sm); color: var(--text-2); }
.tx-tool-sum::-webkit-details-marker { display: none; }
.tx-tool-sum:hover { background: var(--surface-2); }
.tx-st { flex: none; display: inline-flex; width: 16px; height: 16px; align-items: center; justify-content: center; color: var(--muted); }
.tx-st .ic { width: 13px; height: 13px; }
.tx-tool.err .tx-st, .tx-tool.err .tx-verb { color: var(--danger); }
.tx-spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--info-line); border-top-color: var(--info); animation: think-spin 1s linear infinite; }
.tx-verb { flex: none; font-weight: 650; color: var(--text); }
.tx-target { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.tx-meta, .tx-dur { flex: none; color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.tx-dur.spin { color: var(--info); }
.tx-tool-sum .fchip { flex: none; }
.tx-chev { flex: none; margin-left: auto; width: 14px; height: 14px; color: var(--faint); transition: transform .15s; }
.tx-tool[open] > .tx-tool-sum .tx-chev { transform: rotate(180deg); }
.tx-tool-body { margin: 2px 0 6px 23px; padding: 6px 0 2px 12px; border-left: 2px solid var(--line); }
.tx-io-h { font-size: var(--fs-xs); font-weight: 650; color: var(--muted); margin: 6px 0 3px; }
.tx-in, .tx-out { margin: 0; max-height: 22rem; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.tx-tool.err .tx-out { background: var(--danger-soft); color: var(--danger); }
.tx-in mark.ctl, .tx-out mark.ctl, .tx-target mark.ctl { background: var(--danger); color: var(--on-danger); border-radius: 3px; padding: 0 2px; }

/* P0-8: dòng meta "Bắt đầu" dưới yêu cầu, ✓ trên chỉ đạo, chân run gọn (khung màu chỉ khi lỗi) */
.ti.prompt .tx-start { margin-top: 6px; color: var(--muted); font-size: var(--fs-xs); }
.ti.start.tx-start { display: block; color: var(--muted); font-size: var(--fs-xs); font-weight: 450; padding: 0 4px; }
.ti.start.tx-start::before, .ti.start.tx-start::after { content: none; }
.tx-ack { display: inline-flex; align-items: center; gap: 3px; color: var(--ok); font-weight: 600; }
.ti.end.tx-end { background: transparent; border: 0; padding: 2px 4px; font-weight: 500; font-size: var(--fs-xs); color: var(--muted); gap: 6px; }
.ti.end.tx-end .ic { width: 13px; height: 13px; }
.ti.end.tx-end.ok .ic { color: var(--ok); }
.ti.end.tx-end.danger, .ti.end.tx-end.warn { padding: 8px 12px; font-size: var(--fs-sm); font-weight: 600; border: 1px solid; }
.ti.end.tx-end.danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.ti.end.tx-end.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.tx-thinking.live > summary { color: var(--info); }
.result-card.compact h2 { margin-bottom: 4px; }
@media (max-width: 640px) {
  .tx-tool-sum { flex-wrap: wrap; row-gap: 2px; }
  .tx-target { flex: 1 1 5em; }
  .tx-tool-sum .fchip { order: 10; flex-basis: 100%; padding-left: 23px; }
  .tx-tool-body { margin-left: 8px; padding-left: 8px; }
}

/* ============================================================ P1-1/2/3/6/7/11 (docs/dev-notes/plan-chat-ui-claude.md) */
/* P1-1: khối đang chạy chữ đã có markdown (`part`) — HTML bình thường, đuôi chữ thô giữ xuống dòng */
.ti.msg.streaming.parted .md { white-space: normal; }
.tx-tail { white-space: pre-wrap; }
/* P1-2: nhóm tool liền nhau — một dòng "Đã dùng N công cụ · Đọc ×3, Chạy ×2"; nhóm 1 tool: không tiêu đề */
.tx-group { border-radius: var(--r-sm); }
.tx-group > summary.tx-group-sum { display: flex; align-items: center; gap: 7px; min-width: 0; cursor: pointer; list-style: none; padding: 3px 6px;
  border-radius: var(--r-sm); color: var(--muted); font-size: var(--fs-sm); }
.tx-group > summary.tx-group-sum::-webkit-details-marker { display: none; }
.tx-group > summary.tx-group-sum:hover { background: var(--surface-2); }
.tx-gl { flex: none; font-weight: 600; color: var(--text-2); }
.tx-group .tx-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.tx-glive { color: var(--info); }
.tx-group.err > summary .tx-st, .tx-group.err > summary .tx-gl { color: var(--danger); }
.tx-group[open] > .tx-group-sum .tx-chev { transform: rotate(180deg); }
.tx-group > .tx-kids { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 2px 13px; padding-left: 8px; border-left: 2px solid var(--line); }
.tx-group.solo > summary { display: none; }
.tx-group.solo > .tx-kids { margin: 0; padding: 0; border: 0; }
/* P1-3: subagent lồng trong tool Task/Agent */
.tx-tool.nest > .tx-tool-body > .tx-kids { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.tx-tool.nest > .tx-tool-body > .tx-kids:empty { display: none; }
.tx-kids .ti.note { font-size: var(--fs-xs); }
.tx-tool.nest > .tx-tool-body > .tx-kids > .ti.tool.tx-tool.sub { margin-left: 0; padding-left: 0; border-left: 0; }
.tx-kids-n { color: var(--muted); }
.tx-tool.running .tx-kids-n { color: var(--info); }
.tx-io > summary, .tx-more > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; margin: 4px 0; }
/* P1-7: diff Edit/Write trong thân tool — dùng lại .udiff .dl của trang diff run */
.udiff.tx-diff { border: 1px solid var(--line); border-radius: var(--r-sm); max-height: 26rem; margin: 4px 0 6px; }
.udiff .dl.ctx { color: var(--text-2); }
.udiff mark.ctl { background: var(--danger); color: var(--on-danger); border-radius: 3px; padding: 0 2px; }
/* P1-11: duyệt/câu hỏi trong transcript = một dòng trỏ tới thẻ (thao tác chỉ ở thẻ) */
.ti.tx-line { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: var(--fs-sm); min-width: 0; }
.ti.tx-line .ic { flex: none; margin: 0; }
.tx-line-a { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
a.tx-line-a:hover { text-decoration: none; } a.tx-line-a:hover b { text-decoration: underline; }
.tx-line-a code { font-size: 12px; }
.tx-go { color: var(--muted); }
.xcard.tcard-changed { animation: tcard-flash 1.6s ease-out; }
/* P1-6: giờ của từng mục — hiện khi hover/focus */
.tx-time { flex: none; margin-left: 8px; color: var(--muted); font-size: var(--fs-xs); font-weight: 450; font-style: normal; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity .12s; white-space: nowrap; }
.ti:hover > .tx-time, .ti:focus-within > .tx-time, .ti:hover > summary .tx-time, .ti:focus-within > summary .tx-time, .ti:hover > .ti-label .tx-time,
.ti:focus-within > .ti-label .tx-time, .tx-time:focus { opacity: 1; }
.ti.msg > .tx-time { display: block; margin: 2px 0 0; text-align: right; }
.tx-tool-sum .tx-time { margin-left: auto; }
.tx-tool-sum .tx-time + .tx-chev { margin-left: 4px; }
@media (hover: none) { .tx-time { display: none; } }

/* P1-6: trang run = cột đọc một cột, MỘT vùng cuộn (#run-scroll); ô chỉ đạo / "Nói tiếp" nằm DƯỚI vùng cuộn (#run-dock) */
.run-page .main { height: 100vh; height: 100dvh; }
.run-page .wrap { max-width: none; padding: 0; flex: 1 1 auto; min-height: 0; display: flex; }
.run-col { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; width: 100%; }
.run-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.run-read { width: 100%; max-width: calc(var(--read-w) + 40px); margin: 0 auto; padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.run-read > .card, .run-read #run-result > .card, .run-read .need { margin-bottom: 0; }
.run-read #run-result { display: flex; flex-direction: column; gap: 14px; }
.run-read .crumbs { margin-bottom: 0; }
.run-bar { padding: 0 0 12px; border-bottom: 1px solid var(--line); }
.run-bar .run-head { gap: 8px; }
.run-bar .run-title .who { font-size: var(--fs); }
.run-bar .chips-kv .chip { height: 24px; font-size: var(--fs-xs); background: transparent; }
.run-bar .need-run { margin-top: 12px; }
.run-tx-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.run-tx-head h2 { margin: 0; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.run-page .transcript { max-height: none; overflow: visible; padding: 0; gap: 12px; scroll-behavior: auto; }
.run-dock { flex: 0 0 auto; position: relative; z-index: 2; padding: 8px max(16px, calc((100% - var(--read-w)) / 2)) 10px; background: var(--bg);
  border-top: 1px solid var(--line); }
.run-dock:empty { display: none; }
.run-composer .composer { box-shadow: var(--shadow-composer); }
.run-dock-hint { margin: 4px 6px 0; color: var(--muted); font-size: var(--fs-xs); }
.tx-jump { position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit;
  font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-lg); cursor: pointer; }
.tx-jump[hidden] { display: none; }
@media (max-width: 760px) {
  .run-page .main { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
  .run-page .mtop { position: static; }
  .run-read { padding: 12px 16px 20px; }
  .run-dock { padding: 6px 10px 8px; }
  .run-dock-hint { display: none; }
  .run-composer .btn-t { display: none; }
  .tx-line-a { white-space: normal; }
}

/* ============================================================ P2 hoàn thiện (docs/dev-notes/plan-chat-ui-claude.md Đợt 3) */
/* TodoWrite → checklist "Việc cần làm": một khối mỗi run, thay tại chỗ; dính đầu vùng cuộn khi đọc phần phía dưới */
.ti.tx-todo { z-index: 1; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 0; font-size: var(--fs-sm); }
@media (min-width: 761px) { .run-page .ti.tx-todo { position: sticky; top: 0; } .run-page .tx-todo-list { max-height: 9.5rem; } }  /* điện thoại: không dính (che quá nhiều) */
.tx-todo-sum { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 6px 10px; cursor: pointer; list-style: none; color: var(--text-2); }
.tx-todo-sum::-webkit-details-marker { display: none; }
.tx-todo-h { flex: none; font-weight: 650; color: var(--text); }
.tx-todo-cur { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--info); }
.tx-todo[open] > .tx-todo-sum .tx-chev { transform: rotate(180deg); }
.tx-todo-sum .tx-time { margin-left: auto; }
.tx-todo-list { list-style: none; margin: 0; padding: 2px 10px 8px; max-height: 16rem; overflow-y: auto; }
.tx-todo-list .td { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; color: var(--text-2); }
.tx-todo-list .td input { margin: 3px 0 0; flex: none; accent-color: var(--ok); }
.tx-todo-list .td.completed > span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-2); }
.tx-todo-list .td.in_progress > span { color: var(--text); font-weight: 600; }
.tx-todo-now { flex: none; color: var(--info); font-size: var(--fs-xs); }
.tx-todo-list .td.more { color: var(--muted); font-size: var(--fs-xs); }
.mm.pending .tx-todo { position: static; margin: 4px 0 8px; }

/* báo rõ khi hub chỉ giữ phần đầu */
.tx-cutnote { display: flex; align-items: flex-start; gap: 6px; margin: 6px 0 0; color: var(--warn); font-size: var(--fs-xs); }
.tx-cutnote .ic { flex: none; margin-top: 1px; }
.tx-cutnote code { overflow-wrap: anywhere; }

/* Sao chép cả tin / output tool (văn bản gốc trong <template class="tx-src">) */
.tx-acts { display: flex; align-items: center; gap: 2px; margin-top: 2px; min-height: 26px; opacity: 0; transition: opacity .15s; }
.tx-acts .tx-time { opacity: 1; margin-left: auto; }
.ti.msg:hover > .tx-acts, .ti.msg:focus-within > .tx-acts, .ti.msg.final > .tx-acts { opacity: 1; }
.tx-copy.tx-copy-src { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); min-height: 26px; }
.tx-copy.tx-copy-src.done { color: var(--ok); }
.tx-io-h .tx-copy.tx-copy-src { margin-left: 6px; min-height: 24px; padding: 1px 6px; font-weight: 500; vertical-align: middle; }
@media (hover: none) { .tx-acts { opacity: 1; } }

/* dòng trạng thái live "✳ Đang nghĩ… 12s · 3.4k token" */
.tx-status { display: flex; align-items: baseline; gap: 4px; margin: 10px 0 0; padding: 0 4px; color: var(--accent-text); font-size: var(--fs-sm); min-width: 0; }
.tx-status[hidden] { display: none; }
.tx-status-ic { flex: none; display: inline-block; color: var(--accent-mark); animation: think-spin 2.4s linear infinite; }
.tx-status-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tx-status-m { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }

/* run dài: nút tải phần trước */
.tx-older { align-self: center; }

/* Điều phối: vạch ngăn theo ngày */
.mm-day { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.mm-day::before, .mm-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* mobile: vùng an toàn (iPhone không nút home) cho hai ô nhập; bàn phím ảo → .main cao bằng visual viewport (app.js đặt --vvh) */
.composer-wrap, .run-dock { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
html.kb-open body.chat-page .main, html.kb-open body.run-page .main { height: var(--vvh, 100dvh); padding-bottom: 0; }
html.kb-open .tabbar { display: none; }
.md, .tx-msg { min-width: 0; max-width: 100%; }
@media (max-width: 760px) {
  .composer-wrap, .run-dock { padding-bottom: 8px; }  /* thanh tab đáy đã chừa vùng an toàn */
  html.kb-open .composer-wrap, html.kb-open .run-dock { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
.ti.msg > .md > :last-child { margin-bottom: 0; }

/* ===================================================================== giọng nói (static/voice.js, docs/dev-notes/voice.md) */
.voice-mic.on, .voice-wave[aria-pressed="true"] { color: var(--on-accent); background: var(--danger); border-color: var(--danger); }
.voice-mic.on { position: relative; }
.voice-mic.on::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--danger); opacity: .5;
  animation: ring-ping 1.2s ease-out infinite; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .voice-mic.on::after { animation: none; opacity: 0; } }
.composer-bar .voice-mic { flex: 0 0 auto; }
.composer-bar .voice-wave { flex: 0 0 auto; margin-left: auto; }
.composer-bar .voice-wave + .btn.send { margin-left: 0; }
.composer.has-voice { grid-template-columns: minmax(0, 1fr) auto auto; }
.composer.has-voice .voice-mic { height: 38px; width: 38px; }
.voice-row { display: flex; justify-content: flex-end; margin-top: 4px; }
.mgr-mini .mgr-form .voice-row { margin: 0; align-self: flex-end; }
.voice-toast { margin: 4px 0 0; color: var(--danger); font-size: var(--fs-sm); }
.voice-toast[hidden] { display: none; }

.voice-ov { position: fixed; z-index: 60; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(620px, calc(100% - 32px)); max-height: min(70vh, 560px); display: flex; flex-direction: column; gap: 10px;
  background: var(--composer); color: var(--text); border: 1px solid var(--line-2); border-radius: 22px; padding: 12px 16px 12px;
  box-shadow: var(--shadow-composer), 0 18px 48px rgba(0, 0, 0, .18); }
.voice-top { display: flex; align-items: center; gap: 6px; }
.voice-title { font-weight: 600; font-size: var(--fs-sm); margin-right: auto; }
.voice-lang { font-weight: 600; min-width: 40px; }
.voice-stage { display: flex; align-items: center; gap: 16px; min-height: 96px; min-width: 0; }
.voice-orb { position: relative; flex: 0 0 auto; width: 84px; height: 84px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: transparent; }
.voice-orb:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.voice-core, .voice-ring { position: absolute; inset: 0; border-radius: 50%; }
.voice-core { inset: 14px; background: radial-gradient(circle at 35% 30%, var(--accent-hover), var(--accent) 60%, color-mix(in srgb, var(--accent) 70%, #000)); transition: transform .25s; }
.voice-ring { border: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); opacity: 0; }
.voice-ov[data-state="listening"] .voice-ring { opacity: 1; animation: voice-ring 1.8s ease-out infinite; }
.voice-ov.hearing .voice-core { transform: scale(1.12); }
.voice-ov[data-state="thinking"] .voice-core, .voice-ov[data-state="sending"] .voice-core { animation: voice-think 1.4s ease-in-out infinite; }
.voice-ov[data-state="speaking"] .voice-core { animation: voice-speak .9s ease-in-out infinite; }
.voice-ov[data-state="paused"] .voice-core { background: var(--line-2); }
@keyframes voice-ring { 0% { transform: scale(.75); opacity: .9; } 100% { transform: scale(1.15); opacity: 0; } }
@keyframes voice-think { 0%, 100% { transform: scale(.88); opacity: .75; } 50% { transform: scale(1); opacity: 1; } }
@keyframes voice-speak { 0%, 100% { transform: scale(.95); } 50% { transform: scale(1.1); } }
.voice-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.voice-state { margin: 0; font-weight: 600; }
.voice-heard { margin: 0; color: var(--text-2); font-size: 15px; min-height: 1.4em; overflow-wrap: anywhere; }
.voice-heard:empty::before { content: "Hãy nói điều bạn muốn giao cho đội…"; color: var(--muted); }
.voice-reply { color: var(--text); font-size: var(--fs-sm); max-height: 9.5em; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.voice-reply:empty { display: none; }
.voice-ctl { display: flex; gap: 8px; justify-content: flex-end; }
.voice-ctl [hidden] { display: none; }
.voice-note { margin: 0; color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.voice-open .composer-wrap .mgr-suggest { visibility: hidden; }
@media (max-width: 560px) {
  .voice-stage { flex-direction: column; text-align: center; }
  .voice-ctl { justify-content: center; }
  .composer-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .voice-mic.on, .voice-ring, .voice-core { animation: none !important; }
}
.voice-open .mgr-log { padding-bottom: 140px; }

/* L5 — nhật ký kiểm toán: cột kết quả có màu + thẻ "Hoạt động theo người" */
.pill.outcome-ok { background: var(--ok-soft); color: var(--ok); }
.pill.outcome-error { background: var(--warn-soft); color: var(--warn); }
.pill.outcome-denied { background: var(--danger-soft); color: var(--danger); }
.pill.outcome-other { background: var(--surface-3); color: var(--muted); }
a.outcome-denied { color: var(--danger); font-weight: 600; }
.audit-activity { overflow-x: auto; }
.audit-activity table { min-width: 520px; }
.audit-activity td.muted { color: var(--muted); }

/* ============================================================ trạng thái & từ ngữ thống nhất (ux-chat-flow P1-5..P1-8) */
/* đầu trang run: id/mô hình/loại gập trong "Chi tiết kỹ thuật" */
.tech-more { display: inline; }
.tech-more > summary { list-style: none; cursor: pointer; }
.tech-more > summary::-webkit-details-marker { display: none; }
.tech-more[open] > summary { background: var(--surface-3); }
.tech-more .id { font-family: var(--mono, ui-monospace, monospace); font-weight: 500; }
/* bảng Công việc: 5 cột (gộp "Chưa bắt đầu"), cột rỗng thu thành dải hẹp có số đếm — cột "Xong" luôn trong màn hình rộng */
.kanban.board5 { display: flex; align-items: stretch; gap: var(--s3); overflow-x: auto; }
.kanban.board5 .col { flex: 1 1 0; min-width: 200px; }
.kanban.board5 .col.is-empty { flex: 0 0 46px; min-width: 46px; padding: 10px 4px; }
.kanban.board5 .col.is-empty h3 { flex-direction: column-reverse; align-items: center; justify-content: flex-end; gap: 10px; margin: 0; white-space: nowrap; }
.kanban.board5 .col.is-empty .pill { writing-mode: vertical-rl; height: auto; min-height: 0; background: transparent; padding: 0; color: var(--muted); line-height: 1.2; }
.kanban.board5 .col-n { color: var(--muted); font-size: var(--fs-xs); font-weight: 600; }
.kanban.board5 .tcard .meta .pill { font-size: var(--fs-xs); height: auto; padding: 0 6px; }
.kanban.board-empty { display: block; }
.board-none { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding-bottom: var(--s4);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg); }
@media (max-width: 760px) {
  /* điện thoại: danh sách nhóm theo trạng thái — cần chú ý trước, Xong cuối (ẩn bớt), nhóm rỗng chỉ còn một dòng tiêu đề */
  .kanban.board5 { flex-direction: column; overflow-x: visible; }
  .kanban.board5 .col, .kanban.board5 .col.is-empty { flex: 0 0 auto; min-width: 0; min-height: 0; padding: 10px; }
  .kanban.board5 .col.is-empty h3 { flex-direction: row; margin: 0 2px; justify-content: space-between; }
  .kanban.board5 .col.is-empty .pill { writing-mode: horizontal-tb; padding: 0; }
  .kanban.board5 .col-blocked { order: 1; } .kanban.board5 .col-running { order: 2; } .kanban.board5 .col-review { order: 3; }
  .kanban.board5 .col-todo { order: 4; } .kanban.board5 .col-done { order: 5; }
  .kanban.board5 .col.is-empty { order: 6; }
  .kanban.board5 .col-done:not(:target) .tcard:nth-of-type(n+4) { display: none; }
  .kanban.board5 .col-done:target .done-more { display: none; }
}
.done-more { display: none; }
@media (max-width: 760px) { .done-more { display: inline-block; padding: 6px 2px; } }
/* Cần bạn: câu hỏi gọn — nút 1 chạm, form đầy đủ gập sau "Trả lời khác…" */
.q-more { margin-top: var(--s2); }
.q-more > summary { list-style: none; display: inline-flex; width: auto; }
.q-more > summary::-webkit-details-marker { display: none; }
.q-more[open] > summary { margin-bottom: var(--s2); }

/* Dữ liệu dài (tên agent dài trong bộ lọc): select không được đẩy trang tràn ngang trên điện thoại */
select { max-width: 100%; text-overflow: ellipsis; }
.filters form.row, .page-head form.row, .search-form label { min-width: 0; max-width: 100%; }
.filters form.row select, .page-head form.row select { flex: 1 1 auto; min-width: 0; }

/* Nhiều việc chờ (≥4 thẻ): thẻ duyệt/câu hỏi gọn hơn để thấy được nhiều việc trên một màn */
.need:has(> .xcard:nth-child(4)) { gap: var(--s2); }
.need:has(> .xcard:nth-child(4)) > .xcard { padding: 12px 14px; }
.need:has(> .xcard:nth-child(4)) .xcard-head { margin-bottom: 6px; gap: 10px; }
.need:has(> .xcard:nth-child(4)) .xcard-ic { width: 26px; height: 26px; border-radius: 8px; }
.need:has(> .xcard:nth-child(4)) .xcard-title .t > .pill { display: none; }
.need:has(> .xcard:nth-child(4)) .xcard-why { margin-top: 4px; font-size: var(--fs-xs); }
.need:has(> .xcard:nth-child(4)) .xcard-actions { margin-top: 8px; }

/* ============================================================ thanh bên: Luồng việc | Hội thoại
   Một kiểu tiêu đề nhóm (chữ thường, không viết hoa), mọi dòng có ô dẫn rộng bằng icon của Luồng việc → chữ thẳng một cột.
   Đường chia giữa hai phần kéo lên/xuống được (app.js, nhớ theo người xem); "Luồng đang mở" / "Gần đây" gập được. */
.nav-group, .side-recents .ws-head { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.side-recents .ws-head { position: sticky; top: 0; z-index: 1; background: var(--side-bg); padding: 6px 4px 4px 10px; margin: 0; }
.side-sub { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px 4px; margin: 0; border: 0; background: none;
  font: inherit; font-size: var(--fs-xs); font-weight: 500; color: var(--muted); text-align: left; cursor: pointer; border-radius: 6px; }
.side-sub::before { content: ""; flex: none; width: 5px; height: 5px; margin: 0 6px 0 2px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); transition: transform .15s; opacity: .8; }
.side-sub:hover { color: var(--text-2); }
.side-sub:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.side-sub[aria-expanded="false"]::before { transform: rotate(-45deg); }
.side-n { margin-left: auto; font-weight: 500; font-variant-numeric: tabular-nums; opacity: .8; }
html.sf-ws [data-fold-body="ws"], html.sf-recent [data-fold-body="recent"] { display: none; }
.side-recents .mgr-convs a { display: flex; align-items: center; height: 32px; padding: 0 8px 0 10px; }
.side-recents .mgr-convs .ct { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; font-weight: 450; white-space: nowrap; }
.side-recents .ct .cdot { flex: 0 0 17px; display: inline-flex; align-items: center; justify-content: center; }
.side-recents .ct .cdot .ws-dot { margin: 0; }
.side-recents .ct .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.side-recents .ct .ws-unread { margin-left: auto; }
.side-recents .side-none { padding: 6px 10px 6px 37px; }
.side-split { position: relative; flex: none; height: 11px; margin: 3px 0; cursor: row-resize; touch-action: none; }
.side-split::before { content: ""; position: absolute; left: 10px; right: 10px; top: 5px; height: 1px; background: var(--line); transition: background .15s; }
.side-split::after { content: ""; position: absolute; left: 50%; top: 3px; width: 32px; height: 5px; margin-left: -16px; border-radius: 3px;
  background: var(--side-bg); box-shadow: inset 0 0 0 1px var(--line); opacity: 0; transition: opacity .15s; }
.side-split:hover::before, .side-split.drag::before, .side-split:focus-visible::before { background: var(--accent); }
.side-split:hover::after, .side-split.drag::after, .side-split:focus-visible::after { opacity: 1; box-shadow: inset 0 0 0 1px var(--accent); }
.side-split:focus-visible { outline: none; }
html.dragging-split, html.dragging-split * { cursor: row-resize !important; user-select: none; }
.nav, .nav > * { flex-shrink: 0; }
@media (min-width: 1101px) { html.side-nav-sized:not(.side-min) .nav { flex: 0 0 var(--side-nav-h); overflow: hidden; }
  html.side-nav-sized:not(.side-min) .nav:hover, html.side-nav-sized:not(.side-min) .nav:focus-within { overflow-y: auto; } }
@media (max-width: 1100px) { .side-split { display: none; } }
html.side-min .side-split { display: none; }

/* ============================================================ trang Điều phối: hết cuộn ngang, hàng tab Luồng, chữ gọn hơn
   1) Nhãn `.sr-only` (position:absolute) trong tab luồng thoát khỏi vùng cuộn của #ws-tabs (không có tổ tiên định vị bên trong)
      → kéo cả trang rộng thêm ~430px. #ws-tabs làm khối chứa. Lưới an toàn: gốc tài liệu không cuộn ngang (panel trượt
      position:fixed ẩn ngoài mép phải trên điện thoại cũng từng gây cuộn ngang).
   2) Hàng tab: tab hẹp hơn, mờ dần ở mép khi còn tab bị khuất, thanh cuộn mảnh khi rê chuột, lăn chuột dọc = cuộn ngang (app.js).
   3) Nội dung trả lời là trọng tâm: chữ trả lời 15px, tin của bạn 14px, ô nhập thấp và gọn hơn. */
html { overflow-x: clip; }
.ws-tabs { position: relative; scroll-behavior: smooth; overscroll-behavior-x: contain; scroll-padding-inline: 24px;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.ws-tabs.at-end { -webkit-mask-image: none; mask-image: none; }
.ws-tabs.scrolled:not(.at-end) { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
.ws-tabs.scrolled.at-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 28px); mask-image: linear-gradient(to right, transparent, #000 28px); }
.ws-tabs:hover { scrollbar-width: thin; }
.ws-tabs:hover::-webkit-scrollbar { display: block; height: 4px; }
.ws-tabs::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 2px; }
.ws-tab { max-width: 180px; padding: 4px 10px; font-size: var(--fs-xs); }
.ws-tab .ws-unread { min-width: 16px; height: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
.ws-bar { gap: 6px; }
.ws-bar > details { flex: none; }

.mm-md .md { font-size: 15px; line-height: 1.65; }
.mm-md .md h1, .mm-md .md h2, .mm-md .md h3 { font-size: 15.5px; }
.mm.user .mm-text { font-size: 14px; line-height: 1.5; padding: 8px 14px; border-radius: 16px; }
.mgr-form { padding: 8px 8px 6px 14px; gap: 2px; border-radius: 18px; }
.mgr-form textarea { font-size: 14px; min-height: 24px; padding: 4px 0; }
.mgr-form .btn.icon { width: 30px; height: 30px; }
.btn.send { width: 30px; height: 30px; }
.btn.send .ic { width: 16px; height: 16px; }
.chat-disclaimer { margin-top: 4px; font-size: 11px; }

/* ============================================================ khung chat: nhiều chỗ hơn cho nội dung trả lời
   Trước (1440×900): vùng đọc 632px cao (~70%), cột chữ 764px; đầu trang 56 + tab luồng 44 + khay 46 + ô nhập 110 + panel phải 320px.
   Sau: đầu trang + tab gọn, khay một dòng, ô nhập thấp, cột đọc rộng hơn, panel phải mặc định đóng dưới 1700px (early.js). */
.mgr-chat { --read-w: 880px; }
.chat-head { min-height: 44px; padding: 4px 16px; }
.chat-head::after { height: 10px; }
.ws-bar { padding: 2px 16px 4px; }
.ws-tab { padding: 3px 10px; }
.mgr-log { gap: 14px; padding-top: 12px; padding-bottom: 16px; }
.mm-who { margin-bottom: 2px; }
.mm-foot { min-height: 24px; margin-top: 2px; }
.mm-btn { width: 24px; height: 24px; }
.mm-md .md { line-height: 1.6; }
.composer-wrap { padding-bottom: 6px; }
.mgr-chat:not(:has(#mgr-empty)) .chat-disclaimer { display: none; }

/* Chữ câu trả lời (khung chat + diễn biến lượt chạy) và câu hỏi của agent: chữ không chân (sans) 14.5px — nhiều chữ hơn mỗi dòng, đọc nhanh hơn trên màn hình. */
.mm-md .md, .ti.msg .md { font-family: var(--sans); font-size: 14.5px; line-height: 1.6; }
.mm-md .md h1, .mm-md .md h2, .mm-md .md h3, .ti.msg .md h1, .ti.msg .md h2, .ti.msg .md h3 { font-size: 15px; font-weight: 650; }
.q-text { font-family: var(--sans); font-size: 14.5px; }
/* Popup trong hàng tab luồng (+ Luồng, Đã đóng, ⚙ Luồng này) nằm ở mép phải → neo theo mép phải, không tràn ra ngoài màn hình. */
@media (min-width: 721px) { .ws-bar > .ws-pop-wrap > .ws-pop { left: auto; right: 0; } }

/* Khung chat gọn kiểu Gemini: chữ nhỏ hơn, nhịp dòng và đoạn chặt hơn → nhiều nội dung trên một màn.
   Chỉnh một chỗ: --chat-fs (cỡ chữ trả lời), --chat-lh (nhịp dòng). */
.mgr-chat, .run-read { --chat-fs: 14px; --chat-lh: 1.55; }
.mm-md .md, .ti.msg .md { font-size: var(--chat-fs, 14px); line-height: var(--chat-lh, 1.55); }
.mm-md .md p, .ti.msg .md p { margin: .3rem 0; }
.mm-md .md ul, .mm-md .md ol, .ti.msg .md ul, .ti.msg .md ol { margin: .25rem 0; padding-left: 1.25rem; }
.mm-md .md li + li, .ti.msg .md li + li { margin-top: .1rem; }
.mm-md .md h1, .mm-md .md h2, .mm-md .md h3, .ti.msg .md h1, .ti.msg .md h2, .ti.msg .md h3 { font-size: 14.5px; margin: .6rem 0 .2rem; }
.mm-md .md pre, .ti.msg .md pre { font-size: 12px; }
.mm.user .mm-text { font-size: 13.5px; padding: 7px 12px; }
.mgr-form textarea { font-size: 13.5px; }
.mm-who { font-size: 11.5px; }
.mgr-chat .tx-code, .run-read .tx-code { margin: .4rem 0; }
.mgr-chat .tx-code-head, .run-read .tx-code-head { padding: 1px 4px 1px 10px; font-size: 11px; }
.mgr-chat .tx-code-head .tx-copy, .run-read .tx-code-head .tx-copy { padding: 2px 6px; font-size: 11px; min-height: 0; }
.mgr-chat .tx-code pre, .run-read .tx-code pre { padding: 7px 10px; font-size: 12px; line-height: 1.5; }
