:root{
  --bg1:#0b1020;
  --bg2:#121a33;
  --card: rgba(255,255,255,0.08);
  --card2: rgba(255,255,255,0.10);
  --stroke: rgba(255,255,255,0.12);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.65);
  --shadow: 0 24px 70px rgba(0,0,0,0.45);
  --primary: #7c5cff;
  --primary2:#27d8ff;
  --danger:#ff4d6d;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  background: radial-gradient(1200px 800px at 20% 10%, rgba(124,92,255,0.22), transparent 60%),
              radial-gradient(900px 700px at 80% 20%, rgba(39,216,255,0.18), transparent 55%),
              linear-gradient(160deg, var(--bg1), var(--bg2));
  overflow:hidden;
}

.bg{
  position:fixed; inset:-80px;
  background:
    radial-gradient(circle at 30% 30%, rgba(124,92,255,0.18), transparent 55%),
    radial-gradient(circle at 70% 40%, rgba(39,216,255,0.14), transparent 55%);
  filter: blur(18px);
  opacity: 0.9;
  pointer-events:none;
}

.shell{
  position:relative;
  height:100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 18px 18px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 14px 14px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{ display:flex; align-items:center; gap:12px; }
.logo{
  width:42px; height:42px;
  display:grid; place-items:center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  font-weight:800;
  letter-spacing:0.5px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.title{ font-weight: 750; font-size: 15px; }
.subtitle{ color: var(--muted); font-size: 12px; margin-top: 2px; }

.actions{ display:flex; align-items:center; gap:10px; }

.chip{
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 999px;
  cursor:pointer;
  display:flex; align-items:center; gap:8px;
  transition: transform .12s ease, background .2s ease;
}
.chip:hover{ transform: translateY(-1px); background: rgba(0,0,0,0.28); }
.chip.ghost{ background: rgba(255,255,255,0.06); }

.dot{
  width:10px; height:10px; border-radius:999px;
  background: rgba(255,255,255,0.25);
  box-shadow: 0 0 0 6px rgba(255,255,255,0.05);
}
.dot.on{
  background: #28ffb5;
  box-shadow: 0 0 0 6px rgba(40,255,181,0.14);
}

.chat{
  flex:1;
  overflow:auto;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.05));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.msg{ display:flex; margin: 10px 0; }
.msg.me{ justify-content:flex-end; }
.msg.bot{ justify-content:flex-start; }

.bubble{
  max-width: 78%;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.22);
  line-height: 1.35;
  font-size: 14px;
  box-shadow: 0 12px 35px rgba(0,0,0,0.25);
}
.msg.me .bubble{
  background: linear-gradient(135deg, rgba(124,92,255,0.28), rgba(39,216,255,0.20));
  border-color: rgba(255,255,255,0.14);
}

.composer{
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.05));
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.inputWrap{ display:flex; gap:10px; }
input{
  flex:1;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  outline:none;
}
input::placeholder{ color: rgba(255,255,255,0.45); }

.btn{
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.22);
  color: var(--text);
  cursor:pointer;
  transition: transform .12s ease, background .2s ease, opacity .2s ease;
}
.btn:hover{ transform: translateY(-1px); background: rgba(0,0,0,0.28); }
.btn:disabled{ opacity: 0.55; cursor:not-allowed; transform:none; }
.btn.primary{
  background: linear-gradient(135deg, rgba(124,92,255,0.70), rgba(39,216,255,0.45));
  border-color: rgba(255,255,255,0.18);
}
.btn.danger{
  background: rgba(255,77,109,0.22);
  border-color: rgba(255,77,109,0.35);
}

.voiceRow{
  display:flex;
  align-items:center;
  gap:12px;
  margin-top: 10px;
}
.hint{ color: var(--muted); font-size: 12px; }

/* --- Loading Overlay --- */
.loading{
  position: absolute;
  inset: 88px 18px 112px 18px;
  display:grid;
  place-items:center;
  z-index: 50;
  border-radius: 18px;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(10px);
  animation: fadeIn .18s ease;
}
.hidden{ display:none; }

.loadingCard{
  width: min(520px, 92%);
  padding: 18px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  box-shadow: var(--shadow);
  display:flex;
  align-items:center;
  gap:14px;
}

.spinner{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,0.18);
  border-top-color: rgba(124,92,255,0.95);
  animation: spin 0.9s linear infinite;
  flex: 0 0 auto;
}

.loadingTitle{ font-weight: 760; }
.loadingSub{ color: var(--muted); font-size: 13px; margin-top: 2px; }

.dots{
  margin-top: 10px;
  display:flex;
  gap: 6px;
}
.dots span{
  width: 7px; height: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.22);
  animation: pulse 1.05s infinite;
}
.dots span:nth-child(2){ animation-delay: .15s; }
.dots span:nth-child(3){ animation-delay: .30s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%,100%{ transform: translateY(0); opacity: .40; }
  50%{ transform: translateY(-4px); opacity: .95; }
}
@keyframes fadeIn {
  from{ opacity:0; transform: scale(0.99); }
  to{ opacity:1; transform: scale(1); }
}

/* Scrollbar */
.chat::-webkit-scrollbar{ width: 10px; }
.chat::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,0.12);
  border-radius: 999px;
}
