:root {
  --bg: #f7f5f0; --panel: #fff; --text: #1a1a1a; --muted: #6b6560; --line: #e7e2d9;
  --accent: #8b1a1a; --user: #f5e8e8; --err: #b91c1c;
  --claude: #c2410c; --openai: #047857; --gemini: #2563eb; --grok: #111827; --deepseek: #4f46e5; --mistral: #c2410c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c0c; --panel: #161616; --text: #ece8e1; --muted: #a39d94; --line: #2b2b2b;
    --accent: #a11d2b; --user: #2a1517; --err: #f87171;
    --claude: #fb923c; --openai: #34d399; --gemini: #60a5fa; --grok: #e5e7eb; --deepseek: #a5b4fc; --mistral: #fdba74;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: .6rem 1rem; background: var(--accent); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
input, textarea { font: inherit; width: 100%; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
label { display: block; margin: .8rem 0; font-weight: 600; }
label input { margin-top: .3rem; font-weight: 400; }
code { background: var(--line); padding: .1rem .35rem; border-radius: 6px; word-break: break-all; }
.small { font-size: .85rem; color: var(--muted); }
.msg { color: var(--err); }
[hidden] { display: none !important; }

body.center { display: grid; place-items: center; padding: 16px; }
.card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; }
.card h1 { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; }
.card button { width: 100%; margin-top: .5rem; }
#qr { display: block; margin: .5rem auto; background: #fff; border-radius: 8px; }

.layout { display: flex; height: 100%; }
aside { width: 270px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px; gap: 10px; }
.wide { width: 100%; }
nav { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--text); text-decoration: none; padding: .5rem .6rem; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
nav a:hover, nav a.active { background: var(--bg); }
.foot { display: flex; flex-direction: column; gap: 6px; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
#toggleSide { display: none; }
#delConv { margin-left: auto; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { background: transparent; color: var(--text); border: 1px solid var(--line); padding: .35rem .8rem; border-radius: 999px; }
.pill[aria-checked="true"] { color: #fff; border-color: transparent; }
.pill.p-claude[aria-checked="true"] { background: var(--claude); }
.pill.p-openai[aria-checked="true"] { background: var(--openai); }
.pill.p-gemini[aria-checked="true"] { background: var(--gemini); }
.pill.p-grok[aria-checked="true"] { background: var(--grok); color: var(--bg); }
.pill.p-deepseek[aria-checked="true"] { background: var(--deepseek); }
.pill.p-mistral[aria-checked="true"] { background: var(--mistral); }
.pill.p-cloudflare[aria-checked="true"] { background: #f38020; }

#log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
#log .msg { color: var(--text); max-width: 820px; width: fit-content; padding: .7rem .9rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
#log .msg.user { align-self: flex-end; background: var(--user); }
#log .msg.error { color: var(--err); }
#log .msg.waiting { color: var(--muted); font-style: italic; }
.who { font-size: .75rem; font-weight: 700; color: var(--muted); margin-bottom: .2rem; }
.p-claude .who { color: var(--claude); } .p-openai .who { color: var(--openai); } .p-gemini .who { color: var(--gemini); }
.p-grok .who { color: var(--grok); } .p-deepseek .who { color: var(--deepseek); } .p-mistral .who { color: var(--mistral); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { color: var(--muted); text-align: center; margin: auto; }
#send { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel); }
#send textarea { resize: vertical; min-height: 48px; max-height: 40vh; }

@media (max-width: 760px) {
  aside { position: fixed; inset: 0 auto 0 0; z-index: 5; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px #0006; }
  body.side-open aside { transform: none; }
  #toggleSide { display: inline-block; }
}
.card h1 { color: var(--text); letter-spacing: .02em; }
a { color: #c9a227; }
