/* Floating public chat widget for the main page */
#blk-launcher {
  position: fixed !important;
  right: 24px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 10003 !important;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #e338ec;
  border: none;
  box-shadow: 0 4px 16px rgba(227, 56, 236, 0.35);
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: transform 120ms ease, box-shadow 120ms ease;
  color: #fff;
  padding: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto !important;
  transform: translateZ(0);
  will-change: transform;
}
#blk-launcher:hover { transform: scale(1.08); box-shadow: 0 8px 24px rgba(227, 56, 236, 0.45); }
#blk-launcher:active { transform: scale(0.97); }
#blk-launcher.hidden { display: none; }
#blk-launcher svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#blk-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10004;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 48px);
  display: none;
  flex-direction: column;
  background: #170618;
  border: 2px solid #e338ec;
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  font-family: inherit;
}
#blk-widget.open { display: flex; }

#blk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #e338ec;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
#blk-close {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}

#blk-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.blk-msg {
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.3;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.blk-msg.user { align-self: flex-end; background: rgba(255, 255, 255, 0.25); color: #fff; border-bottom-right-radius: 4px; }
.blk-msg.bot { align-self: flex-start; background: #ff98c5; color: #000; border-bottom-left-radius: 4px; }
.blk-msg.error { align-self: flex-start; background: rgba(255, 80, 80, 0.15); color: #ffb3b3; border: 1px solid rgba(255, 80, 80, 0.4); }

#blk-typing {
  align-self: flex-start;
  max-width: 72%;
  display: none;
  align-items: center;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #ff98c5;
  color: #000;
  font-size: 13px;
}
#blk-typing .blk-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #000;
  animation: blk-blink 1.2s infinite ease-in-out;
}
#blk-typing .blk-dot:nth-child(2) { animation-delay: 0.2s; }
#blk-typing .blk-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blk-blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

#blk-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
#blk-input {
  flex: 1;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  resize: none;
  font-family: inherit;
}
#blk-input:focus { outline: none; border-color: #e338ec; }
#blk-input::placeholder { color: rgba(255, 255, 255, 0.5); }
#blk-input:disabled { opacity: 0.6; cursor: not-allowed; }
#blk-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  background-color: #e338ec;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  padding: 0;
  color: #fff;
  transition: background 0.2s ease;
}
#blk-send svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#blk-send:hover { background-color: #9e00b3; }
#blk-send:disabled { opacity: 0.6; cursor: not-allowed; }

@media (max-width: 480px) {
  #blk-launcher { right: 16px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; width: 48px; height: 48px; display:flex !important; }
  #blk-widget { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important; width: calc(100vw - 32px); height: calc(100vh - 64px); }
}

@media (max-height: 500px) and (orientation: landscape) {
  #blk-launcher { right: 12px; bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important; width: 42px; height: 42px; display:flex !important; }
  #blk-launcher svg { width: 20px; height: 20px; }
  #blk-widget { right: 12px; bottom: 12px !important; width: calc(100vw - 24px); height: calc(100vh - 36px); border-radius: 14px; }
  #blk-header { padding: 8px 12px !important; font-size: 13px !important; }
  #blk-messages { padding: 8px !important; }
  .blk-msg { padding: 8px 10px !important; font-size: 13px !important; }
  #blk-input-row { padding: 8px !important; }
  #blk-input { padding: 8px 10px !important; font-size: 13px !important; }
  #blk-send { width: 38px; height: 38px; }
  #blk-send svg { width: 16px; height: 16px; }
}