/* Glue between the approved design (chat-ui/*.css, copied from the preview) and the live page:
   elements the preview did not have, and parts not redesigned yet (answers, dialogs) that need
   the new page frame. Loaded last. */

/* Lists inside answers keep their bullets (common.css resets every list). */
.msg-content ul { list-style: disc; padding-left: 22px; }
.msg-content ol { list-style: decimal; padding-left: 22px; }
.msg-content p + p, .msg-content p + ul, .msg-content p + ol, .msg-content ul + p, .msg-content ol + p { margin-top: 10px; }

/* Page frame: everything that is not part of the grid floats above it. */
#toast { z-index: var(--z-toast); }
.trace-panel { position: fixed; top: 68px; right: 0; bottom: 0; z-index: var(--z-overlay); width: min(420px, 100vw); display: none; background: var(--paper); border-left: 1.5px solid var(--tdtu-blue-200); overflow-y: auto; }
body.trace-open .trace-panel { display: block; }
.src-panel:empty { display: none; }
/* Sources column: three panes on laptops; phones (not designed yet) keep two and the cards under each answer. */
[data-view="chat"]:not([data-src-ready]) { grid-template-columns: auto minmax(0, 1fr); }
[data-view="chat"]:not([data-src-ready]) > [data-slot="notice"] { grid-column: 2; }
@media (max-width: 640px) {
  [data-view="chat"] { grid-template-columns: auto minmax(0, 1fr); }
  [data-view="chat"] > [data-slot="notice"] { grid-column: 2; }
  .src-panel { display: none !important; }
}
[data-view="chat"] > aside.drawer { grid-column: 1; grid-row: 2 / 5; }
[data-view="chat"] > .scroll { grid-column: 2; grid-row: 2; }
[data-view="chat"] > .dock-chat { grid-column: 2; grid-row: 3; }

/* Header: the assistant picker sits after "Trò chuyện mới". */
.top .assistant-picker { flex: none; }
.top .avatar { text-transform: uppercase; }

/* History column: states the preview did not draw. */
.hist-empty .ghost { display: inline-flex; align-items: center; justify-content: center; }
.history-skeleton { display: grid; gap: 6px; padding: 10px 12px; }
.history-guest { margin-top: 16px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--v-cream); font-size: 13px; line-height: 19px; color: var(--gray-700); }
.history-guest-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.history-guest-actions button { padding: 4px 12px; border: 2px solid var(--v-ink); border-radius: var(--radius-sm); background: var(--paper); color: var(--v-ink); font-size: 13px; font-weight: 700; }
.history-guest-actions button.is-danger { background: var(--tdtu-red-600); color: var(--text-inverse); }
.history-guest-list { display: grid; gap: 6px; margin-top: 10px; }

/* Welcome: assistant line, status and exam notes under the greeting. */
.welcome-extra:empty { display: none; }
.welcome-extra { display: grid; gap: 10px; margin-top: 14px; font-size: 14px; line-height: 21px; color: var(--text-2); }
.welcome-extra .welcome-who { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.welcome-extra .welcome-change { padding: 4px 12px; border: 2px solid var(--v-ink); border-radius: var(--radius-sm); background: var(--paper); color: var(--v-ink); font-size: 13px; font-weight: 700; box-shadow: 2px 2px 0 var(--v-ink); }
.welcome-extra .welcome-change:hover { background: var(--v-yellow); }
.welcome-extra .welcome-state { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--v-cream); color: var(--gray-800); }
.welcome-extra .welcome-state svg { flex: none; width: 18px; height: 18px; }
.welcome-extra .welcome-act { flex: none; padding: 4px 12px; border: 2px solid var(--v-ink); border-radius: var(--radius-sm); background: var(--paper); color: var(--v-ink); font-size: 13px; font-weight: 700; }
.stage .panel:empty { display: none; }

