:root {
  --bg: #FAFAF8;
  --text: #1A1A1A;
  --muted: #6B6B66;
  --border: #E5E5E0;
  --bubble: #EFEFEA;
  --accent: #B5532F;
  --accent-text: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --text: #EDEDEA;
    --muted: #9A9A94;
    --border: #2C2C2A;
    --bubble: #232321;
    --accent: #D9704B;
    --accent-text: #141414;
  }
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  font-size: 16px;
}

.app {
  max-width: 720px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 16px;
}

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

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.empty {
  color: var(--muted);
  text-align: center;
  margin: auto;
}

.msg {
  max-width: 85%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--bubble);
  padding: 10px 14px;
  border-radius: 8px;
}

.msg.bot {
  align-self: flex-start;
}

.msg.error {
  color: var(--accent);
  font-size: 14px;
}

.dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

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

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 0 20px;
  border-top: 1px solid var(--border);
}

textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

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

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}

.btn-primary {
  padding: 0 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 500;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.btn-ghost:hover { background: var(--bubble); }

@media (max-width: 480px) {
  .msg { max-width: 92%; }
}

/* ===== Header title + subtitle ===== */
.title h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ===== Footer ===== */
.composer {
  padding-bottom: 12px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.footer a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.footer .dot {
  opacity: 0.6;
}