  /* ---------- Phản hồi chat: bố cục markdown ---------- */
  .msg.assistant { max-width: 100%; padding: 20px 24px; background: var(--surface); border: 1px solid var(--line); }
  .msg.user { max-width: 80%; padding: 12px 18px; line-height: 1.6; }
  .cmprow .msg.assistant { padding: 18px 20px; }
  .mtag { margin-bottom: 10px; }
  .md { font-size: 15.5px; line-height: 1.75; color: color-mix(in srgb, var(--ink) 90%, transparent); overflow-wrap: anywhere; }
  .md > :first-child { margin-top: 0 !important; }
  .md > :last-child { margin-bottom: 0 !important; }
  .md p { margin: 0 0 0.95em; }
  .md strong { font-weight: 600; color: var(--ink); }
  .md em { font-style: italic; }
  .md del { opacity: 0.6; }
  .md .mh { line-height: 1.3; letter-spacing: -0.01em; color: var(--ink); margin: 1.5em 0 0.6em; }
  .md h1 { font-size: 1.5em; font-weight: 800; padding-bottom: 0.35em; border-bottom: 1px solid var(--line); }
  .md h2 { font-size: 1.28em; font-weight: 800; padding-bottom: 0.3em; border-bottom: 1px solid var(--line); }
  .md h3 { font-size: 1.1em; font-weight: 600; }
  .md h4, .md h5, .md h6 { font-size: 1em; font-weight: 600; color: var(--muted); }
  .md ul, .md ol { margin: 0.1em 0 1em; padding-left: 1.6em; }
  .md li { margin: 0.35em 0; padding-left: 0.2em; }
  .md li > ul, .md li > ol { margin: 0.3em 0 0.2em; }
  .md li::marker { color: var(--accent); font-weight: 600; }
  .md li.task { list-style: none; margin-left: -1.3em; }
  .md li.task input { margin-right: 8px; accent-color: var(--accent); vertical-align: -1px; }
  .md blockquote { margin: 1em 0; padding: 0.5em 1.1em; border-left: 3px solid var(--accent); background: var(--raise); border-radius: 0 12px 12px 0; color: var(--muted); }
  .md blockquote p:last-child { margin-bottom: 0; }
  .md hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
  .md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
  .md a:hover { color: var(--accent-hover); }
  .md code { font-family: "JetBrains Mono", "Cascadia Mono", Consolas, monospace; font-size: 0.87em; padding: 0.15em 0.5em; border-radius: 6px; background: var(--raise); border: 1px solid var(--line); color: var(--ink); }
  .md .cb code { padding: 0; border: 0; background: transparent; border-radius: 0; font-size: inherit; color: inherit; }
  .md .tw { overflow-x: auto; margin: 1.1em 0; border: 1px solid var(--line); border-radius: 12px; }
  .md table { border-collapse: collapse; width: 100%; font-size: 0.93em; line-height: 1.55; }
  .md th, .md td { padding: 10px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
  .md th { background: var(--raise); font-weight: 600; color: var(--ink); white-space: nowrap; }
  .md tr:last-child td { border-bottom: 0; }
  .md tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--raise) 45%, transparent); }
  .md .al-c { text-align: center !important; } .md .al-r { text-align: right !important; }

  /* Khối code */
  .cb { margin: 1.1em 0; border-radius: 14px; overflow: hidden; background: var(--code-bg); border: 1px solid rgba(255, 255, 255, 0.09); }
  .cbh { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 8px 7px 16px; background: rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.07); font: 500 12px "JetBrains Mono", Consolas, monospace; color: #a3999a; }
  .cbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cbl b { color: #f1e9e9; font-weight: 700; }
  .cba { display: flex; gap: 6px; flex: none; }
  .cba button { font: 600 12px "Be Vietnam Pro", system-ui, sans-serif; padding: 5px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.08); color: #ece4e4; }
  .cba button:hover { background: rgba(255, 255, 255, 0.16); }
  .cba button.demo { background: var(--accent); color: #fff; }
  .cba button.demo:hover { background: var(--accent-hover); }
  .msg .cb pre { margin: 0; padding: 16px 18px; background: transparent; border-radius: 0; overflow: auto; max-height: 540px; font: 13px/1.65 "JetBrains Mono", "Cascadia Mono", Consolas, monospace; color: #e6edf3; white-space: pre; tab-size: 2; }

  /* Màu cho từng loại token (dùng cả ở chat và tab Code) */
  .tk-c { color: #8b949e; font-style: italic; } .tk-s { color: #a5d6ff; } .tk-n { color: #79c0ff; } .tk-k { color: #ff7b72; }
  .tk-f { color: #d2a8ff; } .tk-t { color: #ffa657; } .tk-v { color: #ffa657; } .tk-p { color: #7ee787; }
  .tk-g { color: #7ee787; } .tk-a { color: #79c0ff; } .tk-l { color: #79c0ff; } .tk-x { color: #8b949e; }
  .tk-h { color: #d2a8ff; } .tk-add { color: #7ee787; background: rgba(46, 160, 67, 0.16); } .tk-del { color: #ffa198; background: rgba(248, 81, 73, 0.16); }

  /* Đang gõ (streaming) */
  @keyframes mdcaret { 50% { opacity: 0; } }
  @keyframes mddot { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
  .msg.live .md > :last-child:not(.cb):not(.tw):not(hr)::after { content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 3px; vertical-align: -0.18em; background: var(--accent); border-radius: 2px; animation: mdcaret 1s steps(2) infinite; }
  .typing { display: inline-flex; gap: 5px; padding: 8px 0; }
  .typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: mddot 1.2s infinite ease-in-out; }
  .typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }

  /* Popup xem demo, góc dưới bên phải */
  @keyframes dpin { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: none; } }
  #demoPop { position: fixed; right: 16px; bottom: 16px; z-index: 9000; width: min(560px, calc(100vw - 32px)); height: min(440px, 72vh); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55); overflow: hidden; animation: dpin 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.1); transition: width 0.2s, height 0.2s; }
  #demoPop.big { width: min(1120px, calc(100vw - 32px)); height: min(88vh, calc(100vh - 32px)); }
  .dp-h { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 14px; background: var(--raise); border-bottom: 1px solid var(--line); }
  .dp-t { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dp-h button { padding: 5px 10px; border-radius: 8px; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; }
  .dp-h button:hover { background: var(--line); color: var(--ink); }
  #demoPop iframe { flex: 1; width: 100%; border: 0; background: #fff; }
  @media (max-width: 900px) { #demoPop { right: 8px; bottom: 8px; width: calc(100vw - 16px); height: 62vh; } .md { font-size: 15px; } .msg.assistant { padding: 16px 16px; } }
