/* Assistant column (right-most, collapsible, splitter-resizable) */

#chatCol {
  background: var(--surface2);
  display: flex; flex-direction: column;
  min-height: 0; min-width: 0;
}
/* the message area and the composer share the same horizontal inset so their right edges
   line up; a reserved (stable) thin scrollbar gutter keeps that alignment steady */
.chat-msgs { flex: 1; overflow-y: auto; scrollbar-gutter: stable;
  padding: 12px 12px; display: flex; flex-direction: column; gap: 8px;
  /* the transcript is freely selectable/copyable (user messages + agent replies) */
  user-select: text; -webkit-user-select: text; }
.chat-msgs::-webkit-scrollbar { width: 8px; }
.chat-msgs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.chat-msgs::-webkit-scrollbar-thumb:hover { background: var(--faint); }
/* one chat bubble — user right (accent), agent left (surface); pre-wrap keeps the
   model's line breaks */
.chat-intro { color: var(--muted); font-size: 12px; text-align: center; padding: 6px 8px; }
.chat-msg {
  max-width: 85%; padding: 7px 10px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere;
}
.chat-msg.user { align-self: flex-end; background: var(--accent-soft); color: var(--ink); }
/* agent answer: borderless, full width of the chat area (the user bubble keeps its
   chip look; the assistant reads like a document, not a boxed message) */
.chat-msg.agent { align-self: stretch; max-width: 100%; background: none; border: 0; padding: 7px 2px; color: var(--ink); }
.chat-msg.error { color: var(--danger); }
/* rendered markdown inside agent bubbles */
.chat-msg strong { font-weight: 650; }
.chat-msg em { font-style: italic; }
.chat-msg code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; background: var(--surface2); padding: 0 4px; border-radius: 4px; }
/* fenced ``` code block — a real block, monospace, scrollable, NOT inline-styled */
.chat-code { margin: 6px 0; padding: 8px 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; }
.chat-code code { background: none; padding: 0; border-radius: 0; font-size: 11.5px;
  white-space: pre; display: block; line-height: 1.45; }
.chat-msg ul { margin: 4px 0; padding-left: 18px; }
.chat-msg li { margin: 2px 0; }
/* "saved as version N" badge under an agent turn that edited the template */
.chat-version { margin-top: 6px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 5px; }
/* the agent's tool activity, inline + chronological (reads/edits/commands); not truncated */
.chat-tool { display: flex; align-items: flex-start; gap: 5px; margin: 3px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10.5px; color: var(--muted); }
.chat-tool > span { white-space: pre-wrap; word-break: break-word; }
.chat-tool-ic { flex: none; margin-top: 1px; opacity: .85; }
/* a reasoning step inside the thinking block — faint italic with a small marker */
.chat-think { font-style: italic; opacity: .8; }
.chat-think-dot { flex: none; margin-top: 1px; opacity: .7; }
/* raw API-error / debug line (e.g. "API 429 rate_limit · attempt 3/10 · backoff 23s") —
   monospace, danger-tinted, full opacity so it stands out from dimmed reasoning steps */
.chat-apierr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; color: var(--danger); opacity: .95; }
.chat-apierr-dot { flex: none; margin-top: 1px; }
/* the collapsible "Думаю… M:SS ›" block: holds all reasoning + tool calls; the final answer
   sits OUTSIDE it. Collapsed by default; the header carries the live/elapsed timer. */
.chat-think-block { margin: 2px 0 4px; }
.chat-think-head {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  background: none; border: none; padding: 1px 0; color: var(--muted);
  font-size: 12px; font-style: italic; line-height: 1.4;
}
.chat-think-head:hover { color: var(--text); }
/* the caret (▸ / ▾) — fixed box, centered, same line-height as the title so the open and
   closed glyphs sit at the SAME height as each other and as the label */
.chat-think-caret {
  font-style: normal; flex: none; width: 10px; display: inline-flex;
  align-items: center; justify-content: center; line-height: 1.4; font-size: 9px; opacity: .75;
}
.chat-think-block.live .chat-think-title { /* gentle pulse while running */ animation: chatThinkPulse 1.4s ease-in-out infinite; }
@keyframes chatThinkPulse { 0%,100% { opacity: .65; } 50% { opacity: 1; } }
.chat-think-body { margin: 3px 0 2px 4px; padding-left: 8px; border-left: 2px solid var(--border); }
.chat-thinking { align-self: flex-start; color: var(--muted); font-size: 12px; padding: 2px 6px; font-style: italic; }
.chat-thinking .chat-elapsed { font-style: normal; font-family: var(--mono); opacity: .8; }
/* the health probe failed repeatedly — the server looks unresponsive */
.chat-thinking.lost { color: var(--danger); font-style: normal; }
/* a graceful stop was requested */
.chat-thinking.stopping { color: var(--danger); font-style: normal; }

