:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #15201d;
  --muted: #66756f;
  --line: #dce5e1;
  --accent: #1f6f5b;
  --accent-strong: #164f41;
  --warn: #a35a16;
  --danger: #9f2d34;
}

* {
  box-sizing: border-box;
}

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

button,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100vh;
  max-width: 760px;
  margin: 0 auto;
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
}

button:active {
  transform: translateY(1px);
}

.modebar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.mode.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
}

.message {
  max-width: 92%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-size: 15px;
}

.message.user {
  align-self: flex-end;
  background: #e5f3ed;
  border-color: #bee0d2;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
}

.message.status {
  align-self: center;
  max-width: 100%;
  color: var(--muted);
  background: #f7faf9;
  font-size: 13px;
}

.message.error {
  align-self: stretch;
  color: var(--danger);
  border-color: #efc7cb;
  background: #fff7f7;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
}

.composer button {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  min-width: 68px;
}

@media (max-width: 520px) {
  .shell {
    max-width: none;
  }

  .topbar {
    padding-top: max(18px, env(safe-area-inset-top));
  }
}
