/* AI Center v1.3 components. Values follow AUTHORING.md + the .dc.html artboards. Tokens live in tokens.css. */

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--body);
  font-family: var(--font-ui); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--info); }
a:hover { color: var(--info-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
img, svg { flex-shrink: 0; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
textarea:focus-visible, .composer textarea:focus-visible { outline: none; }
::placeholder { color: var(--placeholder); opacity: 1; }
.sr-only { position: absolute !important; 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; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.ink { color: var(--ink); }
.small { font-size: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hidden, [hidden] { display: none !important; }
kbd, .kbd {
  white-space: nowrap; flex: 0 0 auto;
  font-family: var(--font-mono); font-size: 11px; line-height: 16px; padding: 0 5px;
  border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted-2); background: var(--surface);
}
code { font-family: var(--font-mono); font-size: .92em; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* AI mark: honey hexagon + ink spark (inline SVG, see icons.js aiMark) */
.ai-mark { display: inline-block; vertical-align: middle; }
.ai-mark .hex { fill: var(--honey); stroke: var(--honey); }
.ai-mark .spark { fill: #1C1917; }

/* spinner (running) */
.spin { display: inline-block; flex: 0 0 auto; }
.spin .trk { stroke: var(--border-strong); }
.spin .arc { stroke: var(--honey-ink); transform-origin: 50% 50%; animation: aic-rot .9s linear infinite; }
@keyframes aic-rot { to { transform: rotate(360deg); } }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--honey); flex: 0 0 auto; }
.dot.ok { background: var(--success); }
.dot.off { background: var(--border-strong); }
.dot.err { background: var(--danger); }
.dot.warn { background: var(--warning-dot); }
.dot.live { width: 6px; height: 6px; box-shadow: 0 0 0 3px var(--honey-soft); animation: aic-pulse 1.6s ease-in-out infinite; }
@keyframes aic-pulse { 50% { box-shadow: 0 0 0 4px rgba(242, 178, 58, .18); } }
@media (prefers-reduced-motion: reduce) {
  .spin .arc, .dot.live, .thinking .bar { animation: none !important; }
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* ------------------------------------------------------------------ boot */
.boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ shell */
.app { display: flex; height: 100vh; height: 100dvh; min-height: 0; background: var(--bg); }
.nav {
  flex: 0 0 var(--nav-w); width: var(--nav-w); background: var(--sunken); border-right: 1px solid var(--border);
  padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; overflow-x: hidden;
}
.nav-ws { display: flex; align-items: center; gap: 10px; padding: 2px 2px 10px 6px; }
.nav-ws .ws-txt { min-width: 0; line-height: 1.3; flex: 1 1 auto; }
.nav-ws .ws-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.nav-ws .ws-sub { font-size: 12px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-search {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 36px; padding: 0 8px 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-ctl); color: var(--muted);
  font-size: 13px; text-align: left;
}
.nav-search:hover { border-color: var(--border-strong); }
.nav-search span.grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-new { width: 100%; margin: 2px 0 10px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px;
  border-radius: var(--r-ctl); color: var(--body); font-size: 14px; text-decoration: none; flex: 0 0 auto;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item .lbl { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: 3px; top: 10px; width: 3px; height: 14px; border-radius: 3px; background: var(--honey);
}
.nav-item.two { height: auto; min-height: 34px; padding: 5px 10px; line-height: 1.35; }
.nav-item .sub { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-2); font-weight: 400; }
.nav-count {
  flex: 0 0 auto; font-size: 11px; font-weight: 600; line-height: 18px; padding: 0 8px; border-radius: var(--r-pill);
  background: var(--honey-soft); color: var(--honey-ink); font-variant-numeric: tabular-nums;
}
.nav-count.outline {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; line-height: 1;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted-2);
}
.nav-group { margin: 14px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.nav-recent {
  position: relative; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px 0 14px;
  border-radius: var(--r-ctl); color: var(--body); font-size: 13px; text-decoration: none; flex: 0 0 auto;
}
.nav-recent:hover { background: var(--hover); color: var(--ink); }
.nav-recent .lbl { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-recent[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; }
.nav-recent[aria-current="page"]::before { content: ""; position: absolute; left: 4px; top: 9px; width: 3px; height: 12px; border-radius: 2px; background: var(--honey); }
.nav-recent.unread .lbl { color: var(--ink); }
.nav-empty { padding: 2px 10px; font-size: 12px; color: var(--muted-2); }
.nav-recent-row { position: relative; display: flex; flex-direction: column; }
.nav-recent-row .nav-recent { padding-right: 32px; }
.nav-recent-x {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  cursor: pointer; opacity: 0; transition: opacity .12s;
}
.nav-recent-row:hover .nav-recent-x, .nav-recent-row:focus-within .nav-recent-x { opacity: 1; }
.nav-recent-row:hover .nav-recent .dot { visibility: hidden; }
.nav-recent-x:hover { background: var(--danger-soft); color: var(--danger); }
.nav-recent-x:focus-visible { opacity: 1; outline: 2px solid var(--focus); outline-offset: 0; }
@media (hover: none) { .nav-recent-x { opacity: .8; } }
.nav-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 8px 2px 0 6px; }
.avatar {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; background: var(--honey-soft); color: var(--honey-ink);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: .02em; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav-user .who { flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.nav-user .who b { display: block; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user .who span { font-size: 12px; color: var(--muted-2); }
.bell { position: relative; }
.bell .badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--honey); color: #1C1917; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
  font-variant-numeric: tabular-nums; border: 1.5px solid var(--sunken);
}

.main { flex: 1 1 auto; min-width: 0; overflow-y: auto; overflow-x: hidden; position: relative; }
.main.full { overflow: hidden; display: flex; flex-direction: column; }
.page { padding: var(--content-pad); min-width: 0; }
.page-inner { max-width: 1360px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; margin-bottom: 4px; }
.page-head .ttl { flex: 1 1 360px; min-width: 0; }
.page-head h1 { font-size: 22px; line-height: 1.3; font-weight: 600; }
.page-head .sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.page-head .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* mobile header + drawer */
.mhead { display: none; }
.scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 60; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 8px 14px;
  border: 1px solid transparent; border-radius: var(--r-ctl); font-size: 14px; font-weight: 600; line-height: 1.2;
  text-decoration: none; white-space: nowrap; background: transparent; color: var(--ink);
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-fg); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink); font-weight: 500; }
.btn-quiet:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn-ai { background: var(--honey-soft); color: var(--honey-ink); border-color: var(--honey-soft); }
.btn-ai:hover:not(:disabled) { border-color: var(--honey-line); color: var(--honey-ink); }
.btn-ai.on { background: var(--honey); color: #1C1917; border-color: var(--honey); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-link { padding: 0; min-height: 0; border: 0; color: var(--info); font-weight: 600; font-size: 13px; background: none; }
.btn-link:hover { color: var(--info-hover); text-decoration: underline; text-underline-offset: 2px; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-xs { min-height: 28px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--muted-2); flex: 0 0 auto;
}
.btn-icon:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn-icon.lg { width: 40px; height: 40px; }
.btn-icon.sm { width: 28px; height: 28px; border-radius: 6px; }
.btn .busy-spin { margin-right: 2px; }

/* ------------------------------------------------------------------ pills + chips */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; white-space: nowrap; flex: 0 0 auto;
  background: var(--sunken); color: var(--muted-2); font-variant-numeric: tabular-nums;
}
.pill.sm { height: 20px; padding: 0 8px; font-size: 11px; }
.pill.honey { background: var(--honey-soft); color: var(--honey-ink); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.success { background: var(--success-soft); color: var(--success); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.outline { background: var(--surface); border: 1px solid var(--border); color: var(--muted-2); }
.pill .pdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.warning .pdot { background: var(--warning-dot); }
.pill.min84 { min-width: 84px; }
.pill.min76 { min-width: 76px; }
.fresh {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 1px solid var(--border);
  border-radius: var(--r-pill); background: var(--surface); font-size: 12px; color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 28px; padding: 0 4px 0 10px;
  border-radius: var(--r-pill); font-size: 13px; font-weight: 600; min-width: 0;
}
.chip .x { flex: 0 0 22px; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: inherit; padding: 0; }
.chip .x:hover { background: rgba(28, 25, 23, .08); }
.chip .t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.tpl { background: var(--honey-soft); color: var(--honey-ink); }
.chip.tpl .t { font-family: var(--font-mono); font-size: 12.5px; font-weight: 500; }
.chip.ref { background: var(--info-soft); color: var(--info); }
.chip.ref .at { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.chip.ctx { background: var(--sunken); border: 1px solid var(--border); color: var(--body); font-weight: 500; }
.src-chip {
  display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 9px;
  background: var(--surface); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.src-chip.mono { font-family: var(--font-mono); font-size: 11px; }
.tag-mono {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 18px; padding: 0 6px; border-radius: 4px;
  background: var(--sunken); color: var(--muted-2); white-space: nowrap;
}

/* ------------------------------------------------------------------ cards + sections */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); min-width: 0; }
.card.pad { padding: 16px 20px; }
.card.pad-sm { padding: 12px 14px; }
.card.ai { background: var(--honey-soft); border-color: var(--honey-line); }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.card-head h2 { font-size: 15px; line-height: 1.4; font-weight: 600; }
.card-head .hint { margin-top: 2px; font-size: 13px; color: var(--muted); }
.sec { margin-top: 36px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 12px; }
.sec-head h2 { font-size: 16px; font-weight: 600; }
.sec-head .hint { font-size: 13px; color: var(--muted); }
.sec-head .more { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--info); text-decoration: none; }
.sec-head .more:hover { color: var(--info-hover); }
.list-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 14px 16px; }
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row .t { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--ink); font-variant-numeric: tabular-nums; }
.list-row a.t { display: block; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row a.t:hover { color: var(--info); }
.list-row .m { margin: 3px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; font-variant-numeric: tabular-nums; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px; min-width: 0; }
.kpi .k { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.kpi .v { margin-top: 4px; font-size: 26px; line-height: 1.2; font-weight: 600; color: var(--ink); }
.kpi .v.bad { color: var(--danger); }
.kpi .v.good { color: var(--success); }
.kpi .d { margin-top: 4px; font-size: 12px; color: var(--muted); }
.kpi.sm { padding: 10px 12px; }
.kpi.sm .v { font-size: 22px; margin-top: 0; line-height: 1.3; }

/* ------------------------------------------------------------------ tabs + segmented */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 0; background: transparent; color: var(--muted-2); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ink); }
.tab .cnt { font-size: 11px; font-weight: 600; padding: 0 7px; line-height: 18px; border-radius: 999px; background: var(--sunken); color: var(--muted-2); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--sunken); border-radius: var(--r-ctl); }
.seg.bordered { border: 1px solid var(--border); }
.seg button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted-2);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-seg); }
.seg.lg button { height: 34px; }
.seg.fill { display: flex; }
.seg.fill button { flex: 1 1 0; }

