<style>
  :root{
    --ai-bg: #06080f;
    --ai-bg-2: #0a0f1c;

    --ai-glass: rgba(255,255,255,0.05);
    --ai-glass-strong: rgba(255,255,255,0.08);
    --ai-glass-border: rgba(255,255,255,0.10);

    --ai-blue-1: #2f6bff;
    --ai-blue-2: #5b8dff;
    --ai-violet: #8b5cf6;
    --ai-cyan: #22d3ee;

    --ai-text: #eef1f7;
    --ai-text-dim: #9aa4bd;
    --ai-text-faint: #626d85;

    --ai-success: #34d399;
    --ai-error: #f87171;
    --ai-warn: #f5b95b;

    --ai-r-xl: 28px;
    --ai-r-lg: 20px;
    --ai-r-md: 14px;
    --ai-r-sm: 10px;
}

  

  /* ambient animated gradient field behind the panel */
  .aura{
    position:fixed;
    inset:0;
    z-index:0;
    background: var(--ai-bg);
    overflow:hidden;
  }
  .aura::before, .aura::after, .blob{
    content:'';
    position:absolute;
    border-radius:50%;
    filter: blur(90px);
    opacity: 0.55;
  }
  .aura::before{
    width: 620px; height: 620px;
    top: -180px; left: -140px;
    background: radial-gradient(circle at 30% 30%, var(--ai-blue-1), transparent 70%);
    animation: drift1 22s ease-in-out infinite;
  }
  .aura::after{
    width: 560px; height: 560px;
    bottom: -200px; right: -120px;
    background: radial-gradient(circle at 60% 60%, var(--ai-violet), transparent 70%);
    animation: drift2 26s ease-in-out infinite;
  }
  .blob{
    width: 420px; height: 420px;
    top: 40%; left: 50%;
    background: radial-gradient(circle, var(--ai-cyan), transparent 70%);
    opacity: 0.25;
    animation: drift3 30s ease-in-out infinite;
  }
  @keyframes drift1{
    0%,100%{ transform: translate(0,0) scale(1); }
    50%{ transform: translate(60px, 40px) scale(1.08); }
  }
  @keyframes drift2{
    0%,100%{ transform: translate(0,0) scale(1); }
    50%{ transform: translate(-50px, -30px) scale(1.05); }
  }
  @keyframes drift3{
    0%,100%{ transform: translate(-50%,-40%) scale(1); }
    50%{ transform: translate(-45%,-45%) scale(1.15); }
  }

  /* app shell */
  .app{
    position:relative;
    z-index: 1;
    width:100%;
    max-width: 760px;
    height: min(820px, 92vh);
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
    border: 1px solid var(--ai-glass-border);
    border-radius: var(--ai-r-xl);
    display:flex;
    flex-direction:column;
    overflow:hidden;
    box-shadow:
      0 30px 80px rgba(0,0,0,0.55),
      0 0 0 1px rgba(255,255,255,0.02) inset,
      0 1px 0 rgba(255,255,255,0.08) inset;
  }

  /* setup banner */
  .setup-banner{
    display:none;
    background: rgba(245, 185, 91, 0.08);
    border-bottom: 1px solid rgba(245, 185, 91, 0.25);
    color: var(--ai-warn);
    font-size: 12px;
    padding: 10px 20px;
    line-height: 1.5;
  }
  .setup-banner.show{ display:block; }
  .setup-banner code{
    background: rgba(0,0,0,0.3);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
  }

  /* header */
  .titlebar{
    padding: 18px 22px;
    border-bottom: 1px solid var(--ai-glass-border);
    display:flex;
    align-items:center;
    gap: 13px;
    background: var(--ai-glass);
  }
  .orb{
    position:relative;
    width: 36px; height: 36px;
    border-radius: 50%;
    flex-shrink:0;
    background: conic-gradient(from 0deg, var(--ai-blue-1), var(--ai-violet), var(--ai-cyan), var(--ai-blue-1));
    box-shadow: 0 0 18px rgba(91,141,255,0.55);
  }
  .orb::after{
    content:'';
    position:absolute;
    inset: 3px;
    border-radius:50%;
    background: var(--ai-bg-2);
  }
  .orb.spin{ animation: spin 7s linear infinite; }
  @keyframes spin{ to{ transform: rotate(360deg); } }

  .orb.small{ width:26px; height:26px; }
  .orb.small::after{ inset:2.5px; }

  .title-text{ display:flex; flex-direction:column; line-height:1.25; }
  .title-text .brand{ font-weight:700; font-size:15px; letter-spacing:-0.01em; }
  .title-text .sub{ font-size:11.5px; color: var(--ai-text-dim); font-weight:500; }

  .status{
    margin-left:auto;
    display:flex; align-items:center; gap:7px;
    font-size: 11.5px;
    color: var(--ai-text-dim);
    font-weight:500;
  }
  .status .dot{
    width:7px; height:7px; border-radius:50%;
    background: #84FAB0;
    box-shadow: 0 0 8px rgba(52,211,153,0.8);
    animation: pulseDot 2s ease-in-out infinite;
  }
  @keyframes pulseDot{ 0%,100%{ opacity:1; } 50%{ opacity:0.45; } }

  /* message log */
  .log{
    flex:1;
    overflow-y:auto;
    padding: 22px;
    display:flex;
    flex-direction:column;
    gap: 16px;
  }
  .log::-webkit-scrollbar{ width: 6px; }
  .log::-webkit-scrollbar-thumb{ background: rgba(255,255,255,0.12); border-radius: 4px; }
  .log::-webkit-scrollbar-track{ background: transparent; }

  
  .row.bot{ align-self:flex-start; }
  .row.user{ align-self:flex-end; flex-direction:row-reverse; }

  .avatar{ flex-shrink:0; margin-top:2px; }
  .avatar.user-avatar{
    width:26px; height:26px; border-radius:50%;
    background: linear-gradient(135deg, #3a4256, #232838);
    border: 1px solid var(--ai-glass-border);
    display:flex; align-items:center; justify-content:center;
  }
  .avatar.user-avatar svg{ width:14px; height:14px; opacity:0.75; }

  .bubble-col{ display:flex; flex-direction:column; gap:4px; }
  .row.user .bubble-col{ align-items:flex-end; }

  .meta{
    font-size: 10.5px;
    color: var(--ai-text-faint);
    font-weight:500;
    letter-spacing:0.02em;
    padding: 0 4px;
  }

  .bubble{
    padding: 11px 15px;
    border-radius: var(--ai-r-md);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-weight: 450;
  }
  .row.bot .bubble{
    background: var(--ai-glass-strong);
    border: 1px solid var(--ai-glass-border);
    border-top-left-radius: 4px;
    color: var(--ai-text);
  }
  .row.user .bubble{
    background: linear-gradient(135deg, var(--ai-blue-1), var(--ai-violet));
    border-top-right-radius: 4px;
    color: #fff;
    box-shadow: 0 6px 20px rgba(47,107,255,0.35);
  }
  .row.bot .bubble.error{
    background: rgba(248,113,113,0.08);
    border-color: rgba(248,113,113,0.3);
    color: #fbc7c0;
  }

  .sysnote{
    align-self:center;
    font-size: 11px;
    font-weight:500;
    color: var(--ai-text-dim);
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--ai-glass-border);
    background: var(--ai-glass);
  }
  .sysnote.ok{ color: var(--ai-success); border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.08); }
  .sysnote.err{ color: var(--ai-error); border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.08); }

  .typing-dots{ display:flex; align-items:center; gap: 5px; padding: 4px 2px; }
  .typing-dots span{
    width:6px; height:6px; border-radius:50%;
    background: linear-gradient(135deg, var(--ai-blue-2), var(--ai-violet));
    animation: pulse 1.2s infinite ease-in-out;
  }
  .typing-dots span:nth-child(2){ animation-delay: 0.15s; }
  .typing-dots span:nth-child(3){ animation-delay: 0.3s; }
  @keyframes pulse{ 0%,60%,100%{opacity:.3; transform:scale(.8);} 30%{opacity:1; transform:scale(1);} }

  /* floating input */
  .input-wrap{
    padding: 16px 20px 20px;
  }
  .inputbar{
    display:flex;
    align-items:flex-end;
    gap: 10px;
    background: var(--ai-glass-strong);
    border: 1px solid var(--ai-glass-border);
    border-radius: var(--ai-r-lg);
    padding: 8px 8px 8px 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  }
  textarea#input{
    flex:1;
    resize:none;
    background: transparent;
    border: none;
    color: var(--ai-text);
    font-family: inherit;
    font-size: 14px;
    padding: 9px 4px;
    max-height: 140px;
    min-height: 24px;
    line-height: 1.5;
  }
  textarea#input:focus{ outline: none; }
  textarea#input::placeholder{ color: var(--ai-text-faint); }
  textarea#input:disabled{ opacity: 0.5; cursor: not-allowed; }

  button#send{
    flex-shrink:0;
    width: 38px; height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ai-blue-1), var(--ai-violet));
    display:flex; align-items:center; justify-content:center;
    cursor:pointer;
    box-shadow: 0 6px 18px rgba(91,141,255,0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  button#send svg{ width:16px; height:16px; }
  button#send:hover{ transform: translateY(-1px); box-shadow: 0 8px 22px rgba(91,141,255,0.6); }
  button#send:disabled{
    background: rgba(255,255,255,0.08);
    box-shadow:none; cursor:not-allowed;
  }
  button#send:focus-visible, textarea#input:focus-visible{
    outline: 2px solid var(--ai-blue-2); outline-offset: 2px;
  }

  .hint{
    text-align:center;
    font-size: 10.5px;
    color: var(--ai-text-faint);
    padding: 0 0 4px;
  }

  button#restart{
    display:none;
    width:100%;
    align-items:center;
    justify-content:center;
    gap:8px;
    margin-top: 10px;
    padding: 11px 16px;
    border-radius: var(--ai-r-lg);
    border: 1px solid var(--ai-glass-border);
    background: var(--ai-glass-strong);
    color: var(--ai-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
  }
  button#restart:hover{ background: rgba(255,255,255,0.12); transform: translateY(-1px); }
  button#restart:focus-visible{ outline: 2px solid var(--ai-blue-2); outline-offset: 2px; }

  @media (prefers-reduced-motion: reduce){
    .orb.spin, .status .dot, .typing-dots span, .aura::before, .aura::after, .blob{ animation: none !important; }
  }

  @media (max-width: 520px){
    body{ padding:0; }
    .app{ height: 100vh; max-width: 100%; border-radius: 0; border:none;  }
  }
</style>