/* BevisHub Bit — isolated; does not touch portal card/star styles */
#hubBit {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(56px, calc(env(safe-area-inset-bottom, 0px) + 48px));
  z-index: 40;
  width: 144px;
  height: 144px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 0 10px rgba(0, 240, 255, 0.35));
}
#hubBit img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
}
#hubBit.hub-bit-float {
  animation: hubBitFloat 3.6s ease-in-out infinite;
}
@keyframes hubBitFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  #hubBit.hub-bit-float { animation: none; }
}
#hubBit.hub-bit-thinking img {
  filter: brightness(1.15) saturate(1.2);
}

#hubChat {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(220px, calc(env(safe-area-inset-bottom, 0px) + 212px));
  z-index: 41;
  width: min(360px, calc(100vw - 24px));
  max-height: min(420px, calc(100vh - 180px));
  display: none;
  flex-direction: column;
  background: rgba(10, 14, 32, 0.92);
  border: 1px solid rgba(0, 240, 255, 0.35);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 24px rgba(180, 77, 255, 0.15);
  backdrop-filter: blur(10px);
  color: #e8f0ff;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}
#hubChat.open { display: flex; }
#hubChat .hub-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid rgba(0, 240, 255, 0.2);
  font-size: 0.92rem;
  font-weight: 600;
}
#hubChat .hub-chat-head button {
  background: transparent;
  border: 0;
  color: #8b9bb8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
}
#hubChat .hub-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 140px;
}
#hubChat .hub-msg {
  max-width: 92%;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.45;
  word-break: break-word;
}
#hubChat .hub-msg.user,
#hubChat .hub-msg.system {
  white-space: pre-wrap;
}
#hubChat .hub-msg.user {
  align-self: flex-end;
  background: rgba(0, 240, 255, 0.18);
  border: 1px solid rgba(0, 240, 255, 0.3);
}
#hubChat .hub-msg.assistant {
  align-self: flex-start;
  background: rgba(180, 77, 255, 0.15);
  border: 1px solid rgba(180, 77, 255, 0.28);
  white-space: normal;
}
#hubChat .hub-msg.assistant > :first-child { margin-top: 0; }
#hubChat .hub-msg.assistant > :last-child { margin-bottom: 0; }
#hubChat .hub-msg.assistant p { margin: 0.35em 0; }
#hubChat .hub-msg.assistant ul,
#hubChat .hub-msg.assistant ol {
  margin: 0.35em 0;
  padding-left: 1.3em;
}
#hubChat .hub-msg.assistant li { margin: 0.15em 0; }
#hubChat .hub-msg.assistant pre {
  margin: 0.4em 0;
  padding: 0.45em 0.55em;
  overflow-x: auto;
  max-width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  font-size: 0.8em;
}
#hubChat .hub-msg.assistant code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.28);
  padding: 0.1em 0.3em;
  border-radius: 4px;
}
#hubChat .hub-msg.assistant pre code {
  background: transparent;
  padding: 0;
}
#hubChat .hub-msg.assistant a {
  color: #7ef0ff;
  text-decoration: underline;
}
#hubChat .hub-msg.assistant h1,
#hubChat .hub-msg.assistant h2,
#hubChat .hub-msg.assistant h3 {
  margin: 0.45em 0 0.25em;
  font-weight: 650;
  line-height: 1.3;
}
#hubChat .hub-msg.assistant h1 { font-size: 1.05em; }
#hubChat .hub-msg.assistant h2 { font-size: 1em; }
#hubChat .hub-msg.assistant h3 { font-size: 0.95em; }
#hubChat .hub-msg.assistant blockquote {
  margin: 0.35em 0;
  padding-left: 0.6em;
  border-left: 2px solid rgba(180, 77, 255, 0.45);
  color: #b8c4d8;
}
#hubChat .hub-msg.system {
  align-self: center;
  color: #8b9bb8;
  font-size: 0.78rem;
  background: transparent;
  border: 0;
}
#hubChat .hub-chat-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(0, 240, 255, 0.18);
}
#hubChat .hub-chat-form input[type="text"],
#hubChat .hub-chat-form input[type="password"] {
  flex: 1;
  min-width: 0;
  background: rgba(5, 6, 15, 0.8);
  border: 1px solid rgba(139, 155, 184, 0.35);
  border-radius: 8px;
  color: #e8f0ff;
  padding: 0.45rem 0.55rem;
  font-size: 16px;
}
#hubChat .hub-chat-form button {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.35), rgba(180, 77, 255, 0.4));
  border: 1px solid rgba(0, 240, 255, 0.45);
  color: #e8f0ff;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 0.86rem;
  cursor: pointer;
  white-space: nowrap;
}
#hubChat .hub-chat-form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
@media (max-width: 520px) {
  #hubChat {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: min(55vh, 420px);
    border-radius: 14px 14px 0 0;
  }
  #hubBit {
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
  }
}