/* ------------------------------------------------------------------ form controls */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label, .field > label { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.help { font-size: 12px; color: var(--muted); }
.err-msg { font-size: 13px; color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--ink); font-size: 14px;
}
.textarea { padding: 8px 12px; resize: vertical; line-height: 1.5; }
.select { padding: 0 8px; cursor: pointer; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.select.sm { min-height: 32px; height: 32px; font-size: 13px; width: auto; }
.select.soft { background: var(--bg); border-color: var(--border); color: var(--body); font-size: 12px; height: 32px; min-height: 32px; padding: 0 6px; width: auto; max-width: 100%; }
.inline-field { display: flex; align-items: center; gap: 6px; }
.inline-field > label { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.boxed-select { display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 4px 0 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-ctl); }
.boxed-select label { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
.boxed-select select { height: 32px; border: 0; background: transparent; font-size: 14px; font-weight: 600; color: var(--ink); padding: 0 4px; cursor: pointer; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex: 0 0 auto; }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; display: block; width: 36px; height: 20px; border-radius: 999px; cursor: pointer; background: var(--surface); border: 1.5px solid var(--switch-off); }
.switch input:checked { background: var(--primary-bg); border-color: var(--primary-bg); }
.switch .knob { position: absolute; top: 4px; left: 4px; width: 12px; height: 12px; border-radius: 50%; pointer-events: none; background: var(--switch-off); transition: left .15s ease; }
.switch input:checked + .knob { left: 20px; background: var(--primary-fg); }
.switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------------ modal / popover / menu / toast */
.modal-wrap { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; background: var(--overlay); overflow-y: auto; }
.modal {
  width: 520px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column; max-height: 80vh; min-height: 0;
}
.modal.lg { width: 720px; }
.modal.sm { width: 420px; }
.modal-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 6px; }
.modal-head h2 { font-size: 16px; font-weight: 600; flex: 1 1 auto; line-height: 1.4; }
.modal-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.modal-body { padding: 8px 18px 14px; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.pop {
  position: fixed; z-index: 90; min-width: 200px; max-width: min(420px, calc(100vw - 16px)); padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop);
}
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border: 0;
  border-radius: var(--r-ctl); background: transparent; color: var(--ink); font-size: 14px; text-align: left; text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible, .menu-item.active { background: var(--sunken); outline: none; color: var(--ink); }
.menu-item svg { color: var(--muted); }
.menu-item .hint { margin-left: auto; font-size: 12px; color: var(--muted); }
.menu-item[aria-checked="true"] { font-weight: 600; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.menu-label { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(440px, calc(100vw - 32px));
  padding: 10px 8px 10px 14px; border-radius: var(--r-card); background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); box-shadow: var(--shadow-pop); font-size: 13px; line-height: 1.45;
  animation: aic-in .16s ease-out;
}
.toast.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.toast.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.toast.ai { background: var(--honey-soft); color: var(--honey-ink); border-color: var(--honey-line); }
.toast .msg { flex: 1 1 auto; min-width: 0; }
.toast .act { font-weight: 600; color: inherit; text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0 4px; white-space: nowrap; }
.toast .btn-icon { color: inherit; }
@keyframes aic-in { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------------ table */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.tbl-wrap.flat { border: 0; border-radius: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { padding: 7px 12px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); text-align: left; background: var(--table-head); white-space: nowrap; }
.tbl td { padding: 6px 12px; border-top: 1px solid var(--border); color: var(--body); vertical-align: top; }
.tbl.compact th, .tbl.compact td { padding: 5px 10px; font-size: 12px; }
.tbl .r, .tbl th.r { text-align: right; }
.tbl tr.hl td { background: var(--honey-soft); color: var(--ink); font-weight: 600; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--bg); }
.tbl td.more { color: var(--muted); }
.tbl td.neg { color: var(--danger); }
.tbl td.pos { color: var(--success); }
.tbl.nowrap td { white-space: nowrap; }

