:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eef2ff;
  --user-bg: #2563eb;
  --user-text: #ffffff;
  --error: #b91c1c;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg);
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  font-weight: 700;
}
.brand span {
  color: var(--accent);
  font-weight: 600;
}
.brand .tagline {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
  margin-top: 2px;
}

.stage-indicator {
  font-size: 13px;
  color: var(--muted);
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: var(--radius);
  white-space: normal;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bg);
  color: var(--user-text);
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.assistant h1,
.msg.assistant h2 {
  font-size: 1.02em;
  margin: 0.6em 0 0.3em;
}
.msg.assistant p {
  margin: 0.5em 0;
}
.msg.assistant ul,
.msg.assistant ol {
  margin: 0.4em 0;
  padding-left: 1.3em;
}
.msg.assistant code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.9em;
}
.msg.assistant pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12.5px;
}

.system-line {
  align-self: center;
  color: var(--muted);
  font-size: 12.5px;
  font-style: italic;
}

.stage-divider {
  align-self: center;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: center;
  padding-top: 10px;
  margin-top: 2px;
}

.error-line {
  align-self: center;
  color: var(--error);
  font-size: 13px;
}

.typing {
  align-self: flex-start;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

#input {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  color: var(--text);
  outline: none;
}
#input:focus {
  border-color: var(--accent);
}

#send {
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
#send:disabled {
  opacity: 0.5;
  cursor: default;
}
