:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b1f27;
  --text-dim: #5c6470;
  --accent: #1a5fb4;
  --accent-text: #ffffff;
  --border: #e2e5ea;
  --danger: #c01c28;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #1a2130;
    --text: #e8ebf0;
    --text-dim: #94a0b0;
    --accent: #62a0ea;
    --accent-text: #0f1420;
    --border: #2a3345;
    --danger: #f66151;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.topbar h1 { margin: 0; font-size: 1.3rem; }

.ghost-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

#chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  scroll-behavior: smooth;
}

.intro { color: var(--text-dim); margin-top: 8vh; text-align: center; }

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  align-items: center;
}

.suggestion {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  max-width: 100%;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  box-shadow: var(--shadow);
}

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

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

.msg.bot.error { border-color: var(--danger); color: var(--danger); }

.msg.bot code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.88em;
}

.tool-note {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 0 6px;
}

.typing {
  align-self: flex-start;
  color: var(--text-dim);
  padding: 10px 14px;
  letter-spacing: 3px;
}

.typing::after {
  content: "•••";
  animation: blink 1.2s infinite;
}

@keyframes blink { 50% { opacity: 0.3; } }

.composer {
  display: flex;
  gap: 10px;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg);
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

.composer input {
  flex: 1;
  padding: 12px 16px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.composer input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.composer button {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 1.1rem;
  cursor: pointer;
}

.composer button:disabled { opacity: 0.5; cursor: default; }
