/* Knowxis support widget — purple Goftino-like */
:root {
  --kx-chat-accent: #6d28d9;
  --kx-chat-accent-2: #5b21b6;
  --kx-chat-ink: #1f1633;
  --kx-chat-muted: #6b6280;
  --kx-chat-panel: #ffffff;
  --kx-chat-shadow: 0 18px 48px rgba(76, 29, 149, .16);
  --kx-chat-radius: 22px;
}

.kx-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99970;
  background: rgba(20, 12, 40, .28);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .22s ease, visibility .22s ease;
}
.kx-chat-backdrop.is-on {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.kx-chat-launcher-wrap {
  position: fixed;
  z-index: 99980;
  right: 18px;
  left: auto;
  bottom: 22px;
  width: 58px;
  height: 58px;
}
.kx-chat-launcher {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(109, 40, 217, .18);
  border-radius: 18px;
  padding: 0;
  cursor: pointer;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(31, 22, 51, .16);
  display: grid;
  place-items: center;
  overflow: visible;
  transition: transform .18s ease, box-shadow .18s ease;
}
.kx-chat-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 5px 12px rgba(31, 22, 51, .2);
}
.kx-chat-launcher:active {
  transform: translateY(0) scale(1);
  box-shadow: 0 2px 5px rgba(31, 22, 51, .14);
}
.kx-chat-launcher.is-open {
  box-shadow: 0 3px 8px rgba(31, 22, 51, .16);
}
/* bottom-right: only the curved corner stroke (not a triangle/L) */
.kx-chat-launcher::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #86efac 0%, #22c55e 50%, #15803d 100%);
  /* ring arc centered at top-left of this box = button corner curve */
  -webkit-mask-image: radial-gradient(
    circle 18px at 0 0,
    transparent 0,
    transparent 14.2px,
    #000 14.7px,
    #000 17.2px,
    transparent 17.8px
  );
  mask-image: radial-gradient(
    circle 18px at 0 0,
    transparent 0,
    transparent 14.2px,
    #000 14.7px,
    #000 17.2px,
    transparent 17.8px
  );
  pointer-events: none;
  z-index: 2;
}
.kx-chat-launcher__img {
  width: 72%;
  height: 72%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  background: transparent;
  filter: none;
}
.kx-chat-launcher__pulse { display: none !important; }
.kx-chat-launcher__badge {
  position: absolute;
  top: -2px;
  left: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font: 700 10px/20px Vazirmatn, Tahoma, sans-serif;
  display: none;
  box-shadow: 0 2px 6px rgba(225, 29, 72, .35);
  z-index: 2;
}
.kx-chat-launcher__badge.is-on { display: grid; place-items: center; }

.kx-chat-panel {
  position: fixed;
  z-index: 99990;
  right: 18px;
  left: auto;
  bottom: max(18px, 5vh);
  width: min(400px, calc(100vw - 28px));
  height: 90vh;
  height: 90dvh;
  max-height: 90dvh;
  background: var(--kx-chat-panel);
  border-radius: var(--kx-chat-radius);
  overflow: hidden;
  box-shadow: var(--kx-chat-shadow);
  display: none;
  flex-direction: column;
  border: 1px solid rgba(124, 58, 237, .12);
}
.kx-chat-panel.is-open { display: flex; animation: kx-chat-pop .26s cubic-bezier(.2,.8,.2,1); }
@keyframes kx-chat-pop {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.kx-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px 15px;
  background:
    radial-gradient(circle at 88% 0%, rgba(255,255,255,.22), transparent 42%),
    linear-gradient(135deg, #7c3aed, #6d28d9 52%, #5b21b6);
  color: #fff;
  flex-shrink: 0;
}
.kx-chat-head img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  padding: 0;
  border: 2px solid rgba(255,255,255,.55);
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.kx-chat-head__meta { flex: 1; min-width: 0; }
.kx-chat-head__meta strong {
  display: block;
  font: 800 14.5px/1.3 Vazirmatn, Tahoma, sans-serif;
  letter-spacing: -.01em;
}
.kx-chat-head__meta span {
  display: block;
  opacity: .92;
  font: 500 12px/1.45 Vazirmatn, Tahoma, sans-serif;
  margin-top: 2px;
}
.kx-chat-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font: 600 11px/1 Vazirmatn, Tahoma, sans-serif;
  padding: 4px 8px 4px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
}
.kx-chat-online i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #86efac;
  box-shadow: 0 0 0 3px rgba(134, 239, 172, .28);
}
.kx-chat-close {
  border: 0;
  background: rgba(255,255,255,.16);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: background .15s ease;
}
.kx-chat-close:hover { background: rgba(255,255,255,.26); }

