:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #eef1f5; --border: #dde2e8; --text: #18212b; --muted: #5d6874;
  --accent: #3554d1; --accent-weak: #e7ecff; --ok: #157f3b; --bad: #b42318; --warn: #a15c00;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --panel: #161c24; --panel-2: #1d2530; --border: #2a3440; --text: #e5eaf0; --muted: #94a1af;
    --accent: #7c95ff; --accent-weak: #1f2a4d; --ok: #4ade80; --bad: #f87171; --warn: #f0a43a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); padding: 6px 12px; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:disabled { opacity: .55; cursor: default; }
button.ghost { background: none; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 28px; height: 28px; color: var(--accent); flex: none; }
h1 { font-size: 17px; margin: 0; }
.sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.right { display: flex; align-items: center; gap: 10px; }
.status { font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.status.online { color: var(--ok); }
.status.offline { color: var(--bad); }
.status.waking { color: var(--warn); }

.chat { flex: 1; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; max-width: 820px; width: 100%; margin: 0 auto; }
.welcome { text-align: center; margin: auto 0; padding: 20px 0; }
.welcome h2 { margin: 0 0 6px; font-size: 24px; }
.welcome p { color: var(--muted); max-width: 520px; margin: 6px auto; }
.welcome .fine { font-size: 12.5px; margin-top: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0 4px; }
.chip { border-radius: 999px; font-size: 13.5px; }

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg.user { align-items: flex-end; }
.bubble { padding: 10px 14px; border-radius: 14px; max-width: min(640px, 92%); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.bot .bubble { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble pre { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow-x: auto; font-family: var(--mono); font-size: 13px; }
.bubble code { font-family: var(--mono); font-size: 13px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.bubble pre code { background: none; padding: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 22px; }
details.thoughts { font-size: 13px; color: var(--muted); max-width: min(640px, 92%); }
details.thoughts summary { cursor: pointer; }
details.thoughts div { white-space: pre-wrap; padding: 6px 0 0 14px; border-left: 2px solid var(--border); font-family: var(--mono); font-size: 12px; }
.meta { font-size: 12px; color: var(--muted); }
.error { color: var(--bad); }
.cursor::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px 14px;
  max-width: 820px; width: 100%; margin: 0 auto;
}
.composer textarea {
  flex: 1; resize: none; max-height: 180px; overflow-y: hidden; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--panel); outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.think { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); padding-bottom: 10px; white-space: nowrap; }

@media (max-width: 560px) {
  .sub { display: none; }
  .composer { flex-wrap: wrap; }
  .think { order: 3; width: 100%; padding: 0; }
}
