/* v1.9 (SPEC 33): chat timeline like the Claude panel of VS Code (33.1), pins + projects in the nav (33.2).
   Colours come from tokens.css only, so light and dark both work. */

/* ------------------------------------------------------------------ 33.1 timeline */
.msg-ai .body > .tl-group,
.msg-ai .body > .tl-solo,
.msg-ai .body > .tl-live { margin-top: 12px; }
.msg-ai .body > .tl-group:first-child,
.msg-ai .body > .tl-solo:first-child,
.msg-ai .body > .tl-live:first-child,
.msg-ai .body > .tl-used + .tl-group,
.msg-ai .body > .tl-used + .tl-solo,
.msg-ai .body > .tl-used + .tl-live { margin-top: 0; }
.msg-ai .body > .tl-group + .answer,
.msg-ai .body > .tl-solo + .answer { margin-top: 12px; }
.tl-used { margin-bottom: 10px; }
.tl-used .skills { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 12px; color: var(--muted); }
.tl-used .skills + .skills { margin-top: 6px; }

.tl-group .toggle .lbl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-group .toggle .lbl b { font-weight: 600; color: var(--ink); }
.tl-group .toggle .tm { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.tl-group.running { border-color: var(--honey-line); }

/* the rail: one dot per step, joined by a thin line */
.tl { position: relative; border-top: 1px solid var(--border); padding: 6px 0 6px; }
.tl-sub { border-top: 0; padding: 2px 0 0; margin-left: -6px; }
.tl-row { position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 0 12px 0 14px; }
.tl-row::before { content: ''; position: absolute; left: 20px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.tl-row:first-child::before { top: 14px; }
.tl-row:last-child::before { bottom: calc(100% - 14px); }
.tl-row:only-child::before { display: none; }
.tl-dot { position: relative; z-index: 1; flex: 0 0 13px; width: 13px; height: 13px; margin-top: 8px; display: flex; align-items: center; justify-content: center; }
.tl-dot::after { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.tl-dot.ok::after { background: var(--success); }
.tl-dot.err::after { background: var(--danger); }
.tl-dot.think::after, .tl-dot.wait::after { width: 6px; height: 6px; background: transparent; border: 1.5px solid var(--muted); }
.tl-dot.wait::after { border-color: var(--honey); animation: tl-pulse 1.4s ease-in-out infinite; }
.tl-dot.run { background: var(--surface); }
.tl-dot.run::after { display: none; }
.tl-dot.run .spin { width: 12px; height: 12px; }
.tl-main { flex: 1 1 auto; min-width: 0; padding: 2px 0; }
.tl-head { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 28px; padding: 2px 6px; margin-left: -6px; border: 0; border-radius: 6px;
  background: transparent; font-size: 13px; text-align: left; color: var(--body); }
.tl-head:hover { background: var(--hover); }
.tl-head .nm { flex: 0 0 auto; font-weight: 600; color: var(--ink); }
.tl-head .sm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tl-head .sm.code { font-family: var(--font-mono); font-size: 12px; }
.tl-head .tm { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-head .chev { flex: 0 0 auto; color: var(--muted); transition: transform .15s; }
.tl-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.tl-row.err .tl-head .sm { color: var(--danger); }
.tl-think { display: inline-block; padding: 6px 0 4px; font-size: 12.5px; color: var(--muted); font-style: italic; }
.tl-row.think { min-height: 26px; }

/* IN / OUT of a step (the "IN"/"OUT" box of VS Code) */
.tl-io { margin: 4px 0 8px; border: 1px solid var(--border); border-radius: var(--r-ctl); overflow: hidden; background: var(--bg); }
.io-row { display: flex; align-items: flex-start; gap: 0; }
.io-row + .io-row { border-top: 1px solid var(--border); }
.io-k { flex: 0 0 44px; padding: 9px 0 0 10px; font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .04em; color: var(--muted); }
.io-v { flex: 1 1 auto; min-width: 0; padding: 6px 8px 6px 0; }
.io-name { font-size: 11.5px; color: var(--muted); margin: 2px 0 4px; }
.io-v .codebox pre { max-height: 240px; overflow: auto; background: var(--sunken); white-space: pre-wrap; overflow-wrap: anywhere; }
.io-text { margin: 0; max-height: 200px; overflow: auto; padding: 8px 10px; border-radius: 6px; background: var(--sunken); font-family: var(--font-mono);
  font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--body); }
.io-text.err { color: var(--danger); background: var(--danger-soft); }
.io-note { margin: 4px 0; font-size: 12.5px; color: var(--muted); }
.io-v .tool-prev, .io-v .tbl-wrap { margin-top: 2px; }

/* lone "Suy nghĩ N giây" line between two pieces of text, and the live line at the bottom */
.tl-solo .tl-row { padding-left: 0; }
.tl-solo .tl-row::before { display: none; }
.tl-live { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 13px; color: var(--muted); }
.tl-live .tl-dot { margin-top: 0; }
.tl-live .tick { font-variant-numeric: tabular-nums; color: var(--muted-2); }
.tl-live .tick::before { content: '· '; }
@keyframes tl-pulse { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .tl-dot.wait::after { animation: none; } }

/* §56: "Đang viết báo cáo «…» · 1 phút · 12.400 / ~41.900 ký tự ▬▬▭ · còn khoảng 1 phút" */
.tl-live.writing { flex-wrap: wrap; row-gap: 4px; }
.tl-live .tl-whead { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.tl-live .tl-whead .tl-lbl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--body); }
.tl-live .tl-whead .tick { flex: 0 0 auto; white-space: nowrap; }
.tl-live .tl-meter { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; font-variant-numeric: tabular-nums; }
.tl-live .tl-bar { flex: 0 1 200px; width: 200px; max-width: 100%; height: 4px; border-radius: 2px; background: var(--sunken); overflow: hidden; }
.tl-live .tl-bar i { display: block; height: 100%; background: var(--honey); transition: width .4s; }
.tl-live .tl-hint { flex-basis: 100%; padding-left: 20px; font-size: 12px; color: var(--muted); }
.tl-live .tl-wait { color: var(--muted-2); }
@media (prefers-reduced-motion: reduce) { .tl-live .tl-bar i { transition: none; } }

@media (max-width: 640px) {
  .tl-head .sm { display: none; }
  .tl-head .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .io-k { flex-basis: 36px; }
  .tl-live .tl-meter { flex-basis: 100%; padding-left: 20px; }
  .tl-live .tl-bar { flex: 1 1 120px; width: auto; max-width: 200px; }
}

/* print / export: folded groups print their one-line summary, open ones print as shown */
body.print-mode #print-root .tl-head { pointer-events: none; }
body.print-mode #print-root .tl-head .chev { display: none; }
body.print-mode #print-root .tl-live { display: none !important; }
body.print-mode #print-root .io-v .codebox pre, body.print-mode #print-root .io-text { max-height: none; overflow: visible; }

/* ------------------------------------------------------------------ 33.2 pins + projects */
/* nav rows: the "⋯" button reuses the hover-revealed slot of the old trash button */
.nav-more:hover { background: var(--hover); color: var(--ink); }
.nav-recent.nav-proj { gap: 8px; padding-left: 10px; }
.nav-proj-ico { flex: 0 0 auto; color: var(--muted-2); }
.nav-recent.nav-proj[aria-current="page"] .nav-proj-ico { color: var(--honey-ink); }
.nav-recent-row.nested .nav-recent { padding-left: 32px; font-size: 12.5px; height: 28px; }
.nav-recent-row.nested .nav-recent[aria-current="page"]::before { left: 22px; }
button.nav-recent { width: 100%; border: 0; background: transparent; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.nav-proj-new { color: var(--muted-2); gap: 8px; padding-left: 10px; }
.nav-more-link .lbl { color: var(--muted-2); font-size: 12.5px; }
.nav-ghead[hidden], .nav-group[hidden], .nav-recents[hidden] { display: none; }

/* "Dự án: IAP tuần · AI dùng hướng dẫn của dự án" above a conversation */
.conv-proj-slot:empty { display: none; }
.conv-proj { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; align-self: flex-start; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: var(--r-pill); background: var(--surface); color: var(--body); font-size: 12.5px; text-decoration: none; }
.conv-proj:hover { border-color: var(--border-strong); color: var(--ink); }
.conv-proj .nm { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-proj .note { color: var(--muted); white-space: nowrap; }
.conv-proj .note::before { content: '· '; }
@media (max-width: 640px) { .conv-proj .note { display: none; } }

/* #/du-an and #/du-an/<id> */
.prj-page { max-width: 860px; }
.prj-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prj-head .grow { flex: 1 1 240px; min-width: 0; }
.prj-head h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.prj-head .sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.prj-head .sub a { color: var(--muted); }
.prj-ico { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--honey-soft); color: var(--honey-ink); }
.prj-ask .help { margin: 8px 2px 0; }
.prj-ins-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prj-ins h2 { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.prj-ins-text { margin: 8px 0 0; white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; color: var(--body); max-height: 220px; overflow: auto; }
.prj-ins-empty { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.prj-sec { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.prj-sec h2 { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.prj-sec .cnt { font-size: 12px; font-weight: 500; color: var(--muted); }
.prj-chats { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); overflow: hidden; }
.prj-chat { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.prj-chat + .prj-chat { border-top: 1px solid var(--border); }
.prj-chat a { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px 0 16px; color: var(--body); text-decoration: none; }
.prj-chat a:hover { background: var(--bg); color: var(--ink); }
.prj-chat .ci { flex: 0 0 auto; color: var(--muted); }
.prj-chat .ttl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.prj-chat .when { flex: 0 0 auto; font-size: 12px; color: var(--muted); }
.prj-pin { flex: 0 0 auto; color: var(--muted); margin-left: 6px; vertical-align: -2px; }
.prj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.prj-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); color: var(--body); text-decoration: none; min-width: 0; }
.prj-card:hover { border-color: var(--border-strong); }
.prj-card .ico { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--honey-soft); color: var(--honey-ink); }
.prj-card .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prj-card b { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prj-card .info > span { font-size: 12px; color: var(--muted); }

/* Kết nối Claude: the bridge version on the download step (owner 2026-10-21) */
.kn-outdated { display: flex; align-items: flex-start; gap: 6px; margin: 0; padding: 8px 10px; border-radius: var(--r-ctl);
  background: var(--warning-soft); color: var(--warning); font-size: 13px; line-height: 1.5; }
.kn-outdated svg { flex: 0 0 auto; margin-top: 3px; }
.kn-old { color: var(--warning); }