.kx-chat-gate {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 28px 22px;
  background:
    radial-gradient(circle at 14% 12%, rgba(109,40,217,.1), transparent 40%),
    radial-gradient(circle at 90% 88%, rgba(91,33,182,.08), transparent 38%),
    linear-gradient(180deg, #fbf9ff, #f5f1ff);
}
.kx-chat-gate.is-on { display: flex; }
.kx-chat-gate__mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 4px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #7c3aed, #5b21b6);
  color: #fff;
  box-shadow: 0 10px 24px rgba(109, 40, 217, .28);
}
.kx-chat-gate__mark svg { width: 26px; height: 26px; }
.kx-chat-gate h3 {
  margin: 0;
  font: 800 18px/1.35 Vazirmatn, Tahoma, sans-serif;
  color: var(--kx-chat-ink);
  text-align: center;
}
.kx-chat-gate p {
  margin: 0;
  text-align: center;
  color: var(--kx-chat-muted);
  font: 500 13px/1.7 Vazirmatn, Tahoma, sans-serif;
}
.kx-chat-gate input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #ddd6fe;
  border-radius: 14px;
  padding: 13px 14px;
  font: 600 14px/1.4 Vazirmatn, Tahoma, sans-serif;
  background: #fff;
  color: var(--kx-chat-ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.kx-chat-gate input:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 4px rgba(109, 40, 217, .14);
}
.kx-chat-gate input:-webkit-autofill,
.kx-chat-gate input:-webkit-autofill:hover,
.kx-chat-gate input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--kx-chat-ink);
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 9999s ease-in-out 0s;
  border-color: #a78bfa;
}
.kx-chat-gate button {
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  background: linear-gradient(145deg, var(--kx-chat-accent), var(--kx-chat-accent-2));
  color: #fff;
  font: 800 14px/1.3 Vazirmatn, Tahoma, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(109, 40, 217, .28);
  transition: transform .15s ease, filter .15s ease;
}
.kx-chat-gate button:hover { filter: brightness(1.04); transform: translateY(-1px); }
.kx-chat-gate__err {
  color: #be123c;
  font-size: 12px;
  text-align: center;
  min-height: 1em;
}

.kx-chat-main { display: none; flex: 1; flex-direction: column; min-height: 0; }
.kx-chat-main.is-on { display: flex; }

