/* The chat transcript: how one turn is drawn, wherever a conversation with a
   model is shown — Joinery AI's chat and the Help panel's support threads
   (includes/ChatTranscript.php, assets/js/chat_transcript.js). A page that
   shows a transcript loads it (ChatTranscript::assets()); no other page does.
   Selectors keep the joai-chat-* names the transcript has always carried. */
/* A reply a person on the support desk wrote, rather than the model. */
.joai-chat-person-mark { display: inline-block; margin-bottom: 0.3rem; font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.02em; color: #1d63d1; }
.joai-chat-msg { font-size: 0.92rem; line-height: 1.65; }
/* Your messages stay a compact bubble so the turn boundary is obvious. */
.joai-chat-mine { align-self: flex-end; max-width: 80%; padding: 0.7rem 1rem;
                  border-radius: 10px; background: #0d6efd; color: #fff; }
.joai-chat-mine .joai-chat-time { color: rgba(255,255,255,0.8); }
/* Assistant replies render as a full-width document — no pill, no width cap —
   so headings and lists have room. A hairline rule separates turns instead. */
.joai-chat-assistant { align-self: stretch; max-width: 100%; color: #222;
                       padding: 0.5rem 0.25rem 1.1rem; border-bottom: 1px solid #f0f0f0; }
/* Live turn-activity line under a streaming bubble ("Waiting for glm-5p2...
   - 2m 40s") - what the runner is doing before/while text arrives. */
.joai-chat-activity { margin-top: 0.3rem; font-size: 0.8rem; color: #888; }
/* A failed turn renders inline (never a popup): the assistant bubble becomes an
   error card carrying the server's message, with a Retry that replays the turn. */
.joai-chat-failed { padding: 0.7rem 0.9rem; background: #fdecea;
                    border: 1px solid #f5c6cb; border-radius: 8px; }
.joai-chat-failed .joai-chat-body { color: #b02a2a; }
.joai-chat-failed-actions { margin-top: 0.55rem; }
.joai-chat-retry { font: inherit; font-size: 0.82rem; font-weight: 600; color: #fff;
                   background: #dc3545; border: 0; border-radius: 5px;
                   padding: 0.35rem 0.8rem; cursor: pointer; }
.joai-chat-retry:hover { background: #c0392b; }
/* A cancelled turn keeps its partial answer under a small marker. */
.joai-chat-cancelled-marker { margin-top: 0.4rem; font-size: 0.78rem; font-weight: 600; color: #b26a00; }
/* Markdown typography inside a bubble/body. */
.joai-chat-body { word-wrap: break-word; overflow-wrap: anywhere; }
.joai-chat-body > :first-child { margin-top: 0; }
.joai-chat-body > :last-child { margin-bottom: 0; }
.joai-chat-body p { margin: 0 0 0.9rem; }
/* The markdown parser emits an empty <p> after a horizontal rule (--- followed
   by a blank line). Collapse those so section breaks don't leave dead space. */
.joai-chat-body p:empty { display: none; }
.joai-chat-body hr { border: 0; border-top: 1px solid #eee; margin: 1.2rem 0; }
/* Bold reads as emphasis, not shouting. */
.joai-chat-body strong { font-weight: 600; }
/* Headings sit barely above body size — section markers, not billboards. */
.joai-chat-body h1, .joai-chat-body h2, .joai-chat-body h3,
.joai-chat-body h4, .joai-chat-body h5, .joai-chat-body h6 {
    margin: 1.5rem 0 0.6rem; line-height: 1.4; font-weight: 600; }
.joai-chat-body h1 { font-size: 1.12rem; }
.joai-chat-body h2 { font-size: 1.05rem; }
.joai-chat-body h3 { font-size: 0.98rem; }
.joai-chat-body h4, .joai-chat-body h5, .joai-chat-body h6 { font-size: 0.92rem; }
/* The admin theme resets list-style globally (for nav menus); chat replies
   are documents, so restore real markers — quiet ones. */
.joai-chat-body ul, .joai-chat-body ol { margin: 0 0 0.9rem; padding-left: 1.6rem; }
.joai-chat-body ul { list-style: disc; }
.joai-chat-body ol { list-style: decimal; }
.joai-chat-body li { margin: 0.35rem 0; list-style: inherit; }
.joai-chat-body li::marker { color: #9aa1ab; }
.joai-chat-body li > ul { list-style: circle; }
.joai-chat-body li > ul, .joai-chat-body li > ol { margin: 0.3rem 0 0.4rem; }
.joai-chat-body code { background: rgba(0,0,0,0.06); padding: 0.1rem 0.3rem;
                       border-radius: 4px; font-size: 0.88em; }
.joai-chat-body pre { white-space: pre-wrap; background: rgba(0,0,0,0.05); padding: 0.75rem 0.85rem;
                      border-radius: 6px; overflow-x: auto; margin: 0 0 0.9rem; }
.joai-chat-body pre code { background: none; padding: 0; }
.joai-chat-body blockquote { margin: 0 0 0.9rem; padding: 0.1rem 0 0.1rem 0.9rem;
                             border-left: 3px solid #ddd; color: #555; }
.joai-chat-body table { border-collapse: collapse; margin: 1.4rem 0; font-size: 0.9em;
                        display: block; max-width: 100%; overflow-x: auto; }
.joai-chat-body th, .joai-chat-body td { border: 1px solid #ddd; padding: 0.4rem 0.65rem; text-align: left; }
.joai-chat-body th { font-weight: 600; }
/* The admin theme drops the last row's bottom border on .table (card-embedded
   data tables); chat tables draw a full grid, so put it back. */
.joai-chat-body table tbody tr:last-child td { border-bottom: 1px solid #ddd; }
/* Per-turn footer: one muted line — the tool trace (left), then time · context ·
   cost, with the hover-only Copy/Delete actions pushed to the right. */
.joai-chat-foot { display: flex; flex-wrap: wrap; align-items: baseline;
                  gap: 0.15rem 0.5rem; margin-top: 0.35rem; }
.joai-chat-meta-line { margin-left: auto; font-size: 0.72rem; color: #999; white-space: nowrap; }
.joai-chat-time { color: inherit; }
.joai-chat-usage-cost { color: #bbb; }
/* Context-size flag — a rough "how full is it getting" gauge (gray < 32k,
   amber 32–64k, red 64k+). */
.joai-ctx-ok   { color: #999; }
.joai-ctx-warn { color: #c77d0a; }
.joai-ctx-high { color: #c0392b; font-weight: 600; }
/* Per-turn actions (copy / delete) — reveal on hover or keyboard focus of a turn. */
.joai-chat-actions { display: flex; gap: 0.3rem; opacity: 0; transition: opacity 0.12s; }
.joai-chat-msg:hover .joai-chat-actions,
.joai-chat-msg:focus-within .joai-chat-actions { opacity: 1; }
.joai-chat-action { background: none; border: 0; padding: 0.1rem 0.4rem; font-size: 0.72rem;
                    color: #888; cursor: pointer; border-radius: 4px; line-height: 1.4; }
.joai-chat-action:hover { background: rgba(0,0,0,0.06); color: #222; }
.joai-chat-action-danger:hover { background: #fdecea; color: #c0392b; }
/* On the blue user bubble the meta + toolbar sit in light ink. */
.joai-chat-mine .joai-chat-meta-line { color: rgba(255,255,255,0.8); }
.joai-chat-mine .joai-chat-action { color: rgba(255,255,255,0.85); }
.joai-chat-mine .joai-chat-action:hover { background: rgba(255,255,255,0.2); color: #fff; }
.joai-chat-mine .joai-chat-action-danger:hover { background: rgba(255,255,255,0.25); color: #fff; }
/* Collapsed tool trace sits inline in the footer; opening it drops the list below. */
.joai-chat-trace { font-size: 0.72rem; color: #666; }
.joai-chat-trace summary { cursor: pointer; }
.joai-chat-trace ul { margin: 0.3rem 0 0; padding-left: 1.1rem; flex-basis: 100%; }
.joai-chat-tool-error { color: #dc3545; }
