/* Customer assistant chat (portal) + staff transcript. Tokens come from base.css. */
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
[hidden]{display:none!important}

.chat-page{max-width:860px;margin:0 auto;display:flex;flex-direction:column;gap:12px}
.chat-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap}
.chat-head h1{margin-bottom:2px}.chat-head p{margin:0}
.chat-banner{padding:10px 14px;border-radius:8px;border:1px solid #b2ddff;background:var(--info-bg);color:#194185;font-size:14px}
.chat-banner-human{border-color:#abefc6;background:var(--ok-bg);color:#054f31}
.chat-banner-closed{border-color:var(--line);background:#f2f4f7;color:var(--muted)}
.chat-older{margin:0;text-align:center}

/* log */
.chat-log{list-style:none;margin:0;padding:16px;display:flex;flex-direction:column;gap:12px;background:var(--card);border:1px solid var(--line);
  border-radius:var(--radius);min-height:280px;max-height:calc(100vh - 360px);overflow-y:auto;scroll-behavior:smooth}
.chat-log:focus-visible{outline:3px solid var(--focus);outline-offset:2px}
@media (prefers-reduced-motion:reduce){.chat-log{scroll-behavior:auto}}
.chat-empty{color:var(--muted);text-align:center;padding:40px 16px}
.chat-msg{max-width:min(620px,88%);padding:10px 14px;border-radius:14px;background:#f2f4f7;align-self:flex-start;word-wrap:break-word;overflow-wrap:anywhere}
.chat-msg-customer{align-self:flex-end;background:var(--brand);color:#fff;border-bottom-right-radius:4px}
.chat-msg-customer a,.chat-msg-customer .chat-meta,.chat-msg-customer .chat-ref{color:#e0eaff}
.chat-msg-assistant{border-bottom-left-radius:4px}
.chat-msg-staff{background:var(--ok-bg);border:1px solid #abefc6;border-bottom-left-radius:4px}
.chat-msg-system{align-self:center;background:none;color:var(--muted);font-size:13px;text-align:center;padding:2px 8px;max-width:90%}
.chat-msg-pending{opacity:.65}
.chat-meta{font-size:12px;color:var(--muted);margin-bottom:2px;display:flex;gap:6px;align-items:baseline;flex-wrap:wrap}
.chat-author{font-weight:600}
.chat-ref{font-weight:600;font-size:12px;padding:0 6px;border-radius:999px;background:rgba(33,86,217,.1)}
.chat-body{white-space:pre-wrap}
.chat-msg a{text-decoration:underline}

/* confirm cards */
.chat-card{margin-top:8px;padding:12px 14px;border:1px solid #9fb9bd;border-radius:10px;background:#fff;color:var(--ink)}
.chat-card[data-status="proposed"]{box-shadow:0 2px 10px rgba(33,86,217,.08)}
.chat-card:not([data-status="proposed"]){border-color:var(--line);background:#fcfcfd}
.chat-card-summary{margin:0 0 8px;font-weight:600;white-space:pre-wrap}
.chat-card-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.chat-card-actions form{margin:0}
.chat-card-final{margin:0}
.chat-card-note{margin:6px 0 0;color:var(--muted)}.chat-card-note:empty{display:none}
.chat-card.busy{opacity:.7}
.chat-card button[disabled]{opacity:.55;cursor:wait}

/* typing indicator */
.chat-typing{font-size:13px;color:var(--muted);display:flex;align-items:center;gap:8px;padding:0 4px}
.chat-typing .dots{display:inline-flex;gap:3px}
.chat-typing .dots i{width:6px;height:6px;border-radius:50%;background:#98a2b3;animation:chat-blink 1.2s infinite ease-in-out}
.chat-typing .dots i:nth-child(2){animation-delay:.2s}.chat-typing .dots i:nth-child(3){animation-delay:.4s}
@keyframes chat-blink{0%,80%,100%{opacity:.25}40%{opacity:1}}
@media (prefers-reduced-motion:reduce){.chat-typing .dots i{animation:none;opacity:.6}}

/* composer */
.chat-composer{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:12px;position:sticky;bottom:12px;box-shadow:0 -4px 16px rgba(16,24,40,.05)}
.chat-composer textarea{min-height:52px;max-height:240px;resize:vertical}
.chat-composer-row{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-top:8px}
.chat-composer button[disabled]{opacity:.6;cursor:wait}
.chat-context{margin-bottom:8px}
.chat-chip{display:inline-flex;align-items:center;gap:6px;padding:3px 6px 3px 12px;border-radius:999px;background:var(--info-bg);border:1px solid #b2ddff;font-size:13px}
.chat-chip-x{font-size:18px;line-height:1;padding:0 6px;color:var(--muted)}
.chat-error{margin:8px 0 0;color:var(--err);font-size:14px}

/* staff transcript */
.chat-log-staff{max-height:none;min-height:0;border:0;padding:0}
.chat-log-staff .chat-msg{max-width:92%}
.chat-trace{margin-top:6px;font-size:12px}
.chat-trace summary{cursor:pointer;color:var(--muted)}
.chat-trace pre{max-height:360px;overflow:auto;font-size:12px;margin:6px 0 0;background:#fff}
.chat-staff-reply label{margin-top:0}
.chat-staff-reply .row{margin-top:8px}
.thin-label{display:inline;margin:0 6px 0 0;font-weight:400}
.chat-staff-actions{margin-top:12px}
ul.plain{list-style:none;padding:0;margin:0}ul.plain li{padding:3px 0}
.chat-inbox td{vertical-align:middle}
