.chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 26px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

@media (max-height: 820px) {
  .messages { padding: 16px 24px; gap: 16px; }
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ── Messages ─────────────────────────────────────────────────────────────
   The assistant's answers are long and cited; a bubble around them just adds
   a box to read inside a box. They run as text on the page, with the avatar
   as the only marker. The user's own line stays a bubble — short, and it
   needs to be told apart at a glance. */

.msg { display: flex; gap: 12px; max-width: 820px; }
.msg.user { justify-content: flex-end; margin-left: auto; }
.msg.assistant { margin-right: auto; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-2);
}
.msg-avatar svg { width: 15px; height: 15px; }
.msg.user .msg-avatar { display: none; }

.msg-content { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.msg.assistant .msg-content { flex: 1; }
.msg.user .msg-content { align-items: flex-end; max-width: 560px; }

.msg-bubble { word-break: break-word; }

.msg.assistant .msg-bubble {
  font-size: 14px;
  line-height: 1.75;
  color: #D6DAE8;
  text-wrap: pretty;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: var(--bg);
  border-radius: 16px 16px 5px 16px;
  padding: 11px 15px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.6;
}

.msg-bubble p { margin-bottom: 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg.assistant .msg-bubble strong { color: var(--text); font-weight: 700; }
.msg-bubble code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.msg-meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-4);
}

/* ── Citations ───────────────────────────────────────────────────────────── */

.citations { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.citation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(124,131,255,.09);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--accent-2);
  cursor: default;
  transition: border-color .15s, color .15s;
}
.citation-chip svg { width: 11px; height: 11px; flex-shrink: 0; }
.citation-chip:hover { border-color: rgba(124,131,255,.55); color: #C0C4FF; }

/* ── Streaming cursor ────────────────────────────────────────────────────── */

.cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: var(--accent);
  border-radius: 1px;
  animation: blink .9s step-end infinite;
  vertical-align: middle;
  margin-left: 3px;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Thinking ────────────────────────────────────────────────────────────── */

.thinking { display: flex; align-items: center; gap: 10px; }
.thinking-dots { display: flex; gap: 4px; }
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-4);
  animation: bounce .9s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .15s; }
.thinking-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
.thinking-text { font-size: 12.5px; color: var(--text-4); }

/* ── Input ───────────────────────────────────────────────────────────────── */

.input-area {
  border-top: 1px solid var(--line);
  padding: 14px 32px 16px;
  background: var(--bg-2);
  flex-shrink: 0;
}
.input-area > * { max-width: 820px; margin-left: auto; margin-right: auto; }

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 11px 11px 11px 16px;
  transition: border-color .15s, box-shadow .15s;
}

/* Locked: visibly inert. Ready: visibly invites typing. */
.input-wrapper:not(.ready) { opacity: .62; }
.input-wrapper.ready {
  border-color: rgba(124,131,255,.45);
  box-shadow: 0 0 0 3px rgba(124,131,255,.07);
}
.input-wrapper.ready:hover,
.input-wrapper:focus-within { border-color: var(--accent); }

/* Two pulses the moment the chat becomes usable, then it settles down */
.input-wrapper.pulse { animation: input-pulse 1.7s ease-out 2; }
@keyframes input-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(124,131,255,.4); }
  65%  { box-shadow: 0 0 0 9px rgba(124,131,255,0); }
  100% { box-shadow: 0 0 0 0 rgba(124,131,255,0); }
}

@media (prefers-reduced-motion: reduce) {
  .input-wrapper.pulse { animation: none; }
}

#chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.6;
  min-height: 22px;
  padding: 6px 0;
}
#chat-input::placeholder { color: var(--text-4); }

#send-btn {
  background: var(--accent);
  border: none;
  color: var(--bg);
  width: 36px;
  height: 36px;
  border-radius: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#send-btn:hover:not(:disabled) { background: var(--accent-2); }
#send-btn:active:not(:disabled) { transform: scale(.95); }
#send-btn:disabled { background: var(--border-strong); color: var(--text-4); cursor: not-allowed; }

.input-hint {
  font-size: 11.5px;
  color: var(--text-4);
  margin-top: 8px;
  text-align: center;
}
.input-hint p { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }

.hint-lock { display: inline-flex; color: var(--text-4); }
.hint-lock svg { width: 12px; height: 12px; }

.hint-ready-lead { color: var(--lime); font-weight: 600; }
.hint-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-2);
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.hint-link:hover:not(:disabled) { color: var(--text); }
.hint-link:disabled { opacity: .5; cursor: not-allowed; }

kbd {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

/* ── Banners ─────────────────────────────────────────────────────────────
   Never a status code: what happened, whose fault it is, what to do now. */

.banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  margin-bottom: 12px;
}
.banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.banner.warn {
  background: var(--elec-soft);
  border: 1px solid var(--elec-line);
  color: #E0C89A;
}
.banner.warn svg { color: var(--elec); }
.banner.error {
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: #E7B7B7;
}
.banner.error svg { color: var(--red); }
