/* chat.css — chat column, message bubbles, MCP foldout */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 88%; display: flex; flex-direction: column; gap: 4px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }

.msg-thumb {
  max-width: 180px;
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.bubble {
  padding: 9px 13px;
  border-radius: 13px;
  line-height: 1.55;
  font-size: 13.5px;
  word-break: break-word;
}
.msg.user .bubble {
  white-space: pre-wrap;
  background: var(--accent);
  color: #fff;
  border-radius: 13px 13px 4px 13px;
}
.msg.assistant .bubble {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 13px 13px 13px 4px;
}
html[data-theme="dark"] .msg.assistant .bubble { background: #232831; }

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { margin: 10px 0 6px; line-height: 1.3; }
.bubble h1 { font-size: 16px; } .bubble h2 { font-size: 15px; }
.bubble h3 { font-size: 14px; } .bubble h4 { font-size: 13.5px; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 22px; }
.bubble li { margin: 2px 0; }
.bubble code {
  background: rgba(127, 127, 127, .18);
  border-radius: 4px; padding: 1px 5px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bubble pre {
  background: #1e293b; color: #e2e8f0; border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 6px 0 8px;
}
.bubble pre code { background: none; color: inherit; padding: 0; font-size: 12px; }
.bubble table { border-collapse: collapse; margin: 6px 0; font-size: 12.5px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 4px 9px; text-align: left; }
.bubble th { background: rgba(127, 127, 127, .12); font-weight: 600; }
.bubble blockquote { border-left: 3px solid var(--border); margin: 6px 0; padding: 2px 10px; opacity: .85; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.bubble a { color: var(--accent); }

.chat-error { color: #ef4444; font-weight: 600; }
.chat-empty { color: var(--dim); font-style: italic; }

.typing { display: inline-flex; gap: 3px; align-items: center; }
.typing span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  animation: typingDot 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typingDot { 0%,100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

/* ── Input ──────────────────────────────────────────────────────── */
.input-area {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--surface);
}
.input-area textarea {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 9px 12px;
  font: 13.5px -apple-system, sans-serif;
  resize: none;
  min-height: 42px;
  max-height: 140px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.input-area textarea:focus { border-color: var(--accent); }
.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; border: none;
  width: 42px; height: 42px; border-radius: 11px;
  cursor: pointer; font-size: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.send-btn:hover { opacity: .9; }
.send-btn:disabled { background: var(--dim); cursor: not-allowed; }
.hint { font-size: 10px; color: var(--dim); text-align: center; padding: 4px 0 8px; }

/* ── MCP foldout ────────────────────────────────────────────────── */
.mcp-foldout {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
}
.mcp-foldout > summary {
  cursor: pointer;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  list-style: none;
}
.mcp-foldout > summary::-webkit-details-marker { display: none; }
.mcp-summary { font-weight: 400; color: var(--dim); font-size: 11.5px; }
.mcp-refresh-btn { margin-left: auto; }

.mcp-banner {
  background: #b91c1c; color: #fff;
  padding: 6px 12px; font-size: 11.5px;
}
.mcp-rows {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
}
.mcp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
}
.mcp-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--dim); }
.mcp-dot.ok { background: #22c55e; }
.mcp-dot.degraded { background: #f59e0b; }
.mcp-dot.failed { background: #ef4444; }
.mcp-dot.missing { background: #9ca3af; }
.mcp-name { font-weight: 600; }
.mcp-detail { color: var(--dim); font-size: 11.5px; flex: 1; min-width: 0; }
.mcp-time { color: var(--dim); font-size: 10.5px; }
