:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #17181a;
  --muted: #6b6f76;
  --line: #e6e4df;
  --accent: #d9382f;
  --accent-ink: #ffffff;
  --user: #17181a;
  --user-ink: #ffffff;
  --assistant: #f1efea;
  --ok: #1f7a4d;
  --warn: #b26a00;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { display: flex; justify-content: center; padding: 0 16px; }
.app { width: 100%; max-width: 760px; min-height: 100vh; display: flex; flex-direction: column; padding-block: 16px; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 4px 14px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 11px; border-radius: 4px; background: var(--accent); }
h1 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.btn-ghost { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn-ghost:hover { background: var(--card); }
.messages { flex: 1; overflow-y: auto; padding: 18px 2px; display: flex; flex-direction: column; gap: 14px; }
.welcome { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.welcome p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.welcome-title { color: var(--ink) !important; font-weight: 600; font-size: 15px !important; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 8px 12px; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--ink); }
.row { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.row.user { align-self: flex-end; align-items: flex-end; }
.row.assistant { align-self: flex-start; }
.bubble { padding: 11px 14px; border-radius: var(--radius); font-size: 15px; line-height: 1.5; word-wrap: break-word; overflow-wrap: anywhere; }
.row.user .bubble { background: var(--user); color: var(--user-ink); border-bottom-right-radius: 4px; }
.row.assistant .bubble { background: var(--assistant); color: var(--ink); border-bottom-left-radius: 4px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 4px 0 8px 18px; padding: 0; }
.bubble li { margin: 2px 0; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; }
.source { font-size: 12px; color: var(--muted); border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 9px; text-decoration: none; }
.source:hover { color: var(--ink); border-color: var(--ink); }
.meta { font-size: 11px; color: var(--muted); }
.escalation { border-left: 3px solid var(--ok); background: var(--card); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--ink); }
.escalation strong { color: var(--ok); }
.typing { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; padding: 4px 6px 10px; }
.dots i { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.banner { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; background: #fff4e5; color: var(--warn); border: 1px solid #f3dcb4; }
.banner.error { background: #fdecec; color: var(--accent); border-color: #f5c6c2; }
.composer { display: flex; gap: 8px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.composer:focus-within { border-color: var(--ink); }
textarea { flex: 1; border: 0; outline: 0; resize: none; font: inherit; font-size: 15px; line-height: 1.45; padding: 8px 6px; background: transparent; color: var(--ink); max-height: 160px; }
.btn-send { flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: grid; place-items: center; }
.btn-send:disabled { opacity: .45; cursor: not-allowed; }
.footnote { margin: 10px 4px 0; font-size: 12px; color: var(--muted); }
.footnote a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (max-width: 480px) {
  .row { max-width: 96%; }
  .subtitle { display: none; }
  .btn-ghost { padding: 6px 10px; }
}