/* ------------------------------------------------------------------ markdown */
.md { font-size: 14px; line-height: 1.7; color: var(--body); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md strong { color: var(--ink); font-weight: 600; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.35; font-weight: 600; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; } .md h4 { font-size: 14px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 2px 0; }
.md li > ul, .md li > ol { margin: 2px 0; }
.md code { background: var(--sunken); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.md pre { margin: 0 0 12px; background: var(--sunken); border-radius: var(--r-ctl); padding: 10px 12px; overflow-x: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--body); position: relative; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md blockquote { margin: 0 0 10px; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md a { overflow-wrap: anywhere; }
.md a.md-img-link { display: inline-block; margin: 4px 8px 8px 0; vertical-align: top; }
.md img.md-img { display: block; max-width: min(100%, 420px); height: auto; border-radius: var(--r-ctl); border: 1px solid var(--border); background: var(--sunken); }
.md .tbl-wrap { margin: 0 0 12px; border-radius: var(--r-ctl); }
.md table { width: 100%; border-collapse: collapse; font-size: 13px; }
.md th { padding: 6px 10px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--table-head); white-space: nowrap; }
.md td { padding: 6px 10px; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------------ charts */
.chart { display: block; width: 100%; height: auto; font-family: var(--font-ui); }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .grid line { stroke: var(--grid); }
.chart .axis { stroke: var(--border-strong); }
.chart .lbl-strong { fill: var(--ink); font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 12px; color: var(--body); }
.legend .sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend .sw.dash { height: 0; border-top: 2px dashed var(--series-ref); border-radius: 0; }
.legend .sw.box { width: 10px; height: 10px; border-radius: 2px; }
.chart-caption { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ------------------------------------------------------------------ empty + skeleton */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 28px 20px; text-align: center; }
.empty .ico { width: 40px; height: 40px; border-radius: 10px; background: var(--honey-soft); color: var(--honey-ink); display: flex; align-items: center; justify-content: center; }
.empty .ttl { font-weight: 600; color: var(--ink); }
.empty .txt { font-size: 13px; color: var(--muted); max-width: 360px; }
.empty.inline { flex-direction: row; justify-content: flex-start; text-align: left; padding: 14px 16px; }
.skel { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--sunken) 0%, var(--hover) 50%, var(--sunken) 100%); background-size: 200% 100%; animation: aic-sk 1.3s ease-in-out infinite; }
@keyframes aic-sk { to { background-position: -200% 0; } }
.skel-lines { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.skel-lines .skel { height: 12px; }
.err-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.note-box { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--info-soft); color: var(--info); font-size: 13px; line-height: 1.5; }
.note-box.warn { background: var(--warning-soft); color: var(--warning); }
.note-box.ok { background: var(--success-soft); color: var(--success); }

/* ------------------------------------------------------------------ home */
.home { padding: 24px 32px 48px; }
.home-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.home-top .date { font-size: 13px; color: var(--muted); }
.home-col { max-width: 860px; margin: 0 auto; }
.greet { text-align: center; margin: 32px 0 24px; }
.greet h1 { margin: 12px 0 8px; font-size: 30px; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; text-wrap: balance; }
.greet p { font-size: 14px; color: var(--muted); }
.hint-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; margin: 10px 4px 0; font-size: 12px; color: var(--muted); }
.hint-row .src { display: inline-flex; align-items: center; gap: 6px; }
.sc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.sc-card { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; min-width: 0; }
.sc-card.on { border: 2px solid var(--honey); padding: 15px; }
.sc-card .top { display: flex; align-items: center; gap: 12px; }
.sc-card .ico { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-ctl); background: var(--sunken); color: var(--body); }
.sc-card h3 { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); font-size: 14px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.sc-card h3 .arg { color: var(--muted); }
.sc-card p { font-size: 13px; color: var(--muted); }
.bg-card { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px; }
.bg-card + .bg-card { margin-top: 8px; }
.bg-card .ico { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--r-ctl); background: var(--honey-soft); }
.bg-card h3 { font-size: 14px; font-weight: 600; line-height: 1.45; }
.progress { flex: 1 1 200px; max-width: 380px; height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--honey); }

/* ------------------------------------------------------------------ composer (shared by home + chat) */
.composer { position: relative; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-composer); box-shadow: var(--shadow-float); padding: 10px 12px; }
.composer.home { border-color: var(--border); padding: 14px 16px 12px; }
.composer .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; min-width: 0; }
.composer .chips:empty { display: none; }
.composer.chat .chips { margin-bottom: 6px; }
.composer textarea {
  display: block; width: 100%; border: 0; resize: none; background: transparent; padding: 4px 2px; color: var(--ink);
  font-size: 14px; line-height: 1.5; max-height: 240px; overflow-y: auto;
}
.composer.home textarea { min-height: 84px; font-size: 16px; }
/* SPEC §62 (mockup M7): [📎] [⚙ Chế độ · Nguồn ▾] … [Gửi | ▾], chips @level · @A/B test · /lối tắt under the text */
.composer .ctl { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; margin-top: 6px; min-width: 0; }
.composer.home .ctl { gap: 8px; margin-top: 10px; }
.composer .ctl .sp { flex: 1 1 auto; min-width: 0; }
.composer .ctl .att-btn { width: 32px; height: 32px; }
.composer .chips .chip.plan { background: var(--info-soft); color: var(--info); font-weight: 500; }
.composer .qchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.composer .qchip {
  height: 26px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg);
  color: var(--muted-2); font: 500 12px var(--font-mono); cursor: pointer;
}
.composer .qchip:hover { background: var(--sunken); color: var(--ink); border-color: var(--border-strong); }
.composer .qchip:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.cmp-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 1 auto; min-width: 0; max-width: 260px; height: 32px; padding: 0 8px 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 13px; font-weight: 500; cursor: pointer;
}
.composer.home .cmp-pill { background: var(--surface); border-color: var(--border-strong); }
.cmp-pill .t { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-pill > svg { flex: 0 0 auto; color: var(--muted); }
.cmp-pill:hover, .cmp-pill[aria-expanded="true"] { background: var(--sunken); border-color: var(--border-strong); }
.cmp-pill:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.cmp-pill.warn { border-color: var(--warning); color: var(--warning); }
.cmp-pill.warn > svg { color: var(--warning); }
.cmp-pill .cust { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--honey); }
.composer .split { display: inline-flex; align-items: stretch; flex: 0 0 auto; }
.composer .split .send { min-height: 32px; padding: 0 12px; gap: 6px; font-size: 14px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.composer .split.solo .send { border-radius: var(--r-ctl); }
.composer .split .send-caret {
  width: 32px; min-height: 32px; padding: 0; gap: 0; border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left-color: var(--primary-hover); box-shadow: inset 1px 0 0 var(--primary-hover);
}
.composer .split .send-caret[aria-expanded="true"] { background: var(--primary-hover); }
.composer .split .send:focus-visible, .composer .split .send-caret:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 1; }
.cmp-bgnow { flex: 0 0 auto; min-height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500; gap: 6px; }
.cmp-pre { display: grid; gap: 8px; margin: 0 0 8px; padding: 10px 12px; border: 1px solid var(--honey-line); border-radius: 12px; background: var(--surface); }
.cmp-pre-t { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.45; color: var(--ink); }
.cmp-pre-t svg { flex: 0 0 auto; margin-top: 2px; color: var(--honey-ink); }
.cmp-pre-a { display: flex; flex-wrap: wrap; gap: 6px; }
.inline-field > .lbl { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
/* ⚙ popover / bottom sheet (js/chat/mode_menu.js) */
.pop.cmp-pop { width: 380px; padding: 10px; }
.cmp-menu { display: grid; gap: 4px; }
.cmp-h { margin: 2px 4px; font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cmp-h:not(:first-child) { margin-top: 8px; }
.cmp-radios { display: grid; gap: 2px; }
.ro2 {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: start; width: 100%; padding: 7px 8px;
  border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--ink); font-size: 12.5px; text-align: left; cursor: pointer;
}
.ro2:hover:not(:disabled) { background: var(--sunken); }
.ro2.on { background: var(--honey-soft); border-color: var(--honey-line); }
.ro2:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.ro2:disabled { cursor: not-allowed; opacity: .6; }
.ro2 .r { width: 14px; height: 14px; margin-top: 2px; border-radius: 50%; border: 1.5px solid var(--border-strong); }
.ro2.on .r { border: 4px solid var(--ink); }
.ro2 .tx { min-width: 0; }
.ro2 b { font-weight: 600; }
.ro2 small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.ro2 .tm { font: 500 11px var(--font-mono); color: var(--muted); white-space: nowrap; }
.cmp-one { margin: 6px 4px 0; font-size: 12.5px; color: var(--muted-2); }
.cmp-one b { color: var(--ink); font-weight: 600; }
.cmp-one .cmp-more { margin-left: 8px; color: var(--info); font-weight: 600; }
.cmp-nosrc { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; padding: 8px 10px; border-radius: 9px; background: var(--warning-soft); color: var(--warning); font-size: 12.5px; }
.cmp-nosrc .grow { flex: 1 1 160px; min-width: 0; }
.cmp-nosrc b { display: block; color: var(--ink); }
.cmp-nosrc small { display: block; color: var(--muted-2); }
.cmp-ins { display: flex; gap: 6px; margin-top: 8px; }
.cmp-ins .btn { flex: 1 1 0; }
.cmp-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 8px 2px 0; border-top: 1px solid var(--border); }
.cmp-foot .grow { flex: 1 1 auto; }
.cmp-custom { gap: 6px; }
.cmp-custom small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
/* ▾ next to Gửi */
.pop.cmp-spop { width: 320px; }
.cmp-mi { align-items: flex-start; padding: 8px 10px; min-height: 44px; }
.cmp-mi > svg { flex: 0 0 auto; margin-top: 2px; }
.cmp-mi .tx { flex: 1 1 auto; min-width: 0; }
.cmp-mi b { display: block; font-size: 13.5px; font-weight: 600; }
.cmp-mi small { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }
.cmp-mi:disabled { opacity: .55; cursor: not-allowed; }
.picker-item.off { opacity: .6; }
.picker-item.off .d { color: var(--warning); }
/* "Cần chốt trước khi chạy" card (js/chat/clarify_card.js) and the mode label (js/chat/mode_label.js) */
.clar { display: grid; gap: 9px; margin-top: 12px; padding: 12px 14px; border: 1px solid var(--honey-line); border-radius: 12px; background: var(--surface); }
.clar.wait { opacity: .7; }
.clar.done { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-color: var(--border); background: var(--sunken); font-size: 12.5px; color: var(--muted-2); }
.clar.done.muted { color: var(--muted); }
.clar.done svg { flex: 0 0 auto; color: var(--success); }
.clar-h { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink); }
.clar-h svg { color: var(--honey-ink); }
.clar-h .muted { color: var(--muted); }
.clar-q { margin: 0; font-size: 13px; color: var(--ink); }
.clar-why, .clar-known { margin: 0; font-size: 12px; color: var(--muted); }
.clar .rw { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; align-items: start; font-size: 12px; }
.clar .rw > span { padding-top: 4px; color: var(--muted); font-weight: 600; }
.clar .rwv { display: grid; gap: 6px; min-width: 0; }
.clar .ch { display: flex; flex-wrap: wrap; gap: 5px; }
.clar .ch button {
  max-width: 100%; padding: 3px 10px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  color: var(--body); font-size: 11.5px; text-align: left; overflow-wrap: anywhere; cursor: pointer;
}
.clar .ch button.sug { border-color: var(--honey); }
.clar .ch button.on { border-color: var(--honey); background: var(--honey-soft); color: var(--ink); font-weight: 600; }
.clar .ch button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.clar .ch button:disabled { cursor: default; }
.clar .clar-in { max-width: 320px; height: 32px; font-size: 13px; }
.clar-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.clar-foot .grow { flex: 1 1 auto; }
.clar-rem { display: inline-flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.clar-rem small { display: block; color: var(--muted); font-size: 11.5px; }
.clar-err { margin: 0; font-size: 12px; color: var(--danger); }
.clar-type { display: grid; gap: 6px; justify-items: start; }
.clar-type .help { margin: 0; font-size: 12px; color: var(--muted); }
.clar-say { margin: 0; padding: 6px 10px; border-radius: 8px; background: var(--sunken); font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; user-select: all; }
.modelabel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; padding: 6px 10px; border-radius: 8px; background: var(--sunken); font-size: 12px; color: var(--muted); }
.modelabel svg { flex: 0 0 auto; color: var(--honey-ink); }
.modelabel b { color: var(--ink); font-weight: 600; }
.modelabel .ml-t { min-width: 0; }
.modelabel .grow { flex: 1 1 auto; }
.src-chip.clar-chip { color: var(--success); }

