/* Modern multi-chat UI, mobile-first */
:root{
  --bg:#0b1220;
  --panel:#0f1a2e;
  --panel2:#0c1628;
  --text:#e7eefc;
  --muted:#9db0d0;
  --border:rgba(255,255,255,.10);
  --me:#3b82f6;
  --me2:#2563eb;
  --bubble:rgba(255,255,255,.03);
  --danger:#ef4444;
  --r:18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background:
    radial-gradient(1200px 800px at 15% 0%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(900px 700px at 95% 15%, rgba(168,85,247,.12), transparent 55%),
    var(--bg);
  color:var(--text);
}

.app{
  height:100vh;
  display:flex;
  overflow:hidden;
  max-width: 1200px;
  margin: 0 auto;
}

.side{
  width:340px;
  max-width:88vw;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border-right:1px solid var(--border);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.brand{
  display:flex;
  gap:12px;
  align-items:center;
  padding:12px;
  border:1px solid var(--border);
  border-radius: var(--r);
  background: rgba(255,255,255,.03);
}
.logo{
  width:42px;height:42px;
  border-radius: 14px;
  display:grid;place-items:center;
  border:1px solid var(--border);
  background: rgba(255,255,255,.02);
}
.brandTitle{font-weight:900}
.brandSub{font-size:12px;color:var(--muted)}
.btn{
  border:1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  color:var(--text);
  padding:12px 12px;
  cursor:pointer;
  font-weight:900;
}
.btn.primary{
  background: linear-gradient(180deg, var(--me), var(--me2));
  border-color: rgba(59,130,246,.55);
}
.btn.primary:hover{filter:brightness(1.05)}

.panel{
  border:1px solid var(--border);
  border-radius: var(--r);
  padding:12px;
  background: rgba(255,255,255,.02);
}
.panel.subtle{background: rgba(255,255,255,.015)}
.panelTitle{
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--muted);
  margin-bottom:10px;
}

.list{
  display:flex;
  flex-direction:column;
  gap:10px;
  overflow:auto;
  padding-right:6px;
  max-height:55vh;
}
.item{
  text-align:left;
  border:1px solid var(--border);
  border-radius: 16px;
  padding:10px 12px;
  background: rgba(255,255,255,.02);
  color:var(--text);
  cursor:pointer;
}
.item:hover{border-color: rgba(59,130,246,.35)}
.item.active{border-color: rgba(59,130,246,.75); background: rgba(59,130,246,.10)}
.itTitle{font-weight:800}
.itMeta{font-size:12px;color:var(--muted); margin-top:4px}
.small{font-size:12px;color:var(--muted); line-height:1.4}

.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
}

.top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  background: rgba(10,16,30,.78);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.icon{
  border:1px solid var(--border);
  background: rgba(255,255,255,.03);
  color:var(--text);
  border-radius: 16px;
  padding:10px 12px;
  cursor:pointer;
  min-width:44px;
}
.icon:hover{border-color: rgba(59,130,246,.35)}
.icon.danger:hover{border-color: rgba(239,68,68,.55)}

.topMid{flex:1; min-width:0}
.chatTitle{font-weight:950; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.status{font-size:12px; color:var(--muted)}

.chat{
  flex:1;
  overflow:auto;
  padding: 18px 14px;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.row{display:flex}
.row.me{justify-content:flex-end}
.row.ai{justify-content:flex-start}

.bubble{
  max-width: 92%;
  border:1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  background: var(--bubble);
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.row.me .bubble{
  background: rgba(59,130,246,.14);
  border-color: rgba(59,130,246,.35);
}
.role{
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing:.02em;
}
.content{
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.45;
  font-size: 14px;
}

.typingDots{
  display:inline-flex;
  gap:6px;
  align-items:center;
}
.dot{
  width:7px;
  height:7px;
  border-radius:999px;
  background: rgba(231,238,252,.65);
  animation: bounce 1.1s infinite;
}
.dot:nth-child(2){animation-delay:.15s}
.dot:nth-child(3){animation-delay:.30s}
@keyframes bounce{
  0%, 80%, 100%{transform: translateY(0); opacity:.55}
  40%{transform: translateY(-6px); opacity:1}
}

.composer{
  display:flex;
  gap:10px;
  padding: 12px 14px;
  border-top:1px solid var(--border);
  background: rgba(10,16,30,.78);
  backdrop-filter: blur(10px);
  position: sticky;
  bottom: 0;
}

.input{
  flex:1;
  resize:none;
  min-height: 46px;
  max-height: 180px;
  border:1px solid var(--border);
  border-radius: 16px;
  padding: 12px 12px;
  background: rgba(255,255,255,.03);
  color: var(--text);
  outline:none;
}
.input:focus{border-color: rgba(59,130,246,.6)}

.send{
  border:1px solid rgba(59,130,246,.55);
  background: linear-gradient(180deg, var(--me), var(--me2));
  color: white;
  border-radius: 16px;
  padding: 12px 14px;
  cursor:pointer;
  font-weight: 950;
  min-width: 92px;
}
.send:disabled{opacity:.55; cursor:not-allowed}

.backdrop{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.35);
  display:none;
  z-index: 19;
}

@media (max-width: 980px){
  .side{
    position:fixed;
    inset:0 auto 0 0;
    height:100vh;
    transform: translateX(-105%);
    transition: transform .18s ease;
    z-index: 20;
    box-shadow: 0 40px 120px rgba(0,0,0,.55);
  }
  .side.open{transform: translateX(0)}
  .backdrop.show{display:block}
}
@media (min-width: 981px){
  #btnMenu{display:none}
}
@media (min-width: 720px){
  .content{font-size:15px}
  .bubble{max-width: 78%}
}
