:root {
  color-scheme: dark;
  --bg: #11100f;
  --panel: #1c1a18;
  --panel-soft: #25221f;
  --text: #f3eee7;
  --muted: #a69b8f;
  --line: #3a332d;
  --accent: #6ee7b7;
  --user: #2d3a45;
  --bot: #24201d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: min(860px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 12px;
  padding: 18px;
}

.topbar,
.composer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

textarea,
button {
  font: inherit;
}

textarea {
  width: 100%;
  min-height: 48px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 10px;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:disabled,
textarea:disabled {
  opacity: 0.65;
  cursor: wait;
}

.messages {
  min-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 2px;
}

.message {
  max-width: min(72ch, 88%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  word-break: break-word;
}

.message.user {
  align-self: flex-end;
  background: var(--user);
}

.message.assistant {
  align-self: flex-start;
  background: var(--bot);
}

.role {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  font-size: 16px;
}

.emote-img {
  height: 1.65em;
  max-width: 7em;
  vertical-align: -0.38em;
  margin: 0 0.08em;
  object-fit: contain;
}

.emote-chip {
  display: inline-block;
  padding: 0 0.28em;
  margin: 0 0.04em;
  border: 1px solid #57483c;
  border-radius: 5px;
  background: #302820;
  color: #ffd28a;
  font-weight: 700;
  font-size: 0.95em;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}

.status {
  min-height: 20px;
  margin: 0;
  padding: 0 2px;
}

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

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

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