:root {
  --purple: #4b1f78;
  --purple-light: #f4eef9;
  --teal: #1a7e7a;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e6e6e6;
  --bg: #ffffff;
  --user-bg: #4b1f78;
  --user-fg: #ffffff;
  --bot-bg: #f4eef9;
  --bot-fg: #1a1a1a;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  background: var(--purple);
  color: #fff;
  font-size: 13px;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; letter-spacing: 0.02em; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #6dd3a0; box-shadow: 0 0 6px rgba(109,211,160,0.7);
}
.ctx { font-size: 11px; opacity: 0.85; letter-spacing: 0.05em; text-transform: uppercase; }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 0.9rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.msg {
  max-width: 86%;
  padding: 0.55rem 0.8rem;
  border-radius: 12px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.bot { background: var(--bot-bg); color: var(--bot-fg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--user-bg); color: var(--user-fg); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.error { background: #fdecea; color: #8a1c12; align-self: flex-start; }
.msg p { margin: 0 0 0.5rem; }
.msg p:last-child { margin-bottom: 0; }
.msg .typing::after {
  content: "▍";
  animation: blink 1s infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--line);
  background: #fff;
}
textarea {
  flex: 1;
  resize: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  max-height: 120px;
}
textarea:focus { border-color: var(--purple); }
button {
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 0.95rem;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:hover:not(:disabled) { filter: brightness(1.08); }
