.chat-main {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: 100vh;
  max-width: 100%;
}
.chat-header {
  padding: 1.2em 2em;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}
.chat-header h1 {
  margin: 0;
  font-size: 1.4em;
  color: #2c3e50;
  border: 0;
  padding: 0;
}
.chat-header p {
  margin: 0.3em 0 0 0;
  font-size: 0.88em;
  color: #718096;
}
.chat-warn {
  background: #fff8d6;
  border-bottom: 1px solid #f0d96b;
  padding: 0.7em 2em;
  font-size: 0.9em;
  color: #744210;
}
.chat-warn code {
  background: #fde68a;
  padding: 0.05em 0.4em;
  border-radius: 3px;
  font-family: "DejaVu Sans Mono", "Menlo", monospace;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5em 2em;
  display: flex;
  flex-direction: column;
  gap: 1em;
}
.chat-welcome {
  color: #4a5568;
  font-size: 0.95em;
  max-width: 38em;
  margin: 2.5em auto;
  text-align: center;
}
.chat-welcome h2 { margin: 0 0 0.5em 0; color: #2c3e50; font-size: 1.2em; }
.chat-welcome ul {
  text-align: left;
  margin: 1em auto;
  max-width: 26em;
  color: #4a5568;
  padding-left: 1.2em;
}
.chat-welcome li { margin: 0.3em 0; }

.chat-msg { display: flex; gap: 0.8em; max-width: 60em; }
.chat-msg .avatar {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78em;
  font-weight: 600;
}
.chat-msg.user .avatar { background: #3498db; color: white; }
.chat-msg.assistant .avatar { background: #edf2f7; color: #2c3e50; }
.chat-msg .body { flex: 1; min-width: 0; }
.chat-msg .body p:first-child { margin-top: 0; }
.chat-msg .body p:last-child { margin-bottom: 0; }
.chat-msg .body pre {
  background: #f5f6f8;
  padding: 0.6em 0.9em;
  border-radius: 6px;
  overflow-x: auto;
  font-family: "DejaVu Sans Mono", "Menlo", monospace;
  font-size: 0.85em;
}
.chat-msg .body code {
  background: #f1f3f5;
  padding: 0.05em 0.3em;
  border-radius: 3px;
  font-size: 0.9em;
}
.chat-msg .body pre code { background: transparent; padding: 0; }

.tool-event {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  padding: 0.25em 0.7em;
  border-radius: 999px;
  font-size: 0.82em;
  color: #4a5568;
  margin: 0.25em 0.4em 0.25em 0;
}
.tool-event .name { font-weight: 600; color: #2c5282; }
.tool-event.done { background: #f0fff4; border-color: #c6f6d5; color: #276749; }
.tool-event.done .name { color: #276749; }

.chat-error {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  color: #9b2c2c;
  padding: 0.7em 1em;
  border-radius: 6px;
  font-size: 0.9em;
  white-space: pre-wrap;
  margin: 0.5em 0;
}

.pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin: 0.6em 0;
  padding: 0.6em 0.9em;
  background: #f7fafc;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  text-decoration: none;
  color: #2c3e50;
  transition: background 0.15s, border-color 0.15s;
}
.pdf-download:hover { background: #ebf4ff; border-color: #3498db; }
.pdf-download .pdf-icon { font-size: 1.5em; line-height: 1; }
.pdf-download .pdf-label { display: flex; flex-direction: column; font-weight: 600; }
.pdf-download .pdf-sub { font-weight: 400; font-size: 0.8em; color: #718096; }

.chat-input-form {
  border-top: 1px solid #e2e8f0;
  padding: 1em 2em;
  background: #fff;
  display: flex;
  gap: 0.7em;
  align-items: flex-end;
}
.chat-input-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  padding: 0.6em 0.8em;
  font: inherit;
  font-size: 0.95em;
  line-height: 1.4;
  min-height: 2.4em;
  max-height: 12em;
  font-family: inherit;
  background: #fff;
}
.chat-input-form textarea:focus { outline: none; border-color: #3498db; }
.chat-input-form button {
  padding: 0.6em 1.2em;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-end;
  height: 2.4em;
}
.chat-input-form button:hover:not(:disabled) { background: #2c80b8; }
.chat-input-form button:disabled { opacity: 0.5; cursor: not-allowed; }
