/* Hetu, the AI twin: a floating button and a chat panel. Solid, not blurred (cheap to draw). */
.tw-bubble {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 21px;
  background: linear-gradient(140deg, #8b5cf6, #e11d48);
  box-shadow: 0 12px 30px -8px rgba(225, 29, 72, .6), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s;
}
.tw-bubble:hover { transform: translateY(-2px) scale(1.04); }
.tw-bubble:active { transform: scale(.96); }
.tw-bubble .ping { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2px rgba(167, 139, 250, .6); animation: tw-ping 2.8s ease-out infinite; }
.tw-bubble[aria-expanded="true"] .ping { display: none; }
@keyframes tw-ping { 0% { transform: scale(1); opacity: .9; } 70%, 100% { transform: scale(1.55); opacity: 0; } }
.tw-badge { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #6ee7b7;
            color: #052e1f; font-size: 11px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 0 0 2px #05060b; }

.tw-panel {
  position: fixed; right: 20px; bottom: 90px; z-index: 41; width: min(390px, calc(100vw - 32px)); height: min(580px, calc(100dvh - 116px));
  display: flex; flex-direction: column; overflow: hidden; border-radius: 24px; background: #0c0e16;
  border: 1px solid rgba(255,255,255,.12); box-shadow: 0 40px 80px -30px rgba(0,0,0,.9), 0 0 0 1px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(14px) scale(.98); transform-origin: bottom right; visibility: hidden;
  transition: opacity .28s cubic-bezier(.2,.8,.2,1), transform .32s cubic-bezier(.2,.8,.2,1), visibility 0s linear .32s;
}
.tw-panel.open { opacity: 1; transform: none; visibility: visible; transition: opacity .28s cubic-bezier(.2,.8,.2,1), transform .32s cubic-bezier(.2,.8,.2,1); }
@media (max-width: 560px) {
  .tw-panel { right: 0; left: 0; bottom: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; transform: translateY(24px); }
}

.tw-head { display: flex; align-items: center; gap: 6px; padding: 14px 10px 14px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
           background: linear-gradient(180deg, rgba(167, 139, 250, .08), transparent); }
.tw-head img { width: 38px; height: 38px; object-fit: contain; margin-right: 6px; }
.tw-head .who { flex: 1; min-width: 0; }
.tw-head strong { display: block; font-size: 15px; }
.tw-head small { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #9aa0b0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-head small::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #6ee7b7; box-shadow: 0 0 0 3px rgba(110, 231, 183, .15); }
.tw-head small.off::before { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .15); }
.tw-x { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #9aa0b0; transition: background .2s, color .2s; }
.tw-x:hover { color: #fff; background: rgba(255,255,255,.07); }

.tw-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.tw-msg { max-width: 86%; padding: 10px 13px; border-radius: 18px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere;
          animation: tw-msg .25s cubic-bezier(.2,.8,.2,1); }
@keyframes tw-msg { from { opacity: 0; transform: translateY(6px); } }
.tw-msg.twin { align-self: flex-start; background: #161927; border: 1px solid rgba(255,255,255,.06); border-bottom-left-radius: 6px; color: #e8e9ee; }
.tw-msg.me { align-self: flex-end; color: #fff; background: linear-gradient(140deg, #7c3aed, #db2777); border-bottom-right-radius: 6px; }
.tw-msg.note { align-self: center; max-width: 95%; background: rgba(110, 231, 183, .08); border: 1px solid rgba(110, 231, 183, .25); color: #a7f3d0;
               font-size: 12.5px; text-align: center; border-radius: 14px; }
.tw-msg.err { align-self: center; background: rgba(251, 191, 36, .08); border: 1px solid rgba(251, 191, 36, .3); color: #fde68a; font-size: 12px; }
.tw-msg.hetu { align-self: flex-start; background: rgba(110, 231, 183, .08); border: 1px solid rgba(110, 231, 183, .3); border-bottom-left-radius: 6px; }
.tw-msg.hetu::before { content: "hetu\0027u"; display: block; font-size: 11px; font-weight: 600; color: #6ee7b7; margin-bottom: 2px; }
.tw-msg.divider { align-self: stretch; max-width: none; display: flex; align-items: center; gap: 10px; padding: 0; font-size: 11px; color: #626879; }
.tw-msg.divider::before, .tw-msg.divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.08); }
.tw-link { color: #a7f3d0; text-decoration: underline; overflow-wrap: anywhere; }
.tw-typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.tw-typing i { width: 6px; height: 6px; border-radius: 50%; background: #9aa0b0; animation: tw-dot 1.2s infinite; }
.tw-typing i:nth-child(2) { animation-delay: .15s; }
.tw-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes tw-dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }

.tw-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 12px; }
.tw-chip { font-size: 13px; padding: 7px 12px; border-radius: 999px; color: #e4defc; background: rgba(167, 139, 250, .1); border: 1px solid rgba(167, 139, 250, .28);
           transition: background .2s, transform .2s; }
.tw-chip:hover { background: rgba(167, 139, 250, .2); transform: translateY(-1px); }

.tw-form { display: none; flex-direction: column; gap: 8px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.07); background: #0a0c13; }
.tw-form.open { display: flex; }
.tw-form .row { display: flex; gap: 8px; }
.tw-form input, .tw-form textarea, .tw-form select, .tw-input textarea {
  width: 100%; font: inherit; font-size: 15px; color: #f4f4f6; background: #141724; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 10px 12px; resize: none;
  transition: border-color .2s;
}
.tw-form select { flex: none; width: 46%; }
.tw-form input:focus, .tw-form textarea:focus, .tw-form select:focus, .tw-input textarea:focus { outline: none; border-color: rgba(167, 139, 250, .6); }
.tw-formnote { margin: 0; font-size: 11px; color: #9aa0b0; }
.tw-form .acts { display: flex; gap: 8px; justify-content: flex-end; }
.tw-btn { font-size: 13px; font-weight: 600; padding: 9px 15px; border-radius: 12px; color: #fff; background: linear-gradient(140deg, #7c3aed, #db2777); transition: filter .2s; }
.tw-btn:hover { filter: brightness(1.1); }
.tw-btn.ghost { background: transparent; color: #9aa0b0; }
.tw-btn.ghost:hover { color: #fff; }
.tw-btn:disabled { opacity: .5; cursor: default; }

.tw-input { display: flex; gap: 8px; align-items: flex-end; padding: 12px 16px 14px; border-top: 1px solid rgba(255,255,255,.07); }
.tw-input textarea { max-height: 120px; }
.tw-send { flex: none; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(140deg, #7c3aed, #db2777);
           transition: transform .2s, opacity .2s; }
.tw-send:hover { transform: translateY(-1px); }
.tw-send:disabled { opacity: .45; cursor: default; transform: none; }
.tw-fine { margin: 0; padding: 0 16px 12px; font-size: 10.5px; color: #626879; text-align: center; }
@media (max-width: 560px) { .tw-fine { padding-bottom: max(12px, env(safe-area-inset-bottom)); } }

/* Hetu's hello on phones: a small bubble by the button instead of the full chat. */
.tw-teaser {
  position: fixed; right: 16px; bottom: 90px; z-index: 40; width: min(300px, calc(100vw - 32px));
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 36px 12px 12px; border-radius: 18px 18px 6px 18px;
  background: #11131d; border: 1px solid rgba(255,255,255,.12); box-shadow: 0 20px 44px -16px rgba(0,0,0,.9);
  animation: tw-msg .3s cubic-bezier(.2,.8,.2,1);
}
.tw-teaser img { width: 34px; height: 34px; object-fit: contain; flex: none; }
.tw-teaser p { margin: 0 0 9px; font-size: 13px; line-height: 1.45; color: #e8e9ee; }
.tw-teaser .tw-btn { padding: 7px 12px; font-size: 12px; }
.tw-teaser-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; color: #9aa0b0; display: grid; place-items: center; }
.tw-teaser-x:hover { color: #fff; background: rgba(255,255,255,.06); }

@media (prefers-reduced-motion: reduce) {
  .tw-bubble .ping { animation: none; display: none; }
  .tw-panel, .tw-panel.open { transition: none; }
  .tw-msg, .tw-teaser { animation: none; }
}
