:root{
  --bg:#0b1020; --panel:#0e152a; --panel-2:#0b1326;
  --text:#e8eef7; --muted:#a7b3c7;
  --brand:#0ea5e9; --brand-2:#22d3ee;
  --ring:rgba(14,165,233,.35); --radius:16px;
}
*{box-sizing:border-box}
body{background:var(--bg);color:var(--text)}
.wrap{
  max-width:980px;margin:0 auto;display:flex;flex-direction:column;height:100dvh;padding:18px 14px;
  background:
    radial-gradient(900px 400px at 80% -10%, rgba(34,211,238,.10), transparent 60%),
    radial-gradient(700px 300px at 0% 0%, rgba(14,165,233,.10), transparent 50%);
}
.top{
  display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:14px 16px;border-radius:20px;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
  position:sticky;top:0;backdrop-filter:blur(10px);z-index:10;
}
.brand{display:flex;align-items:center;gap:12px}
.logo{
  width:36px;height:36px;border-radius:12px;
  background:conic-gradient(from 210deg,var(--brand),var(--brand-2));
  box-shadow:0 8px 30px rgba(34,211,238,.35), inset 0 0 0 1px rgba(255,255,255,.25);
  animation:float 6s ease-in-out infinite;
}
@keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-2px)}}
.title{
  font-weight:900; letter-spacing:.4px; font-size:22px;
  background:linear-gradient(90deg,#e6f4ff,#b9e4ff,#e6f4ff);
  -webkit-background-clip:text; background-clip:text; color:transparent;
  text-shadow:0 0 24px rgba(125,211,252,.15);
}
.actions{display:flex;gap:8px;flex-wrap:wrap}
.btn-mini{
  padding:10px 12px;border-radius:12px;border:1px solid rgba(255,255,255,.12);
  background:linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  color:var(--text);font-weight:700;cursor:pointer
}
.btn-mini:hover{box-shadow:0 8px 18px rgba(34,211,238,.15); border-color:rgba(125,211,252,.4)}
.chat{
  flex:1;overflow:auto;margin:16px 0;padding:18px;border-radius:20px;
  background:linear-gradient(180deg, var(--panel), var(--panel-2));
  border:1px solid rgba(255,255,255,.08);
  box-shadow:0 10px 40px rgba(0,0,0,.35) inset;
}

/* alineación robusta por rol */
.msg{
  display:flex; flex-direction:column; gap:6px; margin:12px 0; width:100%;
}
.msg.ai { align-items:flex-start; }
.msg.me { align-items:flex-end; }

.msg.me .bubble{ margin-left:auto; }
.msg.ai .bubble{ margin-right:auto; }

.bubble{
  max-width:78%;padding:12px 14px;border-radius:16px;
  border:1px solid rgba(255,255,255,.08);
  position:relative; line-height:1.55; animation:fadeIn .2s ease-out;
}
@keyframes fadeIn{from{opacity:0; transform:translateY(4px)}to{opacity:1; transform:translateY(0)}}
.ai .bubble{ background:linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.03)); }
.me .bubble{ background:linear-gradient(135deg, var(--brand), var(--brand-2)); color:#04121d; font-weight:700; box-shadow:0 12px 28px rgba(34,211,238,.25); }

.role{font-size:12px;color:var(--muted);margin:0 6px 4px}
.msg.me .role{ align-self:flex-end; text-align:right; }
.msg.ai .role{ align-self:flex-start; text-align:left; }

.inputbar{
  display:flex;gap:10px;padding:12px;border-radius:16px;
  background:linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.10);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
}
textarea{
  flex:1;background:#0a1426;color:#e8eef7;
  border:1px solid rgba(255,255,255,.10); border-radius:12px;
  padding:12px; min-height:48px; max-height:160px; resize:vertical
}
button{
  background:linear-gradient(135deg, var(--brand), var(--brand-2));
  color:#071019;border:0;border-radius:12px;padding:0 18px;font-weight:900;cursor:pointer
}
button:hover{transform:translateY(-1px)}
.loader{width:16px;height:16px;border-radius:50%;border:2px solid rgba(255,255,255,.35);border-top-color:#fff;animation:spin .8s linear infinite;margin-top:6px}
@keyframes spin{to{transform:rotate(360deg)}}
@media (max-width:700px){ .bubble{max-width:86%} .title{font-size:20px} }
