:root{
  --bg:#0e0f12;
  --panel:#15171c;
  --muted:#8b93a0;
  --text:#e7e9ee;
  --accent:#7aa2ff;
  --border:#23262d;
  --bubble-user:#1e232d;
  --bubble-bot:#141924;
  --ring:0 0 0 2px rgba(122,162,255,.25);
}

*{box-sizing:border-box}
html,body{height:100%; min-height:100dvh}
body{
  margin:0;
  font:15px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,"Helvetica Neue",Arial;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(122,162,255,.08), transparent),
    radial-gradient(800px 500px at -10% 100%, rgba(7, 176, 255, .06), transparent),
    var(--bg);
  color:var(--text);
  display:flex; flex-direction:column;
}

/* Buttons */
.btn{
  border:none; border-radius:10px; padding:10px 14px; font-weight:700;
  cursor:pointer; transition:transform .1s ease, opacity .1s ease, background .15s ease, color .15s ease;
}
.btn:disabled{ opacity:.6; cursor:not-allowed }
.btn:active{ transform:translateY(1px) }
.btn-primary{ background:var(--accent); color:#0b1020 }
.btn-ghost{ background:transparent; color:var(--text); border:1px solid var(--border) }
.btn-ghost:hover{ background:#11151f }

/* Header / Footer */
.app-header,.app-footer{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px; border-bottom:1px solid var(--border);
  background:rgba(0,0,0,.25); backdrop-filter: blur(4px);
}
.app-footer{ border-top:1px solid var(--border); border-bottom:none; justify-content:center }
.brand{ display:flex; align-items:center; gap:10px }
.brand .logo{ font-size:18px }
.app-header h1{ font-size:16px; margin:0; letter-spacing:.8px }
.actions{ display:flex; gap:8px; align-items:center }

/* Chat area */
.chat{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:10px;
  padding:10px 12px 12px;
  max-width:900px; width:100%;
  margin:0 auto;
  min-height:0;
}

.messages{
  list-style:none; padding:0; margin:0;
  display:flex; flex-direction:column; gap:12px;
  overflow:auto; scroll-behavior:smooth;
  flex:1; min-height:0;
  padding-bottom:10px;
}

/* Message layout with avatars */
.message{
  display:flex; gap:10px; align-items:flex-start;
  width:100%;
}
.message.user{ flex-direction:row-reverse }

.avatar{
  flex:0 0 32px; width:32px; height:32px;
  display:flex; align-items:center; justify-content:center;
  border-radius:50%;
  background:#0f1420; border:1px solid var(--border);
  font-size:16px; line-height:1;
}
.message.user .avatar{ background:#131824 }
.message.bot .avatar{ background:#101522 }

/* Content area follows the bubble width */
.message .content{
  display:flex; flex-direction:column; align-items:flex-start; gap:6px;
  max-width:100%;
  flex:1 1 auto;          /* Allow the content to take remaining width */
  min-width:0;            /* Prevent unintended min-content sizing */
}
.message.user .content{ align-items:flex-end }

/* Bubble */
.bubble{
  display:inline-block;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:14px 14px 14px 6px;
  max-width:min(96%, 80ch);
  white-space:pre-wrap;
  overflow-wrap:break-word; /* break long words only if necessary */
  word-break:normal;        /* avoid breaking inside words */
  hyphens:none;             /* no auto hyphenation */
  background:var(--bubble-bot);
  color:var(--text);
}
.message.user .bubble{
  background:var(--bubble-user);
  border-radius:14px 14px 6px 14px;
  color:var(--text);
}

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

/* Composer pinned to bottom */
.composer{
  position:sticky; bottom:0; z-index:5;
  display:flex; gap:10px; padding:10px; background:var(--panel);
  border:1px solid var(--border); border-radius:12px;
  align-items:flex-end;
}
.composer textarea{
  flex:1; resize:none; min-height:42px; max-height:160px;
  padding:10px 12px; border-radius:8px; border:1px solid var(--border);
  background:#0e121a; color:var(--text); outline:none;
}
.composer textarea:focus{ box-shadow:var(--ring); border-color:#2a2f3a }

.typing{ display:inline-flex; align-items:center; gap:6px }
.typing span{
  display:inline-block; width:6px; height:6px; background:#9fb6ff; border-radius:50%;
  animation: blink 1.3s infinite ease-in-out;
}
.typing span:nth-child(2){ animation-delay:.15s }
.typing span:nth-child(3){ animation-delay:.3s }
@keyframes blink{ 0%,80%,100%{opacity:.25;transform:translateY(0)} 40%{opacity:1;transform:translateY(-2px)} }

@media (max-width:600px){
  .bubble{ max-width:100% }
}
