:root {
  color-scheme: light;
  --ink: #202925;
  --muted: #68736e;
  --paper: #f1f5f1;
  --surface: #fffefa;
  --line: #d9ded7;
  --forest: #176b50;
  --forest-dark: #104b3a;
  --user-bubble: #e3f2e8;
  --assistant-bubble: #fbf0e4;
  --assistant-line: #f0e1d1;
  --sans: "Avenir Next", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
}

button,
textarea {
  font: inherit;
}

.chat-app {
  display: flex;
  width: min(900px, 100%);
  height: 100vh;
  height: 100dvh;
  min-height: 360px;
  flex-direction: column;
  margin: 0 auto;
  padding: 0 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  box-shadow: 0 0 36px rgb(32 55 41 / 5%);
}

.chat-header {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 34px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 2px;
  background: var(--forest);
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.chat-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.chat-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.conversation {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 28px 8px;
  scroll-behavior: smooth;
}

.message {
  max-width: min(82%, 660px);
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  animation: message-in 180ms ease-out both;
}

.message p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.message-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-message {
  align-self: flex-end;
  border-color: #d4e8d9;
  border-bottom-right-radius: 2px;
  background: var(--user-bubble);
}

.user-message .message-label {
  color: var(--forest-dark);
}

.assistant-message {
  align-self: flex-start;
  border-color: var(--assistant-line);
  border-bottom-left-radius: 2px;
  background: var(--assistant-bubble);
}

.typing-status {
  display: flex;
  align-items: center;
  gap: 7px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--forest);
  animation: typing 900ms ease-in-out infinite alternate;
}

.typing-dots span:nth-child(2) {
  animation-delay: 150ms;
}

.typing-dots span:nth-child(3) {
  animation-delay: 300ms;
}

@keyframes typing {
  to { opacity: 0.3; transform: translateY(-2px); }
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.handoff-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
  text-underline-offset: 3px;
}

.notice {
  padding: 0 8px;
  color: #8b4b35;
  font-size: 12px;
}

.notice:not(:empty) {
  padding-bottom: 10px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px;
  border: 1px solid #b9c5bc;
  border-radius: 4px;
  background: white;
}

.composer:focus-within {
  outline: 2px solid var(--forest);
  outline-offset: 2px;
}

.composer textarea {
  width: 100%;
  min-height: 40px;
  max-height: 120px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}

.composer textarea::placeholder {
  color: #7e8983;
}

.send-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: var(--forest);
  color: white;
  cursor: pointer;
}

.send-button:hover {
  background: var(--forest-dark);
}

.send-button:focus-visible {
  outline: 2px solid var(--forest-dark);
  outline-offset: 3px;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.send-button svg {
  width: 19px;
  height: 19px;
}

.privacy-note {
  margin: 12px 8px 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

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

@media (max-width: 600px) {
  .chat-app {
    padding-right: 16px;
    padding-left: 16px;
    border: 0;
  }

  .conversation {
    padding: 22px 2px;
  }

  .message {
    max-width: 92%;
  }
}
