:root {
  --bg: #f5f7fa; --panel: #ffffff; --text: #1d2939; --muted: #667085;
  --brand: #0f6e3f; --brand-2: #14924f; --user: #0f6e3f; --user-text: #fff;
  --bot: #f2f4f7; --border: #e4e7ec; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1419; --panel: #161c23; --text: #e6e9ee; --muted: #98a2b3;
    --bot: #1f2730; --border: #2a333d; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }

.app { display: flex; flex-direction: column; height: 100%; max-width: 880px; margin: 0 auto; background: var(--panel); }
body.full .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--brand); color: #fff; }
.header .logo { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.18); display: grid; place-items: center; font-weight: 700; }
.header .title { font-weight: 650; font-size: 16px; }
.header .sub { font-size: 12px; opacity: .85; }
.header .spacer { flex: 1; }
.header button { background: rgba(255,255,255,.15); border: 0; color: #fff; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.header button:hover { background: rgba(255,255,255,.28); }

.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: var(--radius); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-text); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.bot p { margin: .35em 0; }
.msg.bot h1, .msg.bot h2, .msg.bot h3 { font-size: 1em; margin: .8em 0 .3em; }
.msg.bot ul, .msg.bot ol { padding-left: 1.3em; margin: .3em 0; }
.msg.bot blockquote { margin: .4em 0; padding: .2em .8em; border-left: 3px solid var(--brand-2); color: var(--muted); }
.msg.bot table { border-collapse: collapse; font-size: 13px; }
.msg.bot td, .msg.bot th { border: 1px solid var(--border); padding: 4px 6px; }
.msg.bot code { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 4px; }
.msg.error { background: #fef3f2; color: #b42318; }
.typing span { display: inline-block; width: 7px; height: 7px; margin-right: 3px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.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; } }

.suggest { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 8px; }
.suggest button { border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.suggest button:hover { border-color: var(--brand-2); color: var(--brand-2); }

.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--panel); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; background: var(--bg); color: var(--text); max-height: 140px; outline: none; }
.composer textarea:focus { border-color: var(--brand-2); }
.composer button { border: 0; background: var(--brand); color: #fff; border-radius: 12px; padding: 0 16px; font-weight: 600; cursor: pointer; }
.composer button:disabled { opacity: .5; cursor: default; }
.foot { text-align: center; font-size: 11px; color: var(--muted); padding: 0 0 8px; background: var(--panel); }

body.compact { font-size: 14px; }
body.compact .header { padding: 10px 14px; }
body.compact .messages { padding: 12px; }
body.compact .msg { max-width: 94%; }
