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

:root { color-scheme: light; }

:root {
  --red: #e32b2b;
  --red-light: #fdeaea;
  --bg: #f7f7f7;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text: #222222;
  --text-muted: #888888;
  --radius: 10px;
  --sidebar-w: 280px;
  --input-h: 56px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
}

/* ── Layout ─────────────────────────────────────────────────────── */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebar-header {
  margin-bottom: 28px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
}

.tagline {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 32px;
}

.starters {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.starters-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.starter {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
}

.starter:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
}

.sidebar-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.guides-link {
  font-size: 12px;
  color: var(--red);
  text-decoration: none;
}

.guides-link:hover { text-decoration: underline; }

/* ── Chat area ───────────────────────────────────────────────────── */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  scroll-behavior: smooth;
}

.welcome-message {
  max-width: 600px;
  margin: 60px auto 0;
  padding: 0 24px;
  text-align: center;
}

.welcome-message h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.welcome-message p {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Message bubbles ─────────────────────────────────────────────── */

.message {
  max-width: 720px;
  margin: 0 auto 20px;
  padding: 0 24px;
}

.message-user {
  display: flex;
  justify-content: flex-end;
}

.message-user .bubble {
  background: var(--red);
  color: white;
  border-radius: 16px 16px 4px 16px;
  padding: 10px 16px;
  max-width: 80%;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message-assistant .bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.6;
}

/* Markdown inside assistant bubble */
.bubble h1, .bubble h2, .bubble h3 {
  margin: 16px 0 8px;
  font-size: inherit;
  font-weight: 700;
}
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 0; }

.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 8px 0 10px 20px; }
.bubble li { margin-bottom: 4px; }
.bubble code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}
.bubble pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 10px 0;
}
.bubble pre code { border: none; padding: 0; background: none; }
.bubble a { color: var(--red); }
.bubble a:hover { text-decoration: none; }
.bubble strong { font-weight: 600; }

/* Sources block */
.sources {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sources-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.source-item::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--red);
  border-radius: 50%;
  flex-shrink: 0;
}

.source-item a {
  color: var(--red);
  text-decoration: none;
  line-height: 1.4;
}

.source-item a:hover { text-decoration: underline; }

.source-breadcrumb {
  color: var(--text-muted);
  font-size: 12px;
}

/* Loading state */
.message-loading .bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
}

.dots {
  display: flex;
  gap: 4px;
}

.dot {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Error */
.message-error .bubble {
  background: var(--red-light);
  border-color: #f5c2c2;
  color: var(--red);
}

/* ── Input area ──────────────────────────────────────────────────── */

.input-area {
  padding: 12px 24px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s;
  max-width: 720px;
  margin: 0 auto;
}

.input-wrapper:focus-within {
  border-color: var(--red);
}

#question {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 16px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  resize: none;
  min-height: 52px;
  max-height: 200px;
  line-height: 1.5;
}

#question::placeholder { color: var(--text-muted); }

#send-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin: 4px;
  background: var(--red);
  border: none;
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

#send-btn:hover { opacity: 0.85; }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .sidebar { display: none; }
  .message { padding: 0 12px; }
  .input-area { padding: 8px 12px 12px; }
}
