:root {
  --bg: #1e1f22;
  --bg-2: #2b2d31;
  --panel: #313338;
  --text: #f2f3f5;
  --muted: #a7adb6;
  --accent: #5865f2;
  --user-bubble: #4f46e5;
  --assistant-bubble: #3f4248;
  --danger: #ef4444;
  --ok: #22c55e;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

.sidebar {
  background: var(--bg-2);
  border-right: 1px solid #202225;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 14px;
  border-bottom: 1px solid #202225;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 18px;
}

.sidebar-header button {
  background: var(--accent);
  border: 0;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.thread-list {
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thread-item {
  background: #2f3136;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.thread-item.active {
  border-color: var(--accent);
  background: #34373d;
}

.thread-title {
  font-size: 14px;
  margin-bottom: 4px;
}

.thread-meta {
  font-size: 12px;
  color: var(--muted);
}

.chat-panel {
  display: grid;
  grid-template-rows: 70px 1fr 96px;
  background: var(--panel);
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid #25272c;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h2 {
  margin: 0;
  font-size: 18px;
}

.chat-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.conn-badge {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  background: #444;
  color: #fff;
}

.conn-badge.ok { background: rgba(34,197,94,.2); color: #86efac; }
.conn-badge.err { background: rgba(239,68,68,.2); color: #fca5a5; }

.messages {
  overflow: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg-row {
  display: flex;
  gap: 10px;
}

.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }

.msg {
  max-width: min(70%, 720px);
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user { background: var(--user-bubble); }
.msg.assistant { background: var(--assistant-bubble); }

.msg-meta {
  margin-top: 6px;
  font-size: 11px;
  color: #c7ccd1;
  display: flex;
  gap: 8px;
}

.msg-status.pending, .msg-status.running { color: #facc15; }
.msg-status.success { color: #86efac; }
.msg-status.failed, .msg-status.timeout { color: #fca5a5; }

.composer {
  border-top: 1px solid #25272c;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 100px;
  gap: 10px;
}

.composer textarea {
  width: 100%;
  resize: none;
  border: 1px solid #3b3f45;
  background: #2b2d31;
  color: #fff;
  border-radius: 10px;
  padding: 10px;
  height: 72px;
  outline: none;
}

.composer button {
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
