:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --line: #d7dde2;
  --text: #182026;
  --muted: #5f6b75;
  --accent: #1f7a68;
  --accent-dark: #155b4e;
  --user: #e6f3ef;
  --assistant: #ffffff;
  --danger: #8b2f2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
}

.chat-shell {
  min-height: 100%;
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  padding: 16px;
  gap: 12px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.messages {
  min-height: 320px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.message {
  width: min(76%, 680px);
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.message.user {
  margin-left: auto;
  background: var(--user);
}

.message.assistant {
  margin-right: auto;
  background: var(--assistant);
}

.status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 48px;
  max-height: 180px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: transparent;
  color: var(--accent);
}

button.secondary:hover {
  background: #e6f3ef;
}

.new-dialog {
  justify-self: start;
}

@media (max-width: 640px) {
  .chat-shell {
    padding: 10px;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .message {
    width: 100%;
  }
}
