/* =============================================================================
   Site chat widget.

   Rides on four different skins — the dark landing, two light product pages and
   a dark industrial one — so it brings its own palette instead of inheriting
   one. The only thing it borrows from the page is the accent, and only when the
   page offers one.
   ========================================================================== */

.ktc {
  --ktc-accent: var(--kt-accent, #F94803);
  --ktc-panel: #17171C;
  --ktc-panel-2: #1F1F26;
  --ktc-ink: #EDEDEF;
  --ktc-mut: #A8A8B3;              /* 7.4:1 on --ktc-panel */
  --ktc-line: rgba(255, 255, 255, .12);
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  font-family: 'Manrope', 'Helvetica Neue', system-ui, sans-serif;
}

/* The launcher takes the corner, so whatever else lives there steps up: the
   product pages' back-to-top, and the landing's theme panel toggle. */
html.ktc-ready [data-top],
html.ktc-ready .kt-theme-toggle { bottom: 84px; }

/* ---------- Launcher ------------------------------------------------------ */
.ktc__open {
  display: flex; align-items: center; gap: 9px;
  /* The label is a sentence now, and before Manrope arrives it is set in a
     wider fallback — enough to push the pill off a 320px screen. Bounding it
     to the container makes the text wrap instead of overflowing. */
  max-width: 100%;
  min-height: 52px; padding: 12px 20px 12px 17px;
  text-align: left;
  line-height: 1.25;
  border: 0; border-radius: 999px;
  background: var(--ktc-accent); color: #FFF;
  font: 800 14px/1 'Manrope', system-ui, sans-serif;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .3);
  cursor: pointer;
  transition: transform .25s, filter .25s;
}
.ktc__open:hover { transform: translateY(-2px); filter: brightness(1.07); }
.ktc__open svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.ktc__open span { min-width: 0; }
.ktc[data-open="true"] .ktc__open { display: none; }

/* ---------- Panel --------------------------------------------------------- */
.ktc__panel {
  display: none;
  flex-direction: column;
  width: min(384px, calc(100vw - 36px));
  height: min(560px, calc(100vh - 120px));
  border: 1px solid var(--ktc-line);
  border-radius: 20px;
  background: var(--ktc-panel);
  color: var(--ktc-ink);
  box-shadow: 0 26px 70px rgba(0, 0, 0, .45);
  overflow: hidden;
}
.ktc[data-open="true"] .ktc__panel { display: flex; animation: ktc-in .28s cubic-bezier(.22, .66, .22, 1); }
@keyframes ktc-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.ktc__head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 14px 14px 17px;
  border-bottom: 1px solid var(--ktc-line);
}
.ktc__dot { width: 8px; height: 8px; border-radius: 50%; background: #2FBF6B; flex: none; }
.ktc__title { font-size: 14px; font-weight: 800; }
.ktc__sub { font-size: 11.5px; color: var(--ktc-mut); }
.ktc__close {
  margin-left: auto; width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--ktc-line); border-radius: 10px;
  background: transparent; color: var(--ktc-mut);
  font-size: 17px; line-height: 1; cursor: pointer;
  transition: color .2s, border-color .2s;
}
.ktc__close:hover { color: var(--ktc-ink); border-color: var(--ktc-accent); }

.ktc__log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.ktc__msg { max-width: 88%; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.ktc__msg--bot { align-self: flex-start; color: var(--ktc-ink); }
.ktc__msg--me {
  align-self: flex-end;
  padding: 10px 14px; border-radius: 14px 14px 4px 14px;
  background: var(--ktc-accent); color: #FFF; font-weight: 600;
}
.ktc__msg a { color: var(--ktc-accent); text-decoration: underline; }
.ktc__msg--err { color: #FF9A8B; font-size: 13px; }

/* Three dots while the first token is still in flight. */
.ktc__wait { display: inline-flex; gap: 4px; padding: 4px 0; }
.ktc__wait i { width: 6px; height: 6px; border-radius: 50%; background: var(--ktc-mut); animation: ktc-blink 1.2s infinite; }
.ktc__wait i:nth-child(2) { animation-delay: .18s; }
.ktc__wait i:nth-child(3) { animation-delay: .36s; }
@keyframes ktc-blink { 0%, 60%, 100% { opacity: .28; } 30% { opacity: 1; } }

.ktc__seeds { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 12px; }
.ktc__seed {
  border: 1px solid var(--ktc-line); border-radius: 999px;
  padding: 8px 13px; background: var(--ktc-panel-2); color: var(--ktc-mut);
  font: 600 12.5px/1.3 'Manrope', system-ui, sans-serif; text-align: left; cursor: pointer;
  transition: color .2s, border-color .2s;
}
.ktc__seed:hover { color: var(--ktc-ink); border-color: var(--ktc-accent); }

.ktc__form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--ktc-line); }
.ktc__input {
  flex: 1; min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--ktc-line); border-radius: 12px;
  background: var(--ktc-panel-2); color: var(--ktc-ink);
  font: 400 16px/1.4 'Manrope', system-ui, sans-serif;   /* 16px or iOS zooms the page in */
  resize: none; max-height: 96px;
}
.ktc__input::placeholder { color: var(--ktc-mut); }
.ktc__input:focus { outline: none; border-color: var(--ktc-accent); }
.ktc__send {
  flex: none; width: 46px; border: 0; border-radius: 12px;
  background: var(--ktc-accent); color: #FFF; font-size: 17px; cursor: pointer;
  transition: filter .2s;
}
.ktc__send:hover { filter: brightness(1.08); }
.ktc__send:disabled { opacity: .45; cursor: default; }

.ktc__foot { padding: 0 14px 11px; font-size: 10.5px; color: var(--ktc-mut); text-align: center; }

/* On a phone the panel is the screen, not a card floating over it. */
@media (max-width: 560px) {
  .ktc { right: 12px; bottom: 12px; left: 12px; }
  .ktc__open { margin-left: auto; }
  .ktc__panel { width: 100%; height: min(78vh, calc(100vh - 90px)); }
}

@media (prefers-reduced-motion: reduce) {
  .ktc *, .ktc *::before, .ktc *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
.kt-no-motion .ktc *, .kt-no-motion .ktc *::before, .kt-no-motion .ktc *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}

@media (pointer: coarse) {
  .ktc__seed, .ktc__close { min-height: 44px; }
}
