* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --border: #e0d8d0;
  --text: #2c2826;
  --text-muted: #8a7f78;
  --accent: #8b5e3c;
  --accent-light: #f0e8df;
  --accent-hover: #7a5033;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.back-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--accent); }
.brand h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; margin-top: 2px; }
.brand p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.source-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.source-card strong { color: var(--text); }

.chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

.confidence-note {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  border: 1px solid #e0cfc0;
  border-radius: 6px;
  padding: 4px 8px;
}

.sources-toggle {
  font-size: 11px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.sources-list {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--accent-light);
  border-radius: 6px;
  padding: 6px 10px;
  display: none;
}
.sources-list.open { display: block; }
.sources-list div { padding: 2px 0; }

.composer {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding-top: 8px;
}
.composer input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: var(--surface);
}
.composer input:focus { outline: none; border-color: var(--accent); }
.composer button {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.composer button:hover { background: var(--accent-hover); }
.composer button:disabled { opacity: 0.5; cursor: not-allowed; }

.typing-dots { display: flex; gap: 4px; padding: 6px 0; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.suggestion-chip {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.suggestion-chip:hover { border-color: var(--accent); color: var(--accent); }

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

#captcha-box {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(44, 40, 38, 0.45);
  padding: 16px;
  z-index: 50;
}
#captcha-box[hidden] { display: none; }
#captcha-box .captcha-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  max-width: 340px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
#captcha-box p { font-size: 13px; color: var(--text-muted); }
#captcha-box button.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
}