.kx-chat-body {
  flex: 1;
  overflow: auto;
  padding: 16px 12px;
  background-color: #f3effc;
  background-image:
    radial-gradient(rgba(124, 58, 237, .12) 1.25px, transparent 1.3px),
    radial-gradient(rgba(91, 33, 182, .07) 1px, transparent 1.1px),
    linear-gradient(180deg, rgba(255,255,255,.4), transparent 42%);
  background-size: 14px 14px, 26px 26px, 100% 100%;
  background-position: 0 0, 7px 9px, 0 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.kx-chat-line {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}
.kx-chat-line--visitor { align-self: flex-end; flex-direction: row-reverse; }
.kx-chat-line--agent { align-self: flex-start; flex-direction: row; }
.kx-chat-line--system {
  align-self: center;
  max-width: 92%;
  justify-content: center;
}
.kx-chat-ava {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(76, 29, 149, .12);
  border: 1.5px solid rgba(255,255,255,.9);
}
.kx-chat-msg {
  max-width: min(280px, calc(100vw - 110px));
  padding: 10px 12px 8px;
  border-radius: 16px;
  font: 500 13.5px/1.65 Vazirmatn, Tahoma, sans-serif;
  color: var(--kx-chat-ink);
  box-shadow: 0 2px 8px rgba(76, 29, 149, .06);
  white-space: pre-wrap;
  word-break: break-word;
}
.kx-chat-line--visitor .kx-chat-msg {
  background: linear-gradient(160deg, #efe9ff, #e4dbff);
  border-bottom-left-radius: 5px;
}
.kx-chat-line--agent .kx-chat-msg {
  background: #fff;
  border: 1px solid rgba(124, 58, 237, .1);
  border-bottom-right-radius: 5px;
}
.kx-chat-line--system .kx-chat-msg {
  max-width: 100%;
  background: rgba(255,255,255,.82);
  border: 1px dashed rgba(124, 58, 237, .2);
  color: var(--kx-chat-muted);
  font-size: 12px;
  text-align: center;
  box-shadow: none;
}
.kx-chat-msg time {
  display: block;
  margin-top: 5px;
  font-size: 10px;
  opacity: .5;
  line-height: 1;
}
.kx-chat-msg a.kx-chat-file {
  display: inline-flex;
  gap: 6px;
  margin-top: 6px;
  color: var(--kx-chat-accent-2);
  text-decoration: none;
  font-weight: 700;
}
.kx-chat-msg img.kx-chat-thumb,
.kx-chat-msg video.kx-chat-thumb {
  display: block;
  max-width: 100%;
  border-radius: 12px;
  margin-top: 6px;
}
.kx-chat-msg strong { font-weight: 800; color: inherit; }
.kx-chat-quote {
  margin: 0 0 8px;
  padding: 7px 10px;
  border-radius: 10px;
  border-right: 3px solid var(--kx-chat-accent);
  background: rgba(124, 58, 237, .08);
  color: var(--kx-chat-muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.kx-chat-msg__actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.kx-chat-msg__actions button {
  border: 0;
  background: transparent;
  color: var(--kx-chat-accent-2);
  font: 700 11px/1 Vazirmatn, Tahoma, sans-serif;
  cursor: pointer;
  padding: 2px 0;
  opacity: .72;
}
.kx-chat-msg__actions button:hover { opacity: 1; }
.kx-chat-line--system .kx-chat-msg a {
  color: var(--kx-chat-accent-2);
  font-weight: 800;
  text-decoration: none;
}
.kx-chat-call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto 2px;
  height: 28px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid rgba(109, 40, 217, .28);
  background: #f5f3ff;
  color: var(--kx-chat-accent-2) !important;
  text-decoration: none !important;
  font: 700 11.5px/1 Vazirmatn, Tahoma, sans-serif;
  box-shadow: none;
  width: fit-content;
  max-width: 100%;
}
.kx-chat-call-btn:hover {
  background: #ede9fe;
  border-color: rgba(109, 40, 217, .4);
}
.kx-chat-send {
  position: relative;
  z-index: 3;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.kx-chat-send:disabled {
  opacity: .55;
  pointer-events: none;
}

.kx-chat-typing {
  display: none;
  align-self: flex-start;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
}
.kx-chat-typing.is-on { display: flex; }
.kx-chat-typing__bub {
  background: #fff;
  border: 1px solid rgba(124, 58, 237, .1);
  border-radius: 16px;
  border-bottom-right-radius: 5px;
  padding: 12px 14px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(76, 29, 149, .06);
}
.kx-chat-typing__bub i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a78bfa;
  display: block;
  animation: kx-chat-dot 1.2s ease-in-out infinite;
}
.kx-chat-typing__bub i:nth-child(2) { animation-delay: .15s; }
.kx-chat-typing__bub i:nth-child(3) { animation-delay: .3s; }
.kx-chat-typing__label {
  font: 600 11px/1 Vazirmatn, Tahoma, sans-serif;
  color: var(--kx-chat-muted);
  margin-bottom: 4px;
}
@keyframes kx-chat-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.kx-chat-compose {
  border-top: 1px solid rgba(20, 35, 26, .08);
  background: rgba(255,255,255,.96);
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}
.kx-chat-replybar {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #f5f3ff;
  border: 1px solid rgba(124, 58, 237, .12);
}
.kx-chat-replybar.is-on { display: flex; }
.kx-chat-replybar__txt {
  flex: 1;
  min-width: 0;
  font: 600 12px/1.45 Vazirmatn, Tahoma, sans-serif;
  color: var(--kx-chat-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 3px solid var(--kx-chat-accent);
  padding-right: 8px;
}
.kx-chat-replybar__x {
  border: 0;
  background: transparent;
  color: var(--kx-chat-ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.kx-chat-tools {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.kx-chat-tools button.is-on {
  background: #ddd6fe;
  color: var(--kx-chat-accent-2);
}
.kx-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.kx-chat-row textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  border: 1.5px solid #ddd6fe;
  border-radius: 14px;
  padding: 11px 12px;
  font: 500 13.5px/1.5 Vazirmatn, Tahoma, sans-serif;
  background: #faf8ff;
  color: var(--kx-chat-ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.kx-chat-row textarea:focus {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(109, 40, 217, .12);
  background: #fff;
}
.kx-chat-icon-btn,
.kx-chat-send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform .12s ease, background .12s ease;
}
.kx-chat-icon-btn { background: #f3e8ff; color: var(--kx-chat-ink); font: 800 13px/1 Vazirmatn, Tahoma, sans-serif; }
.kx-chat-icon-btn:hover { background: #ebe0ff; }
.kx-chat-icon-btn--sm { width: 34px; height: 34px; border-radius: 10px; }
.kx-chat-send {
  background: linear-gradient(145deg, var(--kx-chat-accent), var(--kx-chat-accent-2));
  color: #fff;
  box-shadow: 0 8px 16px rgba(109, 40, 217, .25);
}
.kx-chat-send:hover { transform: translateY(-1px); }

.kx-chat-emoji {
  position: fixed;
  z-index: 99995;
  right: 18px;
  left: auto;
  bottom: 170px;
  width: min(320px, calc(100vw - 36px));
  max-height: 180px;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--kx-chat-shadow);
  border: 1px solid rgba(124, 58, 237, .12);
  padding: 8px;
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}
.kx-chat-emoji.is-on { display: grid; }
.kx-chat-emoji button {
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px;
}
.kx-chat-emoji button:hover { background: #f5f3ff; }

/* mobile/tablet shell (.m-tabbar @ max-width:992px): bottom sheet */
@media (max-width: 992px) {
  .kx-chat-launcher-wrap {
    right: 14px;
    left: auto;
    bottom: calc(var(--m-tabbar-h, 52px) + 14px + env(safe-area-inset-bottom, 0px));
    width: 54px;
    height: 54px;
    transition: opacity .2s ease, transform .2s ease, bottom .2s ease;
  }
  /* hide FAB when page footer is on screen */
  .kx-chat-launcher-wrap.is-over-footer {
    opacity: 0;
    pointer-events: none;
    transform: translateY(16px);
  }
  .kx-chat-launcher {
    border-radius: 16px;
  }
  .kx-chat-launcher__img {
    width: 70%;
    height: 70%;
  }
  .kx-chat-launcher-wrap.is-open {
    opacity: 0;
    pointer-events: none;
  }
  .kx-chat-panel {
    inset: auto 0 0 0;
    top: auto;
    right: 0;
    left: 0;
    width: 100%;
    bottom: 0;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 18px 18px 0 0;
    border: 0;
    box-shadow: 0 -10px 40px rgba(76, 29, 149, .2);
    /* keep header+compose fixed; body scrolls */
    overflow: hidden;
  }
  .kx-chat-panel.is-kb {
    border-radius: 0;
  }
  .kx-chat-panel.is-kb .kx-chat-head {
    padding: 8px 12px;
    gap: 8px;
  }
  .kx-chat-panel.is-kb .kx-chat-head img {
    width: 32px;
    height: 32px;
  }
  .kx-chat-panel.is-kb .kx-chat-head__meta span,
  .kx-chat-panel.is-kb .kx-chat-online {
    display: none;
  }
  .kx-chat-panel.is-kb .kx-chat-head__meta strong {
    font-size: 13px;
  }
  .kx-chat-panel.is-kb .kx-chat-compose {
    padding-bottom: 8px;
  }
  .kx-chat-head {
    padding: 12px 12px 11px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .kx-chat-main {
    min-height: 0;
    flex: 1;
  }
  .kx-chat-body {
    padding: 12px;
    min-height: 0;
  }
  .kx-chat-gate { padding: 18px 14px; min-height: 0; overflow: auto; }
  .kx-chat-compose {
    flex-shrink: 0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .kx-chat-panel.is-kb .kx-chat-compose {
    padding-bottom: 8px;
  }
  .kx-chat-emoji {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 380px) {
  .kx-chat-head__meta strong { font-size: 13.5px; }
  .kx-chat-head__meta span { font-size: 11.5px; }
  .kx-chat-msg { font-size: 13px; max-width: 90%; }
  .kx-chat-icon-btn,
  .kx-chat-send { width: 40px; height: 40px; }
  .kx-chat-row textarea { min-height: 42px; font-size: 13px; }
}