:root {
  --bg: #0b0b0d;
  --bg-2: #121216;
  --bg-3: #1a1a20;
  --line: #232329;
  --text: #e8e8ec;
  --muted: #8b8b95;
  --accent: #e8e8ec;
  --user: #26262e;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px env(safe-area-inset-bottom);
}

/* header */
.top { padding: 20px 0 8px; text-align: center; }
.brand { display: inline-flex; align-items: center; gap: 9px; }
.mark {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2.5px solid var(--accent);
  position: relative;
}
.mark::after {
  content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--accent);
}
.wordmark { font-weight: 600; font-size: 20px; letter-spacing: -0.02em; }
.tagline { margin: 6px 0 0; color: var(--muted); font-size: 14px; min-height: 1.5em; transition: opacity .35s; }
.tagline.fade { opacity: 0; }

/* chat */
.chat { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 12px 0 8px; }
.intro { margin: auto 0; text-align: center; padding: 24px 0; }
.intro-title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; }
.intro-sub { color: var(--muted); margin: 0 0 22px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.chip:hover { background: var(--bg-3); }

.msg { display: flex; gap: 10px; animation: rise .22s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user); border-radius: var(--radius); border-bottom-right-radius: 6px;
  padding: 11px 15px; max-width: 82%; white-space: pre-wrap; word-wrap: break-word;
}
.msg.bot { align-items: flex-start; }
.avatar {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 7px; margin-top: 4px;
  border: 2px solid var(--accent); position: relative;
}
.avatar::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--accent); }
.bot-body { flex: 1; min-width: 0; }
.msg.bot .bubble { padding: 6px 2px; font-size: 17px; line-height: 1.55; word-wrap: break-word; }
.cursor {
  display: inline-block; width: 8px; height: 1.05em; background: var(--text); vertical-align: -3px;
  margin-left: 2px; animation: blink 1s steps(2, start) infinite;
}
.cursor.done { display: none; }
@keyframes blink { to { visibility: hidden; } }

.thinking-bubble { display: flex; align-items: center; gap: 10px; padding: 10px 2px; }
.status { color: var(--muted); font-size: 15px; font-style: italic; transition: opacity .25s; }
.status.fade { opacity: 0; }
.dots { display: inline-flex; gap: 5px; }
.dots span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--muted);
  animation: pulse 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: .15s; }
.dots span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }

.actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.actions[hidden] { display: none; }
.action {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
.action:hover { color: var(--text); background: var(--bg-2); }
.action.ok { color: var(--text); border-color: var(--text); }

/* composer */
.composer { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 75%, transparent); padding: 10px 0 8px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 24px; padding: 8px 8px 8px 16px;
}
.composer-box:focus-within { border-color: #3a3a44; }
textarea {
  flex: 1; resize: none; background: transparent; border: 0; outline: 0; color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.45; padding: 6px 0; max-height: 140px;
}
textarea::placeholder { color: var(--muted); }
.send {
  flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--bg); display: grid; place-items: center; cursor: pointer;
}
.send:disabled { background: #2b2b33; color: #6a6a74; cursor: default; }
.turnstile-row { display: flex; justify-content: center; margin-top: 6px; }
.turnstile-row:empty { display: none; }
.composer-note { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.ad-slot { min-height: 0; }

/* footer */
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 0 18px; }
.foot p { margin: 4px 0; }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.foot a:hover { color: var(--text); }

@media (min-width: 640px) {
  .top { padding-top: 32px; }
  .msg.bot .bubble { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .msg, .cursor, .dots span, .tagline { animation: none; transition: none; }
}
