
/* ══════════════════════════════════════════════════════════════════
   4 · CONVERSATION  (chat = calm transcript, not a messaging app)
   Assistant speaks as borderless typography with a soft accent marker.
   Only the user gets a minimal tinted pill, to mark the voice.
   ══════════════════════════════════════════════════════════════════ */
.ai-chat {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 22px 6px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.10) transparent;
  min-height: 0;
}
/* With nothing to answer, media.js hides the log and the composer behind the
   tile's own card; their display:flex would otherwise win over [hidden]. */
.ai-chat[hidden],
.ai-input-row[hidden] { display: none; }
.ai-chat::-webkit-scrollbar { width: 3px; }
.ai-chat::-webkit-scrollbar-track { background: transparent; }
.ai-chat::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); border-radius: 2px; }

.ai-msg {
  display: flex;
  max-width: 92%;
  animation: xn-msg-in .22s ease;
}
.ai-msg-user      { align-self: flex-end; max-width: 80%; }
.ai-msg-assistant { align-self: flex-start; max-width: 94%; gap: 10px; }

/* Bit beside its words: a still pose in the mood of the reply (ai-bit-chat.js). */
.ai-msg-bit { flex: none; width: 18px; margin-top: 3px; }
.ai-msg-bit svg { display: block; width: 18px; height: auto; }

.ai-msg-bubble {
  font-size: 14px;
  line-height: 1.62;
  color: rgba(255,255,255,.90);
  word-break: break-word;
  white-space: pre-wrap;
  /* Chat replies must be selectable/copyable — the body sets user-select:none
     globally for the touch UI, so re-enable it here for the message text. */
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* Per-message copy button — sits beside the bubble, quiet until the message is
   hovered/focused (and faintly visible on touch, which has no hover). */
.ai-msg-copy {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 2px;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  opacity: 0;
  transition: opacity .16s ease, background .16s ease, color .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.ai-msg-copy svg { width: 15px; height: 15px; }
.ai-msg:hover .ai-msg-copy,
.ai-msg-copy:focus-visible { opacity: 1; }
.ai-msg-copy:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.9); }
.ai-msg-copy.is-copied { opacity: 1; color: rgba(var(--accent-rgb), 1); }
/* Touch (no hover): keep the button discoverable at rest. */
@media (hover: none) {
  .ai-msg-copy { opacity: .4; }
}

/* user — minimal tinted pill */
.ai-msg-user .ai-msg-bubble {
  padding: 9px 15px;
  border-radius: 16px 16px 5px 16px;
  background: rgba(var(--accent-rgb), .15);
  border: 1px solid rgba(var(--accent-rgb), .22);
  color: rgba(255,255,255,.94);
  font-size: 13.5px;
  line-height: 1.5;
}

/* assistant — pure typography, no box */
.ai-msg-assistant .ai-msg-bubble {
  padding: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,.88);
}

/* ── Status / thinking ───────────────────────────────────────────── */
.ai-status {
  min-height: 22px;
  padding: 2px 22px 4px;
  position: relative;
  z-index: 1;
  font-size: 11.5px;
  letter-spacing: .02em;
  color: rgba(255,255,255,.38);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.ai-thinking-dots { display: inline-flex; align-items: center; gap: 5px; }
.ai-thinking-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(var(--accent-rgb), .75);
  animation: xn-think-dot 1.2s ease-in-out infinite;
  will-change: transform, opacity;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: .18s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: .36s; }

/* A long turn: what it is doing and for how long (ai-turn-wait.js). */
.ai-wait { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 2px 0; flex: 1 1 auto; }
.ai-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.ai-step {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 13px; letter-spacing: 0; color: var(--muted-text);
  animation: ai-wait-in .32s cubic-bezier(.22, 1, .36, 1);
}
.ai-step.is-current { color: var(--text); }
.ai-step-icon { width: 14px; height: 14px; flex: none; }
.ai-step-icon svg { display: block; width: 14px; height: 14px; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-step.is-done .ai-step-icon svg { stroke: var(--color-success); }
.ai-step-track { stroke: var(--line); }
.ai-step-arc { stroke: var(--accent); transform-origin: 7px 7px; animation: ai-step-spin .9s linear infinite; }
.ai-step-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-step-time { margin-left: auto; flex: none; font-size: 12px; color: var(--muted-text); font-variant-numeric: tabular-nums; }
.ai-wait-hint { font-size: 11px; line-height: 1.35; opacity: .85; }
@keyframes ai-wait-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes ai-step-spin { to { transform: rotate(360deg); } }
/* An infinite loop joins the dashboard freezes (invariants-rendering-gpu). */
body.overlay-frozen .ai-step-arc, body.ambient-idle .ai-step-arc,
body.game-mode .ai-step-arc, body.low-power-gpu .ai-step-arc { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .ai-step, .ai-step-arc { animation: none; }
}

/* A quiet line under a reply ("Stopped"). */
.ai-note {
  align-self: flex-start;
  margin: -8px 0 0 28px;
  font-size: 12.5px;
  color: var(--muted-text);
}
