*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}
:root{
  --bg:#0d1117;
  --surface:#161b22;
  --border:#30363d;
  --text:#e6edf3;
  --text-muted:#8b949e;
  --accent:#58a6ff;
  --accent-dim:#1f6feb;
  --user-bg:#1f6feb;
  --bot-bg:#21262d;
  --code-bg:#0d1117;
  --radius:12px;
}
html,body{height:100%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;background:var(--bg);color:var(--text)}
.app{display:flex;flex-direction:column;height:100%;max-width:800px;margin:0 auto}

/* Header */
.header{display:flex;align-items:center;justify-content:space-between;padding:14px 20px;border-bottom:1px solid var(--border);background:var(--surface)}
.header-left{display:flex;align-items:center;gap:12px}
.logo{width:36px;height:36px;border-radius:8px;background:var(--accent-dim);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:18px}
.header h1{font-size:16px;font-weight:600;line-height:1.2}
.status{font-size:11px;color:var(--text-muted);transition:color .3s}
.status.online{color:#3fb950}
.status.online::before{content:"● ";font-size:9px}
.status.offline::before{content:"● ";font-size:9px;color:#f85149}
.btn-clear{background:none;border:1px solid var(--border);color:var(--text-muted);width:32px;height:32px;border-radius:8px;cursor:pointer;font-size:14px;transition:all .2s}
.btn-clear:hover{border-color:var(--accent);color:var(--accent)}

/* Chat area */
.chat{flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:12px}
.message{display:flex;max-width:85%}
.message.user{align-self:flex-end}
.message.bot{align-self:flex-start}
.bubble{padding:10px 14px;border-radius:var(--radius);font-size:14px;line-height:1.55;white-space:pre-wrap;word-break:break-word}
.message.user .bubble{background:var(--user-bg);color:#fff;border-bottom-right-radius:4px}
.message.bot .bubble{background:var(--bot-bg);border:1px solid var(--border);border-bottom-left-radius:4px}
.bubble code{font-family:"SF Mono",SFMono-Regular,Consolas,"Liberation Mono",Menlo,monospace;font-size:13px;background:var(--code-bg);padding:1px 5px;border-radius:4px}
.bubble pre{background:var(--code-bg);padding:10px 12px;border-radius:8px;overflow-x:auto;margin:6px 0}
.bubble pre code{background:none;padding:0}

/* Typing indicator */
.typing .bubble::after{content:"...";animation:blink 1s infinite}
@keyframes blink{0%,100%{opacity:.2}50%{opacity:1}}

/* Input bar */
.input-bar{display:flex;align-items:flex-end;gap:8px;padding:12px 20px;border-top:1px solid var(--border);background:var(--surface)}
.input-bar textarea{flex:1;background:var(--bg);border:1px solid var(--border);border-radius:var(--radius);padding:10px 14px;color:var(--text);font-size:14px;font-family:inherit;resize:none;max-height:150px;line-height:1.5;outline:none;transition:border-color .2s}
.input-bar textarea:focus{border-color:var(--accent)}
.input-bar textarea::placeholder{color:var(--text-muted)}
#btn-send{width:40px;height:40px;border-radius:10px;border:none;background:var(--accent-dim);color:#fff;font-size:18px;cursor:pointer;transition:background .2s;flex-shrink:0}
#btn-send:hover{background:var(--accent)}
#btn-send:disabled{opacity:.4;cursor:default}

/* Scrollbar */
.chat::-webkit-scrollbar{width:6px}
.chat::-webkit-scrollbar-track{background:transparent}
.chat::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}

/* Mobile */
@media(max-width:600px){
  .message{max-width:92%}
  .header{padding:10px 14px}
  .input-bar{padding:10px 14px}
}
