:root {
  --bg: #f7f7f8; --panel: #fff; --text: #17181c; --muted: #646873; --line: #e3e4e8;
  --accent: #3b5bdb; --accent-text: #fff; --user: #eef1fd; --error: #c92a2a; --ok: #2b8a3e; --warn: #e67700;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111215; --panel: #1a1b20; --text: #e8e9ec; --muted: #9a9ea8; --line: #2c2e35; --accent: #748ffc; --accent-text: #0b0c0f; --user: #22263a; --error: #ff6b6b; --ok: #69db7c; --warn: #ffa94d; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; letter-spacing: -.01em; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.spacer { flex: 1; }
.conn { font-size: 12px; color: var(--muted); }
.conn[data-state="on"] { color: var(--ok); }
.conn[data-state="retry"] { color: var(--warn); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.notice { max-width: 560px; margin: 12vh auto; padding: 0 16px; }
.notice h1 { font-size: 28px; line-height: 1.2; }
.button, button { display: inline-block; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
.layout { flex: 1; display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 0; }
.side { border-right: 1px solid var(--line); padding: 12px; overflow: auto; background: var(--panel); }
.side h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 4px 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list button { width: 100%; text-align: left; background: none; color: var(--text); font-weight: 400; padding: 6px 8px; border-radius: 6px; display: flex; gap: 8px; align-items: center; }
.list button:hover { background: var(--bg); }
.list button[aria-current="true"] { background: var(--user); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot[data-state="working"] { background: var(--warn); }
.dot[data-state="your_turn"] { background: var(--accent); }
.dot[data-state="error"] { background: var(--error); }
.list small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list span.col { min-width: 0; }
.inline { display: flex; gap: 6px; margin-top: 6px; }
input, textarea { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.chat { display: flex; flex-direction: column; min-height: 0; }
.chat-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.chat-head h1 { font-size: 17px; margin: 0; }
.state { font-size: 12px; color: var(--muted); }
.items { list-style: none; margin: 0; padding: 16px 20px; flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.items li { max-width: 720px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); white-space: pre-wrap; }
.items li.user_message { align-self: flex-end; background: var(--user); border-color: transparent; }
.items li.error { color: var(--error); }
.items li.streaming::after { content: "▍"; color: var(--muted); }
.composer { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.empty { display: grid; place-items: center; color: var(--muted); }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; max-width: calc(100% - 32px); }
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
}
