:root {
  --bg: #0f1115; --panel: #161a22; --panel2: #1c212c; --line: #262c3a;
  --text: #d7dce4; --dim: #7d8698; --accent: #4f8cff; --accent2: #3a6fd8;
  --user: #2b3a5c; --err: #ff6b6b; --ok: #51cf8e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* login */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 10; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: min(92vw, 340px); display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { font-size: 20px; text-align: center; }
.login-card input { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 15px; outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-card button { background: var(--accent); border: none; border-radius: 8px; padding: 10px; color: #fff; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--accent2); }
.login-error { color: var(--err); font-size: 13px; min-height: 18px; text-align: center; }

/* layout */
.app { display: flex; height: 100vh; }
.sidebar { width: 240px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.brand { padding: 14px 16px; font-weight: 600; border-bottom: 1px solid var(--line); }
.agents { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.agent-btn { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.agent-btn small { display: block; color: var(--dim); font-size: 11.5px; }
.agent-btn:hover { background: var(--panel2); }
.agent-btn.active { background: var(--panel2); box-shadow: inset 2px 0 0 var(--accent); }
.chats-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px 6px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.chats-head button { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
.chats { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.chat-btn { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: 6px; padding: 6px 10px; color: var(--dim); font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-btn:hover { background: var(--panel2); color: var(--text); }
.chat-btn.active { background: var(--panel2); color: var(--text); }
.chat-del { float: right; color: var(--dim); visibility: hidden; cursor: pointer; }
.chat-btn:hover .chat-del { visibility: visible; }
.chat-del:hover { color: var(--err); }

/* main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-title { padding: 12px 20px; border-bottom: 1px solid var(--line); color: var(--dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; border-radius: 12px; padding: 10px 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); }
.msg.assistant { align-self: flex-start; background: var(--panel2); border: 1px solid var(--line); }
.msg.error { align-self: stretch; background: transparent; border: 1px solid var(--err); color: var(--err); font-size: 13px; }
.msg .tool { display: inline-block; margin: 4px 6px 0 0; padding: 1px 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--dim); font-size: 11.5px; }
.msg pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; margin: 8px 0; font-size: 13px; }
.msg code { font-family: ui-monospace, Consolas, monospace; }
.composer { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { flex: 1; resize: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); font: inherit; outline: none; max-height: 160px; }
.composer textarea:focus { border-color: var(--accent); }
.composer button { background: var(--accent); border: none; border-radius: 10px; width: 46px; cursor: pointer; color: #fff; font-size: 17px; }
.composer button:disabled { background: var(--panel2); color: var(--dim); cursor: default; }

@media (max-width: 720px) {
  .sidebar { position: absolute; z-index: 5; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .brand { cursor: pointer; }
  .msg { max-width: 94%; }
}
