:root{
  --bg: #212121;
  --panel: #171717;
  --panel2:#1e1e1e;
  --text: #e8e8e8;
  --muted:#a3a3a3;
  --line: rgba(255,255,255,.08);

  --chip:#2a2a2a;
  --chip2:#303030;

  --radius: 14px;
  --radius2: 22px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background: var(--bg);
  color: var(--text);
  overflow:hidden;
}

/* ===== Layout ===== */
.app{
  height:100vh;
  display:grid;
  grid-template-columns: 300px 1fr;
  min-height:0;
}

/* ===== Sidebar ===== */
.sidebar{
  background: var(--panel);
  border-right: 1px solid var(--line);
  display:flex;
  flex-direction:column;
  min-height:0;
}

.side-header{
  height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 12px;
  gap: 10px;
}

.side-brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.side-logo{
  width:28px;
  height:28px;
  object-fit:contain;
  flex:0 0 auto;
}

.side-brand-text{
  font-size:13px;
  font-weight:650;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.side-icon-btn{
  border:1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  cursor:pointer;
}
.side-icon-btn:hover{ background: rgba(255,255,255,.10); }
.side-icon-btn.danger{ opacity:.9; }
.side-icon-btn.danger:hover{ background: rgba(255,80,80,.12); border-color: rgba(255,80,80,.25); }

.side-nav{
  padding: 6px 8px 10px;
}
.side-item{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  padding: 10px 10px;
  border-radius: 12px;
  border:1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  text-align:left;
}
.side-item:hover{
  background: rgba(255,255,255,.06);
}
.side-ico{ width:18px; display:inline-flex; justify-content:center; opacity:.9; }
.side-text{ flex:1; font-size:13px; }
.side-right{
  font-size:12px;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border:1px solid var(--line);
}

.side-sep{
  height:1px;
  margin: 10px 6px;
  background: var(--line);
}

.side-section{
  flex:1;
  min-height:0;
  padding: 6px 8px 10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.side-section-title{
  padding: 0 6px;
  font-size:12px;
  color: var(--muted);
}
.chatlist{
  overflow:auto;
  min-height:0;
  padding: 2px;
}

/* Your JS uses .chat-item .title .sub — keep these */
.chat-item{
  margin: 6px 4px;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.04);
  cursor:pointer;
}
.chat-item:hover{ background: rgba(255,255,255,.06); }
.chat-item.active{
  background: rgba(255,255,255,.09);
  border-color: rgba(255,255,255,.12);
}
.chat-item .title{
  font-size:13px;
  font-weight:650;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.chat-item .sub{
  margin-top:4px;
  font-size:12px;
  color: var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.side-footer{
  padding: 10px 10px;
  border-top:1px solid var(--line);
  display:flex;
  align-items:center;
  gap:10px;
}
.user-chip{
  display:flex;
  align-items:center;
  gap:10px;
  flex:1;
  min-width:0;
}
.avatar{
  width:34px;
  height:34px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  background: rgba(255,255,255,.08);
  border:1px solid var(--line);
  font-weight:700;
}
.user-meta{ min-width:0; }
.user-meta .name{ font-size:13px; font-weight:650; }
.user-meta .sub{
  font-size:12px;
  color: var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* ===== Main ===== */
.main{
  display:flex;
  flex-direction:column;
  min-height:0;
}

/* Topbar */
.topbar{
  height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.08);
}

.top-left{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}
.model-btn{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor:pointer;
  padding: 8px 10px;
  border-radius: 10px;
}
.model-btn:hover{ background: rgba(255,255,255,.06); }
.model-title{ font-weight:650; font-size:13px; }
.caret{ color: var(--muted); }

.chat-title{
  font-size:13px;
  color: var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 520px;
}

.top-right{
  display:flex;
  align-items:center;
  gap:10px;
}
.status-pill{
  display:flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius: 999px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.06);
  font-size:12px;
  color: var(--muted);
}
.dot{
  width:8px;
  height:8px;
  border-radius:999px;
  background:#22c55e;
}

/* ===== Chat area ===== */
.chat{
  flex:1;
  min-height:0;
  overflow:auto;
}
.chat-inner{
  max-width: 860px;
  margin: 0 auto;
  padding: 22px 18px 140px; /* bottom padding so last msg stays above composer */
}
.thread{
  display:flex;
  flex-direction:column;
  gap: 18px;
}

/* Messages: ChatGPT-like (assistant left with avatar, user right bubble) */
.msg{
  display:flex;
  gap:12px;
  align-items:flex-start;
}

.msg .meta{
  width:36px;
  height:36px;
  border-radius: 12px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.06);
  display:grid;
  place-items:center;
  flex:0 0 auto;
  overflow:hidden;
}

/* keep your canvas */
.assistant-cat-canvas{
  width:36px;
  height:36px;
}

/* assistant content looks more “flat” like ChatGPT */
.msg.assistant .bubble{
  background: transparent;
  border: none;
  padding: 2px 0;
  max-width: 720px;
  line-height:1.55;
  font-size: 14.5px;
  color: var(--text);
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

/* user message on right */
.msg.user{
  justify-content:flex-end;
}
.msg.user .meta{ display:none; }
.msg.user .bubble{
  background: var(--chip2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 10px 14px;
  max-width: 720px;
  line-height:1.5;
  font-size: 14.5px;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

/* actions */
.bubble-actions{
  margin-top:10px;
  display:flex;
  gap:8px;
  opacity:0;
  transition: .15s opacity;
}
.msg:hover .bubble-actions{ opacity:1; }

.mini-btn{
  border:1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 10px;
  font-size:12px;
  cursor:pointer;
}
.mini-btn:hover{ background: rgba(255,255,255,.10); color: var(--text); }

/* ===== Composer (ChatGPT-like floating bar) ===== */
.composer{
  position: sticky;
  bottom: 0;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(to top, rgba(33,33,33,1) 60%, rgba(33,33,33,.6));
}

.composer-inner{
  max-width: 860px;
  margin: 0 auto;
}

.composer-bar{
  display:flex;
  align-items:flex-end;
  gap:10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
}

.composer-icon{
  border:1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  width:34px;
  height:34px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  cursor:pointer;
}
.composer-icon:hover{ background: rgba(255,255,255,.10); }

textarea#input{
  flex:1;
  resize:none;
  border:none;
  outline:none;
  background:transparent;
  color: var(--text);
  font-size:14.5px;
  line-height:1.35;
  max-height:180px;
  min-height:22px;
  padding: 6px 4px;
}
textarea#input::placeholder{ color: rgba(255,255,255,.45); }

.send{
  border:none;
  cursor:pointer;
  width:40px;
  height:40px;
  border-radius: 14px;
  background: rgba(255,255,255,.14);
  color: var(--text);
  display:grid;
  place-items:center;
}
.send:hover{ background: rgba(255,255,255,.20); }
.send:disabled{
  opacity:.45;
  cursor:not-allowed;
}

.send-ico{
  transform: translateX(1px);
}

.composer-hint{
  margin-top: 10px;
  display:flex;
  justify-content:space-between;
  gap:10px;
  font-size:12px;
  color: var(--muted);
  padding: 0 4px;
}

/* ===== Responsive ===== */
@media (max-width: 920px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }
  .chat-inner, .composer-inner{ max-width: 100%; }
  .chat-title{ max-width: 260px; }
}
