:root {
  --bg: #0f172a;
  --ink: #f8fafc;
  --side: #6d28d9;
  --user: #fb923c;
  --user-ink: #1c1917;
  --bot: #5eead4;
  --bot-ink: #042f2e;
  --panel: #1e293b;
  --line: #334155;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Segoe UI", sans-serif;
}
.app {
  max-width: 1200px;
  height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--bg);
}
.side {
  background: var(--side);
  color: #fff;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.side button, .top button, .drawer button {
  border: 1px solid #c4b5fd;
  background: #7c3aed;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.sessions { overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.sessions button { text-align: left; color: #fff; background: #5b21b6; }
.sessions button.active { outline: 2px solid #fde68a; }
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.rainbow { height: 6px; background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7); }
.top {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: #111827;
  border-bottom: 1px solid var(--line);
}
#chatName {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.status { margin: 0; padding: 6px 12px; color: #fde68a; min-height: 1.2em; background: #111827; }
.log {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}
.bubble {
  max-width: min(72%, 640px);
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user { margin-left: auto; background: var(--user); color: var(--user-ink); }
.bubble.assistant { margin-right: auto; background: var(--bot); color: var(--bot-ink); }
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  background: #111827;
  border-top: 1px solid var(--line);
}
#input, .drawer input, .drawer textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  resize: none;
}
.send {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #f59e0b, #22c55e, #3b82f6, #a855f7);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.send svg { width: 20px; height: 20px; display: block; }
.drawer { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 20; }
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(380px, 100%);
  background: #1e1b4b;
  color: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.drawer label { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 8px; }
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side {
    display: none;
    position: absolute;
    z-index: 10;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
  }
  .side.open { display: flex; }
}
