:root {
  --bg: #f4f3ee;          /* warm cream page background */
  --card: #ffffff;
  --text: #262624;        /* warm near-black */
  --muted: #7d7c75;
  --placeholder: #9c9b94;
  --accent: #d97757;      /* clay / terracotta */
  --accent-soft: #f3e3da;
  --red: #e3000f;         /* H&M red — send button + caret */
  --border: rgba(20, 18, 14, 0.10);
  --border-soft: rgba(20, 18, 14, 0.06);
  --column: 760px;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(244, 243, 238, 0.85);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-inner {
  max-width: var(--column);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}
.brand-logo {
  display: block;
  height: 18px;
  width: auto;
}
.new-chat-btn {
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
.new-chat-btn:hover { background: #fbfaf7; }

/* Empty state hides the chrome for a clean centered greeting */
body.empty .topbar { display: none; }

/* ===== Layout ===== */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body.empty .layout { justify-content: center; padding-bottom: 6vh; }

/* ===== Hero (empty state) ===== */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 0 24px 30px;
}
.hero-sse {
  height: 96px;
  width: auto;
}
.hero-row {
  display: flex;
  align-items: center;
  gap: 16px;
}
.hero-hm {
  height: 38px;
  width: auto;
}
.hero-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(30px, 5vw, 46px);
  letter-spacing: -0.01em;
  margin: 0;
  white-space: nowrap;
}
/* Blinking caret for the typewriter animation */
.hero-title.caret::after {
  content: "";
  display: inline-block;
  width: 3px;
  height: 0.92em;
  margin-left: 6px;
  vertical-align: -0.08em;
  background: var(--red);
  animation: caret 1.05s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
body.chatting .hero { display: none; }

/* ===== Messages (chat state) ===== */
.messages { display: none; }
body.chatting .messages {
  display: block;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-top: 8px;
}
.msg-inner {
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
}
.msg-body { min-width: 0; }
.msg-body > *:first-child { margin-top: 0; }
.msg-body > *:last-child { margin-bottom: 0; }

/* User: right-aligned grey bubble, sans-serif */
.msg.user { margin-top: 30px; }
.msg.user .msg-inner { justify-content: flex-end; }
.msg.user .msg-body {
  background: #e9e7e0;
  border-radius: 16px;
  padding: 11px 18px;
  max-width: 80%;
  white-space: pre-wrap;
}

/* Assistant: full-width, serif, no bubble (Claude-style) */
.msg.assistant { margin-top: 10px; margin-bottom: 18px; }
.msg.assistant .msg-body {
  width: 100%;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.7;
}

/* Shimmering "Team Charlie is thinking" indicator (adapted from the
   shining-text component — gradient clipped to the text, swept across) */
.shining-text {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  background: linear-gradient(110deg, #c4c2bb 35%, #3d3c39 50%, #c4c2bb 65%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  animation: shine 2s linear infinite;
}
@keyframes shine {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Streaming cursor */
.cursor {
  display: inline-block;
  animation: blink 1s steps(2, start) infinite;
  color: var(--accent);
}
@keyframes blink { to { visibility: hidden; } }

/* Markdown */
.msg-body p { margin: 0 0 0.75em; }
.msg-body ul, .msg-body ol { margin: 0 0 0.75em; padding-left: 1.4em; }
.msg-body li { margin: 0.2em 0; }
.msg-body h1, .msg-body h2, .msg-body h3 { line-height: 1.3; margin: 1em 0 0.5em; }
.msg-body a { color: #2563eb; text-decoration: none; }
.msg-body a:hover { text-decoration: underline; }
.msg-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #efeee8;
  padding: 0.15em 0.35em;
  border-radius: 4px;
}
.msg-body pre {
  background: #f0efe8;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
}
.msg-body pre code { background: none; padding: 0; font-size: 0.875em; }
.msg-body blockquote {
  margin: 0 0 0.75em;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

/* ===== Composer ===== */
.composer-region { padding: 8px 16px 14px; }
body.chatting .composer-region {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 72%, rgba(244, 243, 238, 0));
}

.composer-card {
  position: relative;
  max-width: var(--column);
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 1px 2px rgba(20, 18, 14, 0.03), 0 14px 30px rgba(20, 18, 14, 0.05);
  padding: 6px;
}
.composer-card:focus-within { border-color: rgba(20, 18, 14, 0.18); }

.status-dot {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #57b87f;
}

.composer-input {
  display: block;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font: inherit;
  line-height: 1.5;
  max-height: 200px;
  background: transparent;
  color: var(--text);
  padding: 14px 38px 6px 16px;
}
.composer-input::placeholder { color: var(--placeholder); }

.composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 4px 6px;
}
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #57564f;
  cursor: pointer;
}
.icon-btn:hover { background: #f1efe9; }

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.send-btn:not(:disabled):hover { background: #c40010; }
.send-btn:disabled {
  background: #e2e0d8;
  color: #b4b2aa;
  cursor: not-allowed;
}

/* ===== Suggestion chips ===== */
.chips {
  max-width: var(--column);
  margin: 16px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
body.chatting .chips { display: none; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}
.chip:hover { background: #fbfaf7; border-color: rgba(20, 18, 14, 0.16); }
.chip svg { color: var(--muted); flex: 0 0 auto; }

.composer-hint {
  max-width: var(--column);
  margin: 14px auto 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 600px) {
  .chips { gap: 8px; }
  .chip span { display: none; } /* icons-only on small screens */
  .composer-hint { font-size: 11px; }
}
