:root {
  --bg: #f6f6f4;
  --ink: #1d1d1b;
  --muted: #6f6f6a;
  --line: #dcdcd6;
  --card: #ffffff;
  --accent: #1d1d1b;
  --accent-ink: #ffffff;
  --danger: #a3261f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  font-size: 14px;
  line-height: 1.55;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.who { display: flex; flex-direction: column; line-height: 1.2; }
.who span { color: var(--muted); font-size: 12px; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4a4a46, #111 70%);
  flex: none;
}
.avatar.small { width: 18px; height: 18px; }

.close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.log {
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.msg.user {
  align-self: flex-end;
  max-width: 80%;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 6px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.assistant { display: flex; gap: 10px; align-items: flex-start; }
.msg.assistant .avatar { margin-top: 3px; }
.msg.error .answer { color: var(--danger); }
.col { min-width: 0; flex: 1; }
.answer { overflow-wrap: anywhere; }
.answer p { margin: 0 0 10px; }
.answer p:last-child { margin-bottom: 0; }
.answer ul, .answer ol { margin: 0 0 10px; padding-left: 20px; }
.answer a { color: inherit; text-underline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.chips button:hover { border-color: var(--ink); }

.lead {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  display: grid;
  gap: 6px;
  max-width: 380px;
}
.lead-title { margin: 0 0 4px; font-weight: 600; }
.lead label { font-size: 12px; color: var(--muted); }
.lead input:not([type="checkbox"]) {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.lead .consent { display: flex; gap: 8px; align-items: flex-start; margin-top: 4px; }
.lead button {
  margin-top: 6px;
  justify-self: start;
  font: inherit;
  padding: 6px 16px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.lead button:disabled { opacity: 0.5; }
.lead-error { margin: 0; color: var(--danger); font-size: 12px; }
.lead-error:empty { display: none; }
.lead-done { margin: 12px 0 0; color: var(--muted); }

.composer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto;
  width: calc(100% - 32px);
  max-width: 608px;
  padding: 6px 6px 6px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.composer input { flex: 1; min-width: 0; border: 0; outline: 0; font: inherit; background: transparent; }
.composer button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
.composer button:disabled { opacity: 0.35; cursor: default; }
.composer:focus-within { border-color: var(--ink); }

.notice { margin: 8px 16px 12px; text-align: center; font-size: 11px; color: var(--muted); }
.notice a { color: inherit; }

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .typing i { animation: none; opacity: 0.6; }
}
