:root{
  --bg: #070A12;
  --card: rgba(255,255,255,.06);
  --stroke: rgba(255,255,255,.10);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.65);
  --shadow: 0 20px 60px rgba(0,0,0,.45);
  --radius: 18px;

  /* extra tokens for nicer UI */
  --chip: rgba(255,255,255,.08);
  --chipHover: rgba(255,255,255,.12);
  --chipStroke: rgba(255,255,255,.14);
  --focus: rgba(59,130,246,.55);
  --focusRing: rgba(59,130,246,.18);
  --green: rgba(34,197,94,.95);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  color:var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Apple Color Emoji","Segoe UI Emoji";
  overflow-x:hidden;
}

/* background glow */
.bg{
  position: fixed;
  inset: -30%;
  background:
    radial-gradient(closest-side at 20% 20%, rgba(34,197,94,.35), transparent 60%),
    radial-gradient(closest-side at 80% 30%, rgba(59,130,246,.35), transparent 60%),
    radial-gradient(closest-side at 55% 80%, rgba(168,85,247,.25), transparent 60%);
  filter: blur(40px);
  opacity: .9;
  pointer-events:none;
  transform: translateZ(0);
}

.shell{
  max-width: 980px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 22px 18px;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}

.brand{ display:flex; align-items:center; gap: 12px; }

.logo{
  width: 44px;
  height:44px;
  border-radius: 14px;
  display:grid;
  place-items:center;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(34,197,94,.95), rgba(59,130,246,.95));
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
}

.title{ font-weight:800; letter-spacing:.2px; }
.subtitle{ color: var(--muted); font-size: 13px; margin-top: 2px; }

.card{
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  min-height: 72vh;
}

.chat{
  padding: 16px 16px 6px;
  overflow-y:auto;
  flex:1;
  scroll-behavior:smooth;
}

.msg{
  display:flex;
  gap: 10px;
  margin: 10px 0;
  align-items:flex-end;
}

.avatar{
  width: 34px;
  height:34px;
  border-radius: 12px;
  display:grid;
  place-items:center;
  flex:0 0 auto;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  user-select:none;
}

.avatar.bot{
  background: linear-gradient(135deg, rgba(34,197,94,.25), rgba(59,130,246,.25));
}

.bubble{
  max-width: 78%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 10px 25px rgba(0,0,0,.18);
  animation: pop .16s ease-out;
}

.user{ justify-content:flex-end; }
.user .avatar{ display:none; }

.user .bubble{
  background: linear-gradient(135deg, rgba(59,130,246,.90), rgba(168,85,247,.75));
  border: 1px solid rgba(255,255,255,.14);
}

.meta{
  font-size: 11px;
  color: rgba(255,255,255,.55);
  margin-top: 8px;
}

.composer{
  padding: 12px;
  display:flex;
  gap: 10px;
  border-top: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.12);
}

.input{
  flex:1;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,16,30,.55);
  color: var(--text);
  outline:none;
}

.input::placeholder{ color: rgba(255,255,255,.45); }

.input:focus{
  border-color: var(--focus);
  box-shadow: 0 0 0 4px var(--focusRing);
}

.btn{
  border: none;
  border-radius: 14px;
  padding: 11px 14px;
  cursor:pointer;
  font-weight: 700;
  color: var(--text);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  transition: transform .12s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.btn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.18);
}

.btn:active{ transform: translateY(0px); }
.btn:disabled{ opacity:.6; cursor:not-allowed; transform:none; }

.btn.primary{
  background: linear-gradient(135deg, rgba(34,197,94,.95), rgba(59,130,246,.95));
  border: 1px solid rgba(255,255,255,.14);
}

.btn.primary:hover{
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  border-color: rgba(255,255,255,.20);
}

.btn.ghost{
  background: rgba(255,255,255,.06);
}

.hint{
  padding: 10px 14px 14px;
  font-size: 12px;
  color: var(--muted);
}

.footer{
  display:flex;
  gap: 10px;
  align-items:center;
  justify-content:center;
  color: rgba(255,255,255,.55);
  font-size: 12px;
}

.dot{ opacity:.4; }
.status{ color: rgba(255,255,255,.7); }

/* typing indicator */
.typing{
  display:inline-flex;
  gap: 6px;
  align-items:center;
}

.typing span{
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.8);
  opacity: .7;
  animation: blink 1s infinite;
}

.typing span:nth-child(2){ animation-delay:.15s; }
.typing span:nth-child(3){ animation-delay:.30s; }

/* ===== Source buttons with icon ===== */
.sources{
  margin-top: 10px;
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
}

.source-btn{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  text-decoration:none;
  color: rgba(255,255,255,.92);
  background: var(--chip);
  border: 1px solid var(--chipStroke);
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.source-btn:hover{
  transform: translateY(-1px);
  background: var(--chipHover);
  border-color: rgba(255,255,255,.24);
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
}

.source-btn:active{
  transform: translateY(0);
  box-shadow: none;
}

.source-btn:focus-visible{
  outline: none;
  box-shadow: 0 0 0 4px var(--focusRing);
  border-color: var(--focus);
}

.source-dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(34,197,94,.15);
}

.source-text{
  font-weight: 650;
  opacity: .95;
}

.source-host{
  opacity: .65;
  max-width: 160px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-icon{
  width: 14px;
  height: 14px;
  opacity: .85;
}

/* animations */
@keyframes blink{
  0%,100%{ transform: translateY(0); opacity:.35; }
  50%{ transform: translateY(-3px); opacity:.9; }
}

@keyframes pop{
  from{ transform: scale(.98); opacity:0; }
  to{ transform: scale(1); opacity:1; }
}

/* responsive */
@media (max-width: 520px){
  .bubble{ max-width: 88%; }
  .logo{ width:40px; height:40px; border-radius: 14px; }
  .card{ min-height: 78vh; }
  .source-host{ max-width: 110px; }
}

/* nice scrollbars (optional) */
.chat::-webkit-scrollbar{ width: 10px; }
.chat::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.10);
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,.0);
}
.chat::-webkit-scrollbar-track{ background: rgba(0,0,0,.0); }
/* ===== Status indicator (top dot) ===== */
.status-indicator{
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display:inline-block;
  margin-left: 10px;
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 0 0 4px rgba(255,255,255,.06);
}

/* состояния */
.status-indicator.ready{
  background: rgba(34,197,94,.95);            /* зелёный */
  box-shadow: 0 0 0 4px rgba(34,197,94,.14), 0 0 12px rgba(34,197,94,.25);
}

.status-indicator.loading{
  background: rgba(250,204,21,.95);           /* жёлтый */
  box-shadow: 0 0 0 4px rgba(250,204,21,.14), 0 0 12px rgba(250,204,21,.25);
}

.status-indicator.error{
  background: rgba(239,68,68,.95);            /* красный */
  box-shadow: 0 0 0 4px rgba(239,68,68,.14), 0 0 12px rgba(239,68,68,.25);
}

/* (необязательно) легкое "дыхание" когда loading */
.status-indicator.loading{
  animation: pulseStatus 1s infinite;
}

@keyframes pulseStatus{
  0%,100%{ transform: scale(1); opacity: .9; }
  50%{ transform: scale(1.12); opacity: 1; }
}