.lede-q:empty { display: none; }
.stage:has(.panel:empty) { grid-template-columns: minmax(0, 1fr); }
.tools-box .tool-list { display: grid; gap: 8px; }
.tools-box .tool-list > div { display: contents; }
.field.is-drop { outline: 2px dashed var(--v-ink); outline-offset: 2px; }
/* Suggested questions from the server have no topic line: the card keeps the number box's height and centres the text. */
.sugs .sug { min-height: 62px; justify-content: center; }
.lead h2 .nw { white-space: nowrap; }
/* Sign-in card button: text only, compact. */
.signin-btn { height: 36px; padding: 0 14px; font-size: 14px; box-shadow: 2px 2px 0 var(--v-ink); }
.signin-btn:hover { box-shadow: 3px 3px 0 var(--v-ink); }
.signin-text strong, .signin-text span { text-wrap: pretty; }
.signin-text strong { text-wrap: balance; }

/* ── Đợt 2: composer (attach-sheet A, scope-sheet, progress-sheet A) ── */
.sg[hidden], .att-btn[hidden], .att-note[hidden], .composer-banner[hidden] { display: none; }
.att-btn.is-locked { border: 1.5px dashed var(--tdtu-blue-300); background: var(--paper); box-shadow: none; color: var(--gray-600); transform: none; cursor: not-allowed; }
.att-btn.is-locked:hover { background: var(--paper); transform: none; box-shadow: none; }
.att-hint.is-info { color: var(--v-ink); }
.att-note { margin: 0; color: var(--gray-700); font-size: 12.5px; line-height: 18px; }
.att-sent img { flex: none; width: 18px; height: 18px; border-radius: 3px; object-fit: cover; }
.composer-banner { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border: 1.5px solid var(--warning-500); border-radius: var(--radius-md); background: var(--warning-50); color: var(--text); font-size: 13.5px; line-height: 19px; }
.composer-banner svg { flex: none; width: 16px; height: 16px; margin-top: 1px; color: var(--warning); }

/* ── Đợt 3: conversation (msg m4, answer-sheet, error-sheet A, notes-sheet A, fb-sheet C) ── */
.msg.bot > .bot-mark { gap: 8px; padding-right: 124px; }
.msg.bot > .bot-mark::after { content: none; }
.bot-mark .role-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bot-mark .tag-time { flex: none; color: var(--gray-700); font-size: 12px; font-weight: 500; }
.msg-body > .tt-tags { margin: 0 0 8px; }
.msg-body > .tt-tags:empty { display: none; }
.msg.user .bubble { overflow-wrap: anywhere; }
.msg-content.answer > :first-child { margin-top: 0; }
.msg-content .pg-line { margin: 2px 0; }
.msg-content .dots { padding: 0; }
@media (min-width: 641px) { .msg-body > .citations { display: none; } }
.citation-group .bracket, .citation-group .sep { display: none; }
.citation-ref.cite { vertical-align: 1px; font-size: 12px; line-height: 20px; font-weight: 700; }
.citation-ref.invalid { color: var(--gray-700); font-size: 12px; }
.msg-unsaved { margin-top: 8px; color: var(--gray-700); font-size: 13px; line-height: 19px; }
.follow-wait { color: var(--gray-700); font-size: 13.5px; }
/* Follow-up questions belong to the latest answer only. */
.message-row.assistant:not(:last-child) .followups { display: none; }
.msg.bot .er-box + .er-acts, .msg.bot .er-acts:empty { display: none; }
.msg.bot.er .msg-content { font-size: 14.5px; }
.msg.bot .nt { margin-top: 12px; }
#chatInner > .conv-notice { margin-top: 0; margin-bottom: 14px; }
.nt .er-btn { flex: none; }
.adv-conds .advising-cond { display: flex; }
.browse-evidence { margin-top: 10px; }
/* Sources column: the selected card shows the quoted passage. */
.sc:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sc-quote { margin: 8px 0 0; padding: 8px 10px; max-height: 260px; overflow-y: auto; border-left: 3px solid var(--v-ink); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; background: var(--paper); color: var(--text); font-size: 13px; line-height: 20px; white-space: pre-wrap; }
.sc button.sc-name { display: block; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.sc button.sc-name:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }
/* Modes and data scope share one row; on a narrow composer the scope button moves under the modes. */
.sg-row { flex-wrap: wrap; row-gap: 6px; }
.sg-row .modes { flex-wrap: nowrap; }
@media (max-width: 640px) { .sg { padding-left: 0; border-left: 0; } }
/* Source card (chốt 2026-11-17): the state in two fixed lines under the name (bản A), then the source
   strip at the bottom (bản C): icon, where it goes, "Mở trang" / "Mở văn bản". The whole strip is the link. */
.sa-state { display: grid; grid-template-columns: 16px minmax(0, 1fr); column-gap: 6px; min-width: 0; margin-top: 8px; }
/* The icon sits on line 1 only: with no date the block is one line tall, no empty second row. */
.sa-state .ic { grid-row: 1; width: 16px; height: 16px; margin-top: 0.5px; }
.sa-state small { grid-column: 2; }
.sa-state b, .sa-state small { display: block; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sa-state b { font-size: 12.5px; line-height: 17px; font-weight: 700; }
.sa-state small { color: var(--gray-700); font-size: 12px; line-height: 16px; font-weight: 500; }
.sa-state.is-valid { color: var(--success); }
.sa-state.is-expired { color: var(--tdtu-red-600); }
.sa-state.is-pending { color: var(--warning-700); }
.sa-state.is-web, .sa-state.is-other { color: var(--v-ink); }
.sc-open { display: flex; align-items: center; gap: 8px; margin-top: 9px; padding: 6px 8px; border: 1.5px solid var(--tdtu-blue-200); border-radius: var(--radius-sm); background: var(--paper); color: var(--v-ink); text-decoration: none; transition: background var(--duration-fast), border-color var(--duration-fast), box-shadow var(--duration-fast); }
.sc-open > .ic { flex: none; width: 15px; height: 15px; }
.sc-open span { flex: 1; min-width: 0; overflow: hidden; color: var(--text-2); font-size: 12px; line-height: 17px; white-space: nowrap; text-overflow: ellipsis; }
.sc-open b { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 12.5px; line-height: 17px; font-weight: 700; }
.sc-open b .ic { width: 12px; height: 12px; }
/* Hover is yellow like every other control; the card behind may be cream, so the strip must not turn cream. */
.sc-open:hover { border-color: var(--v-ink); background: var(--v-yellow); box-shadow: 1.5px 1.5px 0 var(--v-ink); }
.sc-open:hover span, .sc-open:hover b { color: var(--tdtu-blue-800); }
.sc-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Account dialog (đợt 4): one backdrop; the login card (login-sheet, Kiểu B) or the account card (account-sheet, bản 2). */
#accountModal { position: fixed; inset: 0; z-index: var(--z-toast); display: none; place-items: center; padding: 24px; background: var(--overlay); overflow-y: auto; }
#accountModal.open { display: grid; }
#accountModal > [hidden] { display: none; }
#accountModal .lg-view { display: grid; gap: 14px; }
#accountModal .lg-view[hidden] { display: none; }
#accountModal .lg-reg { margin: 0; text-align: center; color: var(--text-2); font-size: 13.5px; line-height: 20px; }
#accountModal .lg-reg .link { padding: 0; border: 0; background: none; color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
#accountModal .lg-go[disabled] { cursor: progress; }
#accountModal .acct-or { margin: 4px 0 6px; text-align: center; color: var(--gray-700); font-size: 13px; }
#accountModal .acct-hint { margin-bottom: 8px; text-align: center; color: var(--text-2); font-size: 13px; line-height: 19px; }
/* Toasts stay above any open dialog (tool dialogs, feedback, account), which share --z-toast. */
#toast { z-index: calc(var(--z-toast) + 10); }
