:root {
  --bg: #0a0a0b;
  --panel: #101113;
  --panel-2: #17181b;
  --border: #282a2f;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --soft: #d4d4d8;
  --accent: #ffffff;
  --blue: #2f7df6;
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, #171923 0, #0a0a0b 34%, #050506 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
button, textarea { font: inherit; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 300px 1fr; }
.sidebar {
  background: rgba(12, 12, 14, .96);
  border-right: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 8px 6px 18px; }
.brand-mark, .avatar {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #f8fafc, #a1a1aa);
  color: #09090b; font-weight: 950;
}
.brand strong { display: block; letter-spacing: -.03em; }
.brand span, .side-foot, .topbar p, .dialog-head span { color: var(--muted); font-size: 13px; }
.new-chat, .ghost, .prompt, .composer button {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: .18s ease;
}
.new-chat { text-align: left; font-weight: 800; background: #f4f4f5; color: #09090b; }
.new-chat:hover, .composer button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.side-section { display: grid; gap: 8px; }
.side-section.grow { margin-top: auto; }
.side-title { margin: 0 0 4px; color: #71717a; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 900; }
.prompt, .ghost { text-align: left; color: var(--soft); background: transparent; }
.prompt:hover, .ghost:hover { background: var(--panel-2); color: #fff; }
.main { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; max-height: 100vh; }
.topbar {
  height: 84px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  background: rgba(10, 10, 11, .7);
  backdrop-filter: blur(20px);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.04em; }
.topbar p { margin: 5px 0 0; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.status span { width: 9px; height: 9px; border-radius: 99px; background: #22c55e; box-shadow: 0 0 0 5px rgba(34,197,94,.12); }
.chat { overflow-y: auto; padding: 34px; display: flex; flex-direction: column; gap: 22px; scroll-behavior: smooth; }
.message { display: grid; grid-template-columns: 42px minmax(0, 820px); gap: 14px; align-items: start; }
.message.user { grid-template-columns: minmax(0, 820px) 42px; align-self: end; }
.message.user .avatar { grid-column: 2; background: #2f7df6; color: white; }
.message.user .bubble { grid-column: 1; grid-row: 1; background: #1c2432; border-color: #263247; }
.bubble {
  border: 1px solid var(--border);
  background: rgba(18, 19, 22, .96);
  border-radius: 22px;
  padding: 16px 18px;
  line-height: 1.65;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  white-space: pre-wrap;
}
.bubble p { margin: 0; }
.bubble code { background: #0b0f19; border: 1px solid #273244; padding: 2px 6px; border-radius: 7px; }
.bubble pre {
  background: #080b11;
  border: 1px solid #273244;
  padding: 16px;
  border-radius: 16px;
  overflow: auto;
  white-space: pre;
}
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 99px; background: #a1a1aa; animation: dot 1s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.composer {
  margin: 0 auto 24px;
  width: min(920px, calc(100% - 48px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  background: rgba(18, 19, 22, .96);
  border-radius: 22px;
  box-shadow: 0 24px 90px rgba(0,0,0,.35);
}
textarea {
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  padding: 12px 12px;
  min-height: 46px;
  max-height: 180px;
}
.composer button { background: #f4f4f5; color: #09090b; font-weight: 900; min-width: 104px; }
dialog {
  width: min(900px, 92vw);
  height: min(720px, 86vh);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: #0e0f12;
  color: var(--text);
  padding: 0;
  box-shadow: 0 50px 160px rgba(0,0,0,.65);
}
dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(6px); }
.dialog-head { height: 72px; padding: 0 18px 0 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.dialog-head strong { display: block; }
.dialog-head button { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: #17181b; color: #fff; font-size: 24px; cursor: pointer; }
#brainOutput { margin: 0; padding: 22px; height: calc(100% - 72px); overflow: auto; white-space: pre-wrap; color: #d4d4d8; }
@media (max-width: 880px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 18px; }
  .status { display: none; }
  .chat { padding: 22px 14px; }
  .message, .message.user { grid-template-columns: 36px minmax(0, 1fr); }
  .message.user { grid-template-columns: minmax(0, 1fr) 36px; }
  .avatar { width: 34px; height: 34px; border-radius: 11px; }
  .composer { width: calc(100% - 20px); margin-bottom: 10px; }
}
