.kb { position: fixed; z-index: 70; right: 1rem; bottom: 1rem; }
.kb.is-positioned { right: auto; bottom: auto; }

.kb-launcher { position: relative; display: flex; width: 112px; height: 112px; align-items: flex-end; justify-content: center; background: transparent; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.kb-launcher:active { cursor: grabbing; }
.kb-launcher.is-tracing { cursor: default; }
.kb-launcher .kriyon-mascot-presence { position: relative; z-index: 1; display: flex; width: 108px; height: 108px; align-items: flex-end; justify-content: center; }
.kb-launcher .kriyon-mascot-beaver { width: 106px; height: 106px; object-fit: contain; filter: drop-shadow(0 12px 10px rgba(72, 19, 38, 0.22)); -webkit-user-drag: none; }

.kb-tip { position: absolute; top: 1.5rem; left: -4.6rem; padding: 0.4rem 0.75rem; border: 1px solid var(--border); border-radius: 999px; background: var(--pearl); box-shadow: 0 10px 28px -16px rgba(72, 19, 38, 0.5); color: var(--burgundy); font-size: 0.75rem; font-weight: 700; white-space: nowrap; }
.kb-tip::after { position: absolute; top: 50%; right: -0.38rem; width: 0.75rem; height: 0.75rem; border-top: 1px solid var(--border); border-right: 1px solid var(--border); background: var(--pearl); content: ""; transform: translateY(-50%) rotate(45deg); }
.kb.is-open .kb-tip, .kb-launcher.is-tracing .kb-tip { display: none; }

.kb-panel { position: fixed; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--border); border-radius: 26px; background: var(--pearl); box-shadow: 0 24px 70px -24px rgba(72, 19, 38, 0.48); }
.kb-panel[hidden] { display: none; }

.kb-head { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; background: var(--burgundy-dark); color: var(--pearl); }
.kb-head__avatar { display: flex; width: 3rem; height: 3rem; flex: none; align-items: center; justify-content: center; overflow: hidden; border-radius: 999px; background: var(--ivory); box-shadow: 0 0 0 2px rgba(252, 250, 247, 0.2); }
.kb-head__avatar img { width: 2.75rem; height: 2.75rem; object-fit: contain; }
.kb-head__text { min-width: 0; flex: 1; }
.kb-head__title { color: var(--pearl); font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.kb-head__status { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.15rem; color: rgba(252, 250, 247, 0.7); font-size: 0.75rem; }
.kb-head__status::before { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: #75c99a; content: ""; }
.kb-iconbtn { display: inline-flex; min-width: 2.25rem; height: 2.25rem; align-items: center; justify-content: center; padding-inline: 0.5rem; border-radius: 999px; color: rgba(252, 250, 247, 0.8); font-size: 0.72rem; font-weight: 700; transition: background 160ms ease; }
.kb-iconbtn:hover { background: rgba(252, 250, 247, 0.12); color: var(--pearl); }

.kb-messages { display: flex; flex: 1; flex-direction: column; gap: 0.85rem; overflow-y: auto; padding: 1.1rem 1rem; background: rgba(246, 242, 236, 0.7); overscroll-behavior: contain; }
.kb-msg { display: flex; }
.kb-msg--user { justify-content: flex-end; }
.kb-msg p { max-width: 86%; padding: 0.7rem 1rem; border-radius: 1rem; box-shadow: 0 1px 2px rgba(39, 35, 38, 0.06); font-size: 0.875rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.kb-msg--assistant p { border: 1px solid var(--border); border-bottom-left-radius: 0.3rem; background: var(--pearl); }
.kb-msg--user p { border-bottom-right-radius: 0.3rem; background: var(--burgundy); color: var(--pearl); }
.kb-msg--error p { border-color: #e7c4c4; color: var(--error); }

.kb-suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.kb-suggestions button { padding: 0.5rem 0.8rem; border: 1px solid var(--burgundy-soft); border-radius: 999px; background: var(--pearl); color: var(--burgundy); font-size: 0.75rem; font-weight: 700; text-align: left; transition: background 160ms ease; }
.kb-suggestions button:hover { background: var(--burgundy-tint); }

.kb-typing { display: flex; gap: 0.25rem; width: fit-content; padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: 1rem; border-bottom-left-radius: 0.3rem; background: var(--pearl); }
.kb-typing span { width: 0.4rem; height: 0.4rem; border-radius: 999px; background: var(--burgundy-soft); animation: kb-pulse 1s ease-in-out infinite; }
.kb-typing span:nth-child(2) { animation-delay: 0.15s; }
.kb-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes kb-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.kb-form { padding: 0.75rem; border-top: 1px solid var(--border); background: var(--pearl); }
.kb-form__row { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 1rem; background: var(--ivory); }
.kb-form__row:focus-within { border-color: var(--burgundy-soft); box-shadow: 0 0 0 3px rgba(108, 31, 61, 0.06); }
.kb-form textarea { flex: 1; min-height: 2.5rem; max-height: 6rem; padding: 0.55rem 0.25rem; border: 0; background: transparent; font-size: 1rem; outline: none; resize: none; }
.kb-form textarea:focus-visible { outline: none; }
.kb-form__send { display: flex; width: 2.5rem; height: 2.5rem; flex: none; align-items: center; justify-content: center; border-radius: 0.75rem; background: var(--burgundy); color: var(--pearl); transition: background 160ms ease; }
.kb-form__send:hover { background: var(--burgundy-dark); }
.kb-form__send:disabled { cursor: not-allowed; opacity: 0.4; }
.kb-form__note { margin-top: 0.5rem; color: var(--muted-foreground); font-size: 0.65rem; text-align: center; }

@media (max-width: 640px) {
  .kb { right: 0.5rem; bottom: 0.5rem; }
  .kb-launcher { width: 88px; height: 88px; }
  .kb-launcher .kriyon-mascot-presence { width: 84px; height: 84px; }
  .kb-launcher .kriyon-mascot-beaver { width: 82px; height: 82px; }
  .kb-tip { display: none; }
  .kriyon-mascot-walk-sprite { width: 81px; height: 84px; }
}