/* model + effort picker (js/chat/model_picker.js) */
.mp-trigger {
  display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 240px; height: 32px; padding: 0 8px 0 10px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-ctl); color: var(--body); font-size: 12px; cursor: pointer;
}
.mp-trigger.mp-home { background: var(--surface); border-color: var(--border-strong); color: var(--ink); font-size: 13px; }
.mp-trigger:hover:not(:disabled), .mp-trigger[aria-expanded="true"] { border-color: var(--border-strong); background: var(--sunken); }
.mp-trigger:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.mp-trigger:disabled { cursor: default; opacity: .6; }
.mp-trigger .mp-cur { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-trigger .mp-eff { color: var(--muted); white-space: nowrap; }
.mp-trigger .mp-chev { flex: 0 0 auto; color: var(--muted); }
.pop.mp-pop { width: 360px; padding: 6px; }
.mp-head { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.mp-list { display: flex; flex-direction: column; gap: 2px; max-height: min(360px, 52vh); overflow-y: auto; }
.mp-item {
  display: grid; grid-template-columns: minmax(0, 1fr) 20px; column-gap: 10px; row-gap: 2px; width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--ink); text-align: left; cursor: pointer;
}
.mp-item:hover, .mp-item:focus-visible { background: var(--sunken); outline: none; }
.mp-item:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.mp-t { grid-column: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.mp-name { font-size: 14px; font-weight: 500; }
.mp-item.sel .mp-name { font-weight: 600; }
.mp-tag { height: 18px; line-height: 18px; padding: 0 7px; border-radius: 999px; background: var(--honey-soft); color: var(--honey-ink); font-size: 11px; font-weight: 600; }
.mp-d { grid-column: 1; font-size: 12px; line-height: 1.4; color: var(--muted); }
.mp-price { grid-column: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mp-check { grid-column: 2; grid-row: 1 / span 3; align-self: center; color: var(--ink); }
.mp-effort { margin-top: 6px; padding: 10px 10px 4px; border-top: 1px solid var(--border); }
.mp-erow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mp-elabel { font-size: 13px; color: var(--ink); }
.mp-eval { color: var(--muted); }
.mp-scale { position: relative; display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 999px; background: var(--sunken); }
.mp-rail { position: absolute; left: 14px; right: 14px; top: 50%; height: 2px; transform: translateY(-50%); background: var(--border-strong); }
.mp-dot { position: relative; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
.mp-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); transition: width .12s, height .12s; }
.mp-dot.past::before { background: var(--ink); }
.mp-dot.on::before { width: 14px; height: 14px; background: var(--ink); box-shadow: 0 0 0 3px var(--sunken); }
.mp-dot:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.mp-ehint { min-height: 16px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.mp-foot { margin-top: 8px; padding: 8px 10px 4px; border-top: 1px solid var(--border); font-size: 12px; line-height: 1.4; color: var(--muted); }
@media (pointer: coarse) { .mp-dot { width: 30px; height: 30px; } .mp-scale { gap: 2px; } .mp-item { padding: 10px; } }
@media (prefers-reduced-motion: reduce) { .mp-dot::before { transition: none; } }

/* "Lên kế hoạch": chip on the user message, "Thực hiện kế hoạch" bar under the plan answer (SPEC §62: turned on from
   the menu next to Gửi, shown as a chip in the composer) */
.plan-chip { display: inline-flex; align-items: center; gap: 4px; color: var(--info); }
.planbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--sunken); }
.planbar > span { font-size: 12px; color: var(--muted-2); }

/* propose_schedule card (js/chat/schedule_card.js); layout from .dashcard */
.dashcard.schedcard { align-items: flex-start; }
.schedcard .info .sub { display: block; margin-top: 2px; }
.sched-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 10px 0 0; font-size: 13px; }
.sched-dl dt { color: var(--muted); }
.sched-dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.sched-warn { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sched-warn li { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; color: var(--warning); }
.sched-warn li svg { flex: 0 0 auto; margin-top: 2px; }
.schedcard .acts { align-self: center; }
/* web_fetch needs the user's OK (js/chat/web_confirm.js) */
.webcard .ico { color: var(--warning); }
.webcard-url { font-size: 12px; overflow-wrap: anywhere; word-break: break-all; color: var(--ink); }

/* "Đang xem dữ liệu ngày …" bar of a data page opened with ?ngay= (js/dash/page.js) */
.pv-asof { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 0 12px; padding: 10px 14px;
  border: 1px solid var(--info); border-radius: var(--r-card); background: var(--info-soft); color: var(--ink); font-size: 13px; line-height: 1.45; }
.pv-asof[hidden] { display: none; }
.pv-asof > svg { flex: 0 0 auto; color: var(--info); }
.pv-asof .grow { flex: 1 1 260px; min-width: 0; }

/* freshness popover additions (js/ui/freshness.js): send-on-refresh box, schedule links row */
.fp-check { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.45; color: var(--muted-2); cursor: pointer; }
.fp-check input { margin: 2px 0 0; accent-color: var(--ink); }
.fp-links { padding-top: 2px; }
.fp-links .btn-quiet { padding: 0 6px; margin-left: -6px; font-size: 13px; }
.statusline { margin-top: 6px; padding-left: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 18px; }
.picker {
  position: absolute; left: 8px; bottom: calc(100% + 8px); z-index: 20; width: 420px; max-width: calc(100% - 16px);
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop);
}
.composer.home .picker { bottom: auto; top: calc(100% + 8px); }
.picker-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 6px 8px; }
.picker-head .k { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.picker-head .s { flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-list { max-height: 280px; overflow-y: auto; }
.picker-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0;
  border-radius: var(--r-ctl); background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; text-align: left;
}
.picker-item:hover, .picker-item.active { background: var(--sunken); }
.picker-item .ico { color: var(--muted-2); flex: 0 0 16px; }
.picker-item .t { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-item .t .mono { font-size: 12.5px; }
.picker-item .d { display: block; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-item .type { flex: 0 0 auto; height: 20px; line-height: 20px; padding: 0 8px; border-radius: 999px; background: var(--sunken); color: var(--muted-2); font-size: 12px; font-weight: 500; }
.picker-item.active .type { background: var(--surface); }
.picker-foot { margin: 4px 8px 2px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.picker-empty { padding: 10px 8px; font-size: 13px; color: var(--muted); }

.composer.chat .ctl .btn { flex: 0 0 auto; }

/* ------------------------------------------------------------------ chat */
.chat { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ctabs { display: flex; align-items: stretch; height: 40px; flex: 0 0 40px; background: var(--sunken); border-bottom: 1px solid var(--border); min-width: 0; }
.ctabs-list { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.ctabs-list::-webkit-scrollbar { display: none; }
.ctab { display: flex; align-items: center; flex: 0 1 auto; min-width: 0; max-width: 250px; height: 41px; margin-bottom: -1px; border-right: 1px solid var(--border); background: transparent; }
.ctab.on { background: var(--surface); }
.ctab .pick { display: flex; align-items: center; gap: 8px; min-width: 0; height: 40px; padding: 0 6px 0 12px; border: 0; background: transparent; font-size: 13px; color: var(--muted-2); font-weight: 500; }
.ctab.on .pick { color: var(--ink); font-weight: 600; }
.ctab .pick .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctab .x { flex: 0 0 26px; width: 26px; height: 26px; margin-right: 6px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: var(--muted-2); }
.ctab .x:hover { background: var(--hover); color: var(--ink); }
.ctabs .add { flex: 0 0 40px; width: 40px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--body); }
.ctabs .add:hover { color: var(--ink); background: var(--hover); }
.ctabs .right { margin-left: auto; display: flex; align-items: center; padding: 0 10px; flex: 0 0 auto; }
.ctabs .panel-btn { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap; }
.ctabs .panel-btn:hover { background: var(--hover); }
.chat-body { flex: 1 1 auto; min-height: 0; display: flex; }
.conv-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.conv { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 28px 24px 8px; }
.conv-inner { max-width: var(--reading); margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.composer-dock { flex: 0 0 auto; padding: 8px 24px 14px; }
.composer-dock .inner { max-width: var(--reading); margin: 0 auto; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 82%; background: var(--sunken); border: 1px solid var(--border); border-radius: 12px 12px 4px 12px;
  padding: 10px 14px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-user .refs { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; margin-top: 6px; }
.msg-user .col { display: flex; flex-direction: column; align-items: flex-end; max-width: 82%; }
.msg-user .col .bubble { max-width: 100%; }
.msg-ai { display: flex; gap: 12px; }
.msg-ai > .ai-mark { flex: 0 0 24px; margin-top: 2px; }
.msg-ai .body { flex: 1 1 auto; min-width: 0; }
.msg-ai .mhd { display: none; }
.steps { border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.steps .skills { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px 2px; font-size: 12px; color: var(--muted); }
.skill-pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); background: var(--honey-soft); color: var(--honey-ink); font-size: 12px; font-weight: 600; text-decoration: none; }
.skill-pill:hover { color: var(--honey-ink); text-decoration: underline; }
.steps .toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 0 12px; border: 0; background: transparent; font-size: 13px; color: var(--muted); text-align: left; }
.steps .toggle .chev { transition: transform .15s; }
.steps .toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.steps .list { border-top: 1px solid var(--border); padding: 4px 0; }
.step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 12px; border: 0; background: transparent; font-size: 13px; text-align: left; color: var(--body); }
button.step:hover { background: var(--bg); }
.step .nm { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--ink); flex: 0 0 auto; }
.step .sm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.step .sm.code { font-family: var(--font-mono); font-size: 12px; }
.step .tm { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; flex: 0 0 auto; }
.step.err .sm { color: var(--danger); }
.step-detail { padding: 2px 12px 10px 37px; }
.codebox { position: relative; }
.codebox pre { margin: 0; background: var(--sunken); border-radius: var(--r-ctl); padding: 10px 40px 10px 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--body); overflow-x: auto; white-space: pre; }
.codebox .copy { position: absolute; top: 6px; right: 6px; }
.step-detail .tbl-wrap { margin-top: 8px; border-radius: var(--r-ctl); }
.steps .run-note { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 6px 12px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.steps .run-note span { flex: 1 1 200px; }
.answer { margin-top: 14px; }
.answer:first-child { margin-top: 0; }
.thinking { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 4px 0; }
.thinking .bar { width: 36px; height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--hover), var(--honey), var(--hover)); background-size: 200% 100%; animation: aic-sk 1.2s linear infinite; }
.msg-err { margin-top: 10px; }
.msg-stopped { margin-top: 10px; font-size: 13px; color: var(--muted); }
.artcard { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.artcard .ico { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px; background: var(--honey-soft); color: var(--honey-ink); display: flex; align-items: center; justify-content: center; }
.artcard .info { flex: 1 1 160px; min-width: 0; }
.artcard .info b { display: block; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artcard .info span { font-size: 12px; color: var(--muted); }
.srcrow { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.actrow { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; margin-left: -8px; }
.actrow .btn-quiet { min-height: 32px; height: 32px; padding: 0 8px; font-size: 13px; font-weight: 400; gap: 6px; }
.actrow .btn-icon { color: var(--ink); }
.followups { margin-top: 14px; }
.followups .k { margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin: 0 8px 8px 0; padding: 0 12px; border: 0; border-radius: 999px; background: var(--honey-soft); color: var(--honey-ink); font-size: 13px; font-weight: 600; }
.ai-chip:hover { box-shadow: inset 0 0 0 1px var(--honey-line); }
.conv-empty { max-width: 560px; margin: 8vh auto 0; }
.conv-empty h2 { margin: 14px 0 6px; font-size: 20px; font-weight: 600; line-height: 1.35; }
.conv-empty > p { margin: 0 0 20px; font-size: 14px; color: var(--muted); }
.sugg { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); font-size: 14px; line-height: 1.4; color: var(--ink); text-align: left; }
.sugg:hover { border-color: var(--border-strong); }
.sugg svg { color: var(--honey-ink); }
.conv-loading { padding: 20px 0; }
.load-more { align-self: center; }

/* artifact panel */
.splitter { flex: 0 0 6px; width: 6px; cursor: col-resize; background: var(--sunken); border-left: 1px solid var(--border); display: flex; align-items: center; justify-content: center; touch-action: none; }
.splitter span { width: 2px; height: 28px; border-radius: 2px; background: var(--border-strong); }
.splitter:hover span, .splitter:focus-visible span { background: var(--muted); }
.apanel { flex: 0 0 46%; min-width: 320px; max-width: 75%; background: var(--surface); display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.ap-head { padding: 12px 16px 0; border-bottom: 1px solid var(--border); }
.ap-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-title .ico { flex: 0 0 28px; width: 28px; height: 28px; border-radius: var(--r-ctl); background: var(--honey-soft); color: var(--honey-ink); display: flex; align-items: center; justify-content: center; }
.ap-title h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vers { display: flex; gap: 4px; flex-wrap: wrap; }
.vers button { height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--body); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.vers button[aria-pressed="true"] { border-color: var(--honey); background: var(--honey-soft); color: var(--honey-ink); font-weight: 600; }
.ap-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ap-acts .btn { min-height: 32px; height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500; gap: 6px; }
.ap-acts .btn-primary { font-weight: 600; padding: 0 12px; }
.ap-view { margin: 12px 0; }
.ap-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 22px; position: relative; }
.ap-body.frame { padding: 0; overflow: hidden; display: flex; }
.ap-body iframe { flex: 1 1 auto; width: 100%; height: 100%; border: 0; background: #FFFFFF; }
.ap-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.ap-foot .input { flex: 1 1 auto; min-width: 0; font-size: 13px; }
.ap-old { margin: 12px 16px 0; }
.ap-back { display: none; }
.ap-bar { display: none; }

.mob-ver, .ap-more { display: none; }
.apanel.is-empty .ap-acts, .apanel.is-empty .ap-view, .apanel.is-empty .ap-foot, .apanel.is-empty .ap-bar, .apanel.is-empty .vers, .apanel.is-empty .mob-ver, .apanel.is-empty .ap-more { display: none !important; }
.apanel.is-empty .ap-head { border-bottom: 0; padding-bottom: 8px; }
.apanel.is-empty .ap-body { display: flex; align-items: center; justify-content: center; }
.apanel[hidden] { display: none !important; }
.msg-user .bubble.pending { opacity: .72; }
.chat-body .apanel { min-height: 0; }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--bg); }
.login-card { width: 420px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-float); padding: 28px 28px 22px; display: flex; flex-direction: column; gap: 18px; }
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand b { display: block; font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.login-brand small { font-size: 12px; color: var(--muted); }
.login-card h1 { font-size: 22px; font-weight: 600; line-height: 1.3; }
.login-card .lead { margin-top: 6px; font-size: 14px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-or { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.login-or::before, .login-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border); }
.gsi-box { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-height: 44px; }
.gsi-btn { min-height: 44px; display: flex; justify-content: center; }
.login-note { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.login-note span { display: flex; gap: 8px; align-items: flex-start; }
.login-note svg { color: var(--success); margin-top: 2px; }

/* login layout A "Tổ ong dữ liệu" (2026-10-23): intro panel + form. The panel stays dark in both themes, so its
   colours are fixed values, not theme tokens. */
.login.login-a { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: flex-start; padding: 0; }
.login-hero { flex: 1 1 540px; min-width: 0; box-sizing: border-box; background: #1C1917; color: #F4F0E9; padding: 44px 56px 48px; display: flex; flex-direction: column; gap: 36px; }
:root[data-theme="dark"] .login-hero { background: #0F0E0C; border-right: 1px solid var(--border); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-hero { background: #0F0E0C; border-right: 1px solid var(--border); } }
.lh-brand { display: flex; align-items: center; gap: 12px; }
.lh-brand b { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; color: #F4F0E9; }
.lh-brand small { font-size: 13px; color: #A69D91; }
.lh-mid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 32px; margin: auto 0; }
.lh-copy { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.login-hero h2 { margin: 0; font-size: 40px; line-height: 1.18; font-weight: 600; letter-spacing: -.01em; color: #F4F0E9; }
.lh-lead { margin: 0; max-width: 420px; font-size: 16px; line-height: 1.6; color: #CFC7BB; }
.lh-art { flex: 0 1 300px; width: 300px; max-width: 100%; height: auto; }
.lh-art .lh-cell use { fill: #24201C; stroke: #3A342E; stroke-width: 1.5; }
.lh-art .lh-cell-top use { fill: #F2B23A; stroke: #F2B23A; stroke-width: 1.5; }
.lh-art .lh-spark { fill: #1C1917; }
.lh-feats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.lh-feats li { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lh-ico { width: 40px; height: 40px; border-radius: 10px; background: rgba(242, 178, 58, .14); color: #F2B23A; display: flex; align-items: center; justify-content: center; }
.lh-feats b { font-size: 15px; font-weight: 600; color: #F4F0E9; }
.lh-feats li > span:last-child { font-size: 13.5px; line-height: 1.5; color: #A69D91; }
.login-pane { flex: 1 1 420px; min-width: 0; box-sizing: border-box; display: flex; align-items: center; justify-content: center; padding: 48px 32px; background: var(--bg); }
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 22px; }
.login-form h1 { font-size: 30px; font-weight: 600; line-height: 1.25; color: var(--ink); }
.login-form .lead { margin-top: 8px; font-size: 15px; line-height: 1.6; color: var(--muted); }
.login-form form { display: flex; flex-direction: column; gap: 12px; }
.login-domain { display: flex; align-items: center; gap: 8px; margin: -8px 0 0; font-size: 13px; color: var(--muted); }
.login-domain svg { flex: 0 0 16px; }
.login-form .login-note { gap: 10px; padding-top: 18px; font-size: 13px; line-height: 1.5; }
.login-form .login-note span { gap: 10px; }
.login-form .login-note svg { flex: 0 0 16px; }
@media (max-width: 960px) {
  .login.login-a { flex-direction: column; flex-wrap: nowrap; }
  .login-hero { flex: 0 0 auto; padding: 28px 24px 24px; gap: 18px; }
  .lh-mid { margin: 0; }
  .login-hero h2 { font-size: 30px; }
  .lh-art, .lh-feats { display: none; }
  .login-pane { flex: 1 0 auto; padding: 32px 16px 40px; align-items: flex-start; }
}

/* ------------------------------------------------------------------ Máy chủ (#/may-chu, screens/maychu.js) */
.srv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.srv-card { display: flex; flex-direction: column; gap: 10px; }
.srv-row { display: flex; align-items: baseline; gap: 12px; font-size: 13.5px; min-width: 0; }
.srv-row .k { flex: 0 0 92px; color: var(--muted); }
.srv-row .v { flex: 1 1 auto; min-width: 0; color: var(--body); overflow-wrap: anywhere; }
.srv-path { font-size: 12px; }
.srv-sub { margin: 2px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.srv-meter { display: inline-flex; align-items: center; gap: 10px; }
.srv-bar { display: inline-block; width: 96px; height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; flex: 0 0 auto; }
.srv-bar > span { display: block; height: 100%; background: var(--success); }
.srv-bar.hot > span { background: var(--warning-dot); }
.srv-big { display: flex; align-items: baseline; gap: 6px 8px; flex-wrap: wrap; }
.srv-big b { font-size: 28px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.srv-big b.bad { color: var(--danger); }
.srv-big span { font-size: 13px; color: var(--muted); margin-right: 12px; }
.srv-last { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--r-ctl); background: var(--danger-soft); color: var(--danger); font-size: 12.5px; line-height: 1.45; overflow-wrap: anywhere; }
.srv-last .mono { font-size: 11.5px; opacity: .85; }
.srv-acts, .srv-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.srv-tools { margin-top: 0; }
.srv-cklist { list-style: none; margin: 12px 0 8px; padding: 0; display: flex; flex-direction: column; }
.srv-cklist li { display: grid; grid-template-columns: 10px minmax(150px, 220px) 64px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--grid); font-size: 13.5px; }
.srv-cklist li:first-child { border-top: 0; }
.srv-cklist b { font-weight: 600; color: var(--ink); }
.srv-ms { font-size: 12px; color: var(--muted); text-align: right; }
.srv-cklist li.bad .srv-ms { color: var(--danger); }
.srv-ckd { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.srv-cklist li.bad .srv-ckd { color: var(--danger); }
.srv-logcard { display: flex; flex-direction: column; gap: 12px; }
.srv-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.srv-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.srv-q { flex: 1 1 220px; min-width: 0; max-width: 360px; height: 32px; }
.srv-size { width: auto; height: 32px; }
.srv-auto { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--body); }
.srv-log { height: 60vh; min-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-ctl); background: var(--sunken); padding: 6px 0; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; }
.srv-log:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.srv-e { padding: 1px 12px; color: var(--body); }
.srv-e:hover { background: var(--hover); }
.srv-e > .ts, .srv-e > summary > .ts { color: var(--muted); margin-right: 8px; white-space: nowrap; }
.srv-e .lv { display: inline-block; min-width: 56px; margin-right: 8px; font-weight: 600; }
.srv-e .lv.err { color: var(--danger); }
.srv-e .lv.warn { color: var(--warning); }
.srv-e .lv.info { color: var(--muted); font-weight: 500; }
.srv-e .lg { color: var(--muted); margin-right: 8px; }
.srv-e .tx { white-space: pre-wrap; overflow-wrap: anywhere; }
.srv-e.multi > summary { cursor: pointer; list-style: none; }
.srv-e.multi > summary::-webkit-details-marker { display: none; }
.srv-e .more { margin-left: 8px; color: var(--info); font-size: 11px; }
.srv-e pre { margin: 2px 0 6px 0; padding: 6px 10px; border-left: 2px solid var(--border-strong); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted-2); font: inherit; }
.srv-empty { padding: 16px 12px; color: var(--muted); font-family: var(--font-ui); font-size: 13px; }
@media (max-width: 720px) {
  .srv-cklist li { grid-template-columns: 10px minmax(0, 1fr) 56px; }
  .srv-ckd { grid-column: 2 / -1; }
  .srv-log { height: 70vh; }
}

/* ------------------------------------------------------------------ palette + notifications */
.palette { width: 640px; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); display: flex; flex-direction: column; max-height: 70vh; min-height: 0; overflow: hidden; }
.palette .q { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--muted); }
.palette .q input { flex: 1 1 auto; min-width: 0; height: 52px; border: 0; background: transparent; font-size: 16px; color: var(--ink); }
.palette .q input:focus { outline: none; }
.palette .res { overflow-y: auto; padding: 6px; min-height: 0; }
.palette .grp { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.palette .it { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 10px; border: 0; border-radius: var(--r-ctl); background: transparent; color: var(--ink); text-align: left; font-size: 14px; }
.palette .it .ico { color: var(--muted); flex: 0 0 18px; display: inline-flex; }
.palette .it .t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette .it .d { font-size: 12px; color: var(--muted); flex: 0 0 auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette .it.active, .palette .it:hover { background: var(--sunken); }
.palette .it.ask .ico { color: var(--honey-ink); }
.palette .foot { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.notif-pop { width: 380px; padding: 0; }
.notif-pop .hd { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.notif-pop .hd b { flex: 1 1 auto; font-size: 14px; color: var(--ink); }
.notif-list { max-height: min(520px, 70vh); overflow-y: auto; padding: 0 6px 6px; }
/* one notification: a plain container (title link + action buttons inside, never a link around buttons) */
.notif { display: flex; gap: 10px; width: 100%; padding: 10px 8px; border-radius: var(--r-ctl); text-align: left; color: var(--body); }
.notif + .notif { box-shadow: 0 -1px 0 var(--border); border-top-left-radius: 0; border-top-right-radius: 0; }
.notif .nd { flex: 0 0 8px; margin-top: 7px; }
.notif .nb { flex: 1 1 auto; min-width: 0; }
.notif .nh { display: flex; align-items: flex-start; gap: 4px; }
.notif .nt { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.4; text-decoration: none; overflow-wrap: anywhere; }
.notif a.nt:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.notif.read .nt { font-weight: 500; color: var(--body); }
.notif .nr { margin: -4px -4px -4px 0; color: var(--muted); }
.notif .nr + .ndel { margin-left: 2px; }
.notif .ndel:hover { color: var(--danger); }
/* delete shows on hover / keyboard focus where there is a pointer; always on touch */
@media (hover: hover) {
  .notif .ndel { opacity: 0; transition: opacity .12s; }
  .notif:hover .ndel, .notif:focus-within .ndel { opacity: 1; }
}
.notif-list:focus { outline: none; }
.notif .nx { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.notif .nm { font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.notif .nk { font-weight: 600; color: var(--muted-2); }
.notif .nk.danger { color: var(--danger); }
.notif .nk.warning { color: var(--warning); }
.notif .na { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.notif .na .btn { max-width: 100%; }
.notif .na .btn .lbl { overflow: hidden; text-overflow: ellipsis; }

/* placeholder screen */
.ph { max-width: 640px; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .apanel { flex-basis: 50%; }
}
/* below 1024px the artifact panel becomes a full-screen overlay (SPEC 19.2) */
@media (max-width: 1023px) {
  .apanel { position: fixed; inset: 0; z-index: 70; max-width: none; min-width: 0; width: auto !important; flex: none; border-left: 0; background: var(--bg); }
  .splitter { display: none; }
  .ap-head { background: var(--surface); padding: 0; }
  .ap-title { flex-wrap: nowrap; height: 52px; padding: 0 6px 0 4px; border-bottom: 1px solid var(--border); }
  .ap-title .ico, .ap-title .x-close, .ap-acts { display: none; }
  .ap-back { display: inline-flex; }
  .mob-ver, .ap-more { display: inline-flex; }
  .vers { display: none; }
  .ap-title h2 { flex: 1 1 auto; font-size: 14px; }
  .ap-view { display: flex; margin: 0; padding: 8px 12px 10px; }
  .ap-view .seg { display: flex; flex: 1 1 auto; }
  .ap-view .seg button { flex: 1 1 0; height: 34px; }
  .ap-body { padding: 12px; }
  .ap-bar { display: flex; gap: 8px; padding: 10px 12px 14px; background: var(--surface); border-top: 1px solid var(--border); }
  .ap-bar .btn { min-height: 40px; }
  .ap-bar .btn-primary { flex: 1 1 auto; }
  .ap-foot { background: var(--surface); }
}
@media (max-width: 760px) {
  :root { --content-pad: 16px 16px 32px; }
  .app { flex-direction: column; }
  .nav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 61; width: 304px; max-width: 86vw;
    transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow-pop); border-right: 0;
  }
  .app.drawer-open .nav { transform: none; }
  .nav-item { height: 38px; margin-bottom: 2px; }
  .nav-recent { height: 34px; padding-left: 16px; margin-bottom: 2px; }
  .nav-search { height: 40px; font-size: 14px; }
  .nav-search kbd { display: none; }
  .nav-new { min-height: 40px; }
  .nav .drawer-x { display: inline-flex; }
  .mhead {
    display: flex; align-items: center; flex: 0 0 52px; height: 52px; padding: 0 12px 0 6px; gap: 4px;
    border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 30;
  }
  .mhead h1 { flex: 1 1 auto; min-width: 0; margin: 0 8px 0 4px; font-size: 15px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mhead .src-pill { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12px; font-weight: 500; color: var(--body); white-space: nowrap; max-width: 120px; overflow: hidden; }
  .mhead .avatar { flex-basis: 32px; width: 32px; height: 32px; margin-left: 4px; }
  .main { flex: 1 1 auto; min-height: 0; }
  .home { padding: 16px 16px 40px; }
  .greet { margin: 20px 0 18px; }
  .greet h1 { font-size: 24px; }
  .composer.home textarea { min-height: 72px; font-size: 15px; }
  .sec { margin-top: 28px; }
  .page-head h1 { font-size: 20px; }
  /* chat on phone: chips tab strip, compact composer (Mobile.dc.html) */
  .ctabs { height: auto; flex: 0 0 auto; background: var(--bg); padding: 8px 16px; gap: 0; }
  .ctabs-list { gap: 8px; }
  .ctab { height: 34px; margin: 0; border: 1px solid var(--sunken); border-radius: 999px; background: var(--sunken); max-width: 200px; }
  .ctab.on { background: var(--surface); border-color: var(--border-strong); }
  .ctab .pick { height: 32px; padding: 0 12px; }
  .ctab .x { display: none; }
  .ctab .pick .dot.cur { display: none; }
  .ctabs .add { flex: 0 0 auto; width: auto; height: 34px; margin-left: 8px; padding: 0 12px 0 9px; gap: 4px; border: 1px dashed var(--border-strong); border-radius: 999px; font-size: 13px; font-weight: 500; }
  .ctabs .add .lbl { display: inline; }
  .ctabs .right { display: none; }
  .conv { padding: 16px 16px 20px; }
  .conv-inner { gap: 18px; }
  .msg-user .bubble, .msg-user .col { max-width: 296px; }
  .msg-user .bubble { background: var(--surface); border-radius: 12px; padding: 10px 12px; }
  .msg-ai { flex-direction: column; gap: 0; }
  .msg-ai > .ai-mark { display: none; }
  .msg-ai .mhd { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--ink); }
  .msg-ai .mhd .when { font-size: 12px; font-weight: 400; color: var(--muted); }
  .steps .toggle { min-height: 40px; background: var(--sunken); }
  .composer-dock { padding: 8px 12px 12px; background: var(--bg); }
  .composer.chat { border-color: var(--border); padding: 10px 10px 10px 12px; }
  .schedcard .acts { width: 100%; }
  /* SPEC §62 phone: four controls, each ≥ 40 px: [📎] [⚙ Nhanh · Bridge …] [Gửi] [▾]; ⚙ opens a bottom sheet */
  .composer .qchips { display: none; }
  .composer .ctl { margin-top: 8px; gap: 6px; }
  .composer .ctl > * { min-height: 40px; }
  .composer .ctl .sp { display: none; }
  .composer.chat .ctl .att-btn, .composer.home .ctl .att-btn, .composer .ctl .att-btn { width: 40px; height: 40px; }
  .composer .cmp-pill { flex: 1 1 auto; max-width: none; height: 40px; gap: 5px; padding: 0 10px; }
  .composer .cmp-pill > .chev { display: none; }
  .composer .split .send { min-height: 40px; padding: 0 14px; }
  .composer .split .send-caret { width: 40px; min-height: 40px; }
  /* the label stays ("Chạy ngầm"): ▾ is hidden while a turn runs, so the row has room */
  .composer .cmp-bgnow { min-height: 40px; flex: 0 0 auto; padding: 0 10px; gap: 5px; white-space: nowrap; }
  /* while "Chạy ngầm" shows, the ⚙ pill keeps only its icon (its aria-label still names the mode and the source) */
  .composer .ctl:has(> .cmp-bgnow:not([hidden])) .cmp-pill { flex: 0 0 40px; width: 40px; padding: 0; justify-content: center; }
  .composer .ctl:has(> .cmp-bgnow:not([hidden])) .cmp-pill > :not(svg:first-child) { display: none; }
  .composer .ctl > .cmp-bgnow:not([hidden]) { margin-left: auto; }
  .modal.sheet { width: 100%; max-width: 100%; max-height: 82vh; border-radius: 16px 16px 0 0; border-bottom: 0; }
  .modal-wrap:has(> .modal.sheet) { padding: 0; }
  .modal.sheet .ro2 { padding: 10px; }
  .clar .rw { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .clar .rw > span { padding-top: 0; }
  .clar .ch button { min-height: 32px; }
  .nav .bell { display: none; }
  .statusline { display: none; }
  .artcard .acts { display: flex; width: 100%; gap: 8px; }
  .artcard .acts .btn { flex: 1 1 0; min-height: 40px; }
  .picker { width: auto; right: 8px; }
  .ap-foot { display: none; }
  .palette { max-height: 80vh; }
  .modal-wrap { padding: 16px 8px; align-items: flex-end; }
  .notif-pop { width: calc(100vw - 16px); }
  .notif .na .btn { min-height: 32px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
}
@media (min-width: 761px) {
  .nav .drawer-x { display: none; }
  .ctabs .add .lbl { display: none; }
}

/* Có gì mới (js/screens/comoi.js): changelog timeline */
.nav-user-more { position: relative; display: inline-flex; }
.nav-new-dot { position: absolute; top: 4px; right: 4px; pointer-events: none; box-shadow: 0 0 0 2px var(--surface); }
.cl-page { max-width: 880px; }
.cl-intro { margin: 0; color: var(--muted); font-size: 14px; }
.cl-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.cl-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; }
.cl-chip .n { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.cl-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.cl-chip[aria-pressed="true"] .n { color: inherit; opacity: .75; }
.cl-chip:focus-visible { outline: 2px solid var(--honey); outline-offset: 2px; }
.cl-timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 18px; }
.cl-entry { position: relative; display: flex; flex-direction: column; gap: 8px; }
.cl-when { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); margin-left: -25px; }
.cl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); flex: 0 0 auto; }
.cl-entry.is-new .cl-dot { background: var(--honey); border-color: var(--honey); }
.cl-card { display: flex; flex-direction: column; gap: 8px; }
.cl-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cl-head:empty { display: none; }
.cl-title { margin: 0; font-size: 16px; line-height: 1.35; }
.cl-summary { margin: 0; color: var(--muted); font-size: 13.5px; }
.cl-items { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cl-items > li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 14px; }
.cl-kind { justify-self: start; margin-top: 1px; }
.cl-text > :first-child { margin-top: 0; }
.cl-text > :last-child { margin-bottom: 0; }
.cl-text p { margin: 0 0 4px; }
@media (max-width: 640px) {
  .cl-timeline { padding-left: 14px; }
  .cl-when { margin-left: -21px; }
  .cl-items > li { grid-template-columns: 1fr; gap: 4px; }
}
.cl-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.cl-top .tabs { flex: 1 1 auto; min-width: 0; }
.cl-share { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cl-access { font-size: 12.5px; color: var(--muted); }
.cl-log { display: flex; flex-direction: column; gap: 16px; }
.cl-backlog { min-width: 0; overflow-x: auto; }
.cl-backlog table { font-size: 13.5px; }
/* live notice under a running answer (cost warning, SPEC 29.8) */
.msg-notice { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 8px 12px; border-radius: var(--r-ctl); font-size: 13px; line-height: 1.45; }
.msg-notice.warning { background: var(--warning-soft); color: var(--warning); }
.msg-notice svg { flex: 0 0 auto; margin-top: 1px; }
