:root {
  --bg: #ffffff;
  --panel: #f7f8fa;
  --text: #1a1d24;
  --muted: #5b6373;
  --accent: #2563eb;
  --bot: #eef1f6;
  --user: #dde6fb;
  --border: #e4e7ec;
  --error-bg: #fdecec;
  --error-text: #8a1c1c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #161922;
    --text: #e7e9ee;
    --muted: #8a93a6;
    --accent: #4f8cff;
    --bot: #1f2433;
    --user: #2a3553;
    --border: #232838;
    --error-bg: #4a1f1f;
    --error-text: #f4c5c5;
  }
}

* { box-sizing: border-box; }

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

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  letter-spacing: -0.01em;
}

.tagline {
  margin: 0 0 8px;
  color: var(--muted);
}

.meta {
  margin: 0 0 24px;
  font-size: 14px;
}

.meta a {
  color: var(--accent);
  text-decoration: none;
}

.meta a:hover { text-decoration: underline; }

.chat {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  overflow-y: auto;
  max-height: 60vh;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg { display: flex; }
.msg--bot { justify-content: flex-start; }
.msg--user { justify-content: flex-end; }

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg--bot .bubble {
  background: var(--bot);
  border-top-left-radius: 4px;
}

.msg--user .bubble {
  background: var(--user);
  border-top-right-radius: 4px;
}

.bubble--error {
  background: var(--error-bg);
  color: var(--error-text);
}

.composer {
  display: flex;
  gap: 8px;
}

#input {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

#input:focus {
  outline: none;
  border-color: var(--accent);
}

#send {
  padding: 0 20px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

#send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status {
  margin: 6px 2px 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
}

.typing {
  display: inline-flex;
  gap: 4px;
}
.typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}