/* saved-conversation history (clock icon) — the list reuses the .chat-msgs area.
   ("New chat" is now a toolbar icon, #chatNewBtn, next to the history icon.) */
.chat-hitem {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--ink); font: inherit; font-size: 12px; cursor: pointer;
}
.chat-hitem:hover { background: var(--sel); }
.chat-hitem.active { background: var(--accent-soft); }
.chat-hitem-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-hitem-time { flex: none; color: var(--muted); font-size: 11px; }
/* while browsing history, hide the composer + chips */
#chatCol.chat-history .chat-input,
#chatCol.chat-history .chat-chips { display: none; }
.chat-chips { flex: none; display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
/* composer: ONE white box (like a Send dialog) — the message textarea on top, a bottom
   row of controls (attach · model picker · send) inside the same box. Initial state is
   3 lines: 2 empty text lines + the controls row. */
.chat-input { flex: none; padding: 0 12px 12px; }
/* the composer is ONE rounded white card: an auto-growing message textarea on top, and a
   bottom row of controls (attach · model · send) — ALL inside this card. Adding a line
   grows the card upward; removing a line shrinks it (autoGrowTA in chat.js). */
.chat-box {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 8px;
  border: 1px solid var(--faint); border-radius: 18px;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.chat-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-box textarea {
  width: 100%; box-sizing: border-box; resize: none; overflow-y: hidden;
  min-height: 46px; max-height: 200px;             /* 2 lines min; auto-grows up to ~8 */
  font: inherit; font-size: 14px; line-height: 1.5; padding: 1px 4px;
  border: none; outline: none; background: none; color: var(--ink);
}
/* attachment chip (a text file passed to the agent as context), above the textarea */
.chat-attached { display: none; flex-wrap: wrap; gap: 5px; padding: 1px 2px 3px; }
.chat-att-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  padding: 2px 4px 2px 7px; font-size: 11.5px; color: var(--ink);
  background: var(--surface2); border: 1px solid var(--border-strong); border-radius: 8px;
}
.chat-att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-att-x {
  flex: none; border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 15px; line-height: 1; padding: 0 2px;
}
.chat-att-x:hover { color: var(--ink); }
/* the attached-file marker shown under a user message */
.chat-msg-att { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px;
  font-size: 11px; color: var(--muted); }
/* bottom control row, inside the white card */
.chat-controls { display: flex; gap: 4px; align-items: center; }
.chat-spacer { flex: 1 1 auto; }
/* minimalist ghost icon button (attach) — dark enough to read on the white card */
.chat-icon-btn {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border: none; border-radius: 9px; background: none; color: var(--ink); cursor: pointer;
}
.chat-icon-btn:hover:not(:disabled) { background: var(--sel); }
.chat-icon-btn:disabled { opacity: .55; cursor: default; }
/* send — minimalist filled accent button (Feather up-arrow) */
.chat-send {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border: none; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer;
}
.chat-send:hover { filter: brightness(1.06); }
.chat-send:disabled { opacity: .45; cursor: default; }
/* it's the agent's move — the button stops the turn (red); a second press force-stops */
.chat-send.stop { background: var(--danger); }
.chat-send.stop.stopping { animation: chat-stop-pulse 1s ease-in-out infinite; }
@keyframes chat-stop-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
/* total agent time in this conversation */
.chat-total { font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
/* model picker reuses the app dropdown (.dd, like the printer picker), but as a clean
   GHOST control so it reads as part of the white card (no box-in-a-box); locked
   (pinned to the harness) once the conversation has turns */
#chatModelDD .dd-btn {
  border-color: transparent; background: none; color: var(--ink);
  padding: 4px 7px; font-size: 12px; border-radius: 8px;
}
#chatModelDD .dd-btn:hover { background: var(--sel); border-color: transparent; }
#chatModelDD .dd-arr { color: var(--muted); }
#chatModelDD.locked { pointer-events: none; opacity: .7; }
