:root {
  --accent: #2f6b4f;
  --accent-dark: #244f3b;
  --accent-soft: #e7efe9;
  --bg: #faf7f0;
  --surface: #ffffff;
  --ink: #1f2421;
  --muted: #6b7569;
  --line: #e8e3d8;
  --user-bubble: #2f6b4f;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(31,36,33,.05), 0 8px 24px rgba(31,36,33,.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 780px;
  margin: 0 auto;
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 400px at 50% -10%, #fff 0%, rgba(255,255,255,0) 70%);
}

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 20px;
  background: rgba(250,247,240,.85);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.paw {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.brand-text h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600; font-size: 1.28rem; margin: 0; letter-spacing: -.01em;
}
.tagline { margin: 2px 0 0; font-size: .82rem; color: var(--muted); max-width: 46ch; }
.demo-badge {
  flex: none;
  font-size: .68rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid #cfe0d5;
  padding: 5px 10px; border-radius: 999px;
}

/* ---- thread ---- */
.thread {
  flex: 1; min-width: 0; overflow-y: auto;
  padding: 24px 20px 8px;
  display: flex; flex-direction: column; gap: 22px;
  scroll-behavior: smooth;
}
.thread > * { min-width: 0; max-width: 100%; }
.welcome-card, .suggestions, .bubble { max-width: 100%; }

.welcome { margin: auto 0; }
.welcome-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 24px;
}
.intro { margin: 0 0 18px; font-size: 1.06rem; color: #2c332e; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font: inherit; font-size: .9rem; text-align: left; max-width: 100%;
  color: var(--accent-dark); background: var(--accent-soft);
  border: 1px solid #d3e2d8; border-radius: 18px;
  padding: 9px 14px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.chip:hover { background: #dceae1; transform: translateY(-1px); box-shadow: var(--shadow); }

/* ---- messages ---- */
.msg { display: flex; flex-direction: column; max-width: 100%; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: flex-start; }
.bubble {
  max-width: 86%;
  padding: 13px 16px; border-radius: 16px;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.user .bubble {
  background: var(--user-bubble); color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.assistant .bubble {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}
.bubble :first-child { margin-top: 0; } .bubble :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .6em; }
.bubble ul, .bubble ol { margin: .3em 0 .6em; padding-left: 1.25em; }
.bubble li { margin: .15em 0; }
.bubble strong { font-weight: 600; }
.bubble a { color: var(--accent-dark); }

.who { font-size: .72rem; color: var(--muted); margin: 0 4px 5px; font-weight: 500; }

/* typing dots */
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #b8c2bb;
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.25} 40%{opacity:1} }

/* ---- citations ---- */
.cites { margin-top: 12px; width: 100%; }
.cites-label {
  font-size: .74rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin: 0 2px 9px;
  display: flex; align-items: center; gap: 6px;
}
.cite-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.cite {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
  transition: transform .1s ease, box-shadow .15s ease;
}
.cite:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.cite-thumb { position: relative; aspect-ratio: 16/9; background: #e9e6dd; }
.cite-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cite-play {
  position: absolute; inset: 0; display: grid; place-items: center;
}
.cite-play span {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center;
  font-size: 14px; padding-left: 3px;
}
.cite-title {
  font-size: .8rem; font-weight: 500; line-height: 1.3;
  padding: 9px 10px 11px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---- composer ---- */
.composer {
  position: sticky; bottom: 0;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, rgba(250,247,240,0));
}
.composer-form {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 6px 6px 18px;
  box-shadow: var(--shadow);
}
.composer-form:focus-within { border-color: #bcd2c4; box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; color: var(--ink); padding: 8px 0;
}
.send-btn {
  flex: none; width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--accent); color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: background .15s ease, transform .08s ease;
}
.send-btn:hover { background: var(--accent-dark); }
.send-btn:active { transform: scale(.94); }
.send-btn:disabled { background: #b9c4bc; cursor: default; }
.disclaimer { text-align: center; color: var(--muted); font-size: .72rem; margin: 10px 4px 0; }

@media (max-width: 560px) {
  .brand-text h1 { font-size: 1.15rem; }
  .tagline { display: none; }
  .bubble { max-width: 92%; }
}
