/* The chat module's button and panel. Every class starts with kc-. Colours: set --kc-accent and the
   others on .kc-root in the host's own CSS to match another site. */
.kc-root {
  --kc-accent: #c6613f;
  --kc-accent-dark: #a94f32;
  --kc-accent-light: #e8946b;
  --kc-accent-soft: #f7ebe4;
  --kc-grad: linear-gradient(135deg, var(--kc-accent-light) 0%, var(--kc-accent) 55%, #8e3f27 100%);
  --kc-ink: #141413;
  --kc-muted: #5e5d59;
  --kc-line: #e3dfd3;
  --kc-bg: #faf9f5;
  --kc-card: #fff;
  --kc-ok: #2f9e5b;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
  color: var(--kc-ink);
}
.kc-root *, .kc-root *::before, .kc-root *::after { box-sizing: border-box; }

/* The face: a sparkle on the brand gradient. */
.kc-av { display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--kc-grad); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.kc-av svg { width: 72%; height: 72%; }
.kc-av--sm { width: 26px; height: 26px; margin-top: 2px; }
.kc-av--lg { width: 40px; height: 40px; }

/* The button that opens it: a round face, its name beside it on hover. */
.kc-open {
  position: fixed; right: 20px; bottom: 20px; z-index: 95;
  display: grid; place-items: center;
  width: 58px; height: 58px; padding: 0; border: 0; border-radius: 50%;
  background: var(--kc-grad); color: #fff; font: inherit; cursor: pointer;
  box-shadow: 0 10px 28px -8px rgba(198,97,63,.75), 0 0 0 0 rgba(198,97,63,.35);
  animation: kcGlow 3.2s ease-in-out 1.5s infinite;
  transition: transform .2s, filter .2s, translate .25s ease-out, opacity .2s, scale .2s;
}
.kc-open:hover { filter: brightness(1.06); transform: scale(1.05); animation-play-state: paused; }
.kc-open .kc-av--btn { width: 100%; height: 100%; background: transparent; box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.kc-open .kc-av--btn svg { width: 62%; height: 62%; animation: kcTwinkle 3.2s ease-in-out 1.5s infinite; }
.kc-tip { position: absolute; right: calc(100% + 10px); top: 50%; transform: translate(6px, -50%); padding: 6px 11px; border-radius: 8px; background: var(--kc-ink); color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s, transform .15s; }
.kc-open:hover .kc-tip, .kc-open:focus-visible .kc-tip { opacity: 1; transform: translate(0, -50%); }
@keyframes kcGlow { 0%, 70%, 100% { box-shadow: 0 10px 28px -8px rgba(198,97,63,.75), 0 0 0 0 rgba(198,97,63,.35); } 35% { box-shadow: 0 10px 28px -8px rgba(198,97,63,.75), 0 0 0 10px rgba(198,97,63,0); } }
@keyframes kcTwinkle { 0%, 70%, 100% { transform: scale(1) rotate(0); } 35% { transform: scale(1.12) rotate(12deg); } }
.kc-open:focus-visible, .kc-panel button:focus-visible, .kc-panel a:focus-visible, .kc-panel input:focus-visible { outline: 2px solid var(--kc-accent); outline-offset: 2px; }
.kc-open:focus-visible { outline-color: var(--kc-ink); }
.kc-root.is-open .kc-open { display: none; }
.kc-open.kc-away { opacity: 0; scale: .6; pointer-events: none; }

/* The panel. */
.kc-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 1000;
  display: none; flex-direction: column; margin: 0; padding: 0;
  width: 390px; max-width: calc(100vw - 40px); height: 590px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
  background: var(--kc-bg); border: 1px solid var(--kc-line); border-radius: 20px; overflow: hidden;
  box-shadow: 0 30px 70px -24px rgba(20,20,19,.45), 0 0 0 1px rgba(198,97,63,.06);
}
.kc-root.is-open .kc-panel { display: flex; animation: kcIn .25s cubic-bezier(.2,.8,.2,1) both; transform-origin: bottom right; }
@keyframes kcIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.kc-head { position: relative; display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 14px; background: linear-gradient(180deg, var(--kc-accent-soft), var(--kc-card)); border-bottom: 1px solid var(--kc-line); }
.kc-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, transparent, var(--kc-accent-light), var(--kc-accent), transparent); opacity: .55; }
.kc-who { flex: 1; display: flex; align-items: center; gap: 11px; min-width: 0; }
.kc-face { position: relative; display: inline-flex; }
.kc-dot { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: var(--kc-ok); border: 2px solid var(--kc-card); }
.kc-dot::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--kc-ok); opacity: 0; animation: kcPing 2.4s ease-out infinite; }
@keyframes kcPing { 0% { transform: scale(.7); opacity: .6; } 100% { transform: scale(1.9); opacity: 0; } }
.kc-head h2 { margin: 0; font-family: inherit; font-size: 17px; font-weight: 650; letter-spacing: 0; color: var(--kc-ink); line-height: 1.15; }
.kc-head h2 small { display: block; font-size: 12.5px; font-weight: 400; color: var(--kc-muted); margin-top: 2px; }
.kc-close { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--kc-muted); cursor: pointer; }
.kc-close:hover { background: rgba(20,20,19,.06); color: var(--kc-ink); }
.kc-close svg { width: 18px; height: 18px; }
.kc-tools { display: flex; gap: 2px; margin-left: auto; }
.kc-clear { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; border: 1px solid var(--kc-line); border-radius: 16px; background: var(--kc-card); color: var(--kc-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.kc-clear:hover { color: var(--kc-ink); border-color: var(--kc-muted); }
.kc-clear svg { width: 14px; height: 14px; }
.kc-tools { align-items: center; gap: 6px; }

/* The talk. */
.kc-log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.kc-row { display: flex; align-items: flex-start; gap: 8px; max-width: 92%; }
.kc-msg { padding: 10px 13px; border-radius: 16px; font-size: 15px; overflow-wrap: anywhere; }
.kc-msg p { margin: 0; }
.kc-msg p + p { margin-top: 8px; }
.kc-bot { background: var(--kc-card); border: 1px solid var(--kc-line); border-top-left-radius: 5px; box-shadow: 0 1px 2px rgba(20,20,19,.04); }
.kc-bot.is-typing p:last-of-type::after, .kc-bot.is-typing:not(:has(p:last-of-type))::after { content: ""; display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--kc-accent); animation: kcCaret .8s steps(2) infinite; }
@keyframes kcCaret { 50% { opacity: 0; } }
.kc-me { align-self: flex-end; max-width: 85%; background: var(--kc-ink); color: #fff; border-top-right-radius: 5px; }
.kc-bot a { color: var(--kc-accent-dark); text-decoration: underline; text-underline-offset: 2px; }
.kc-more { display: inline-block; margin-top: 8px; font-weight: 600; }

.kc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; padding-left: 34px; }
.kc-chip { padding: 7px 12px; border: 1px solid var(--kc-line); border-radius: 18px; background: var(--kc-card); color: var(--kc-ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.kc-chip::before { content: "✦ "; color: var(--kc-accent); font-size: 11px; }
.kc-chip:hover { border-color: var(--kc-accent); background: var(--kc-accent-soft); }
.kc-act { display: inline-block; padding: 8px 14px; border-radius: 10px; background: var(--kc-grad); color: #fff !important; font-size: 14px; font-weight: 600; text-decoration: none !important; }
.kc-act:hover { filter: brightness(1.06); }
.kc-act + .kc-act { background: var(--kc-card); color: var(--kc-ink) !important; border: 1px solid var(--kc-line); }
.kc-act + .kc-act:hover { border-color: var(--kc-accent); filter: none; }

.kc-typing { display: flex; align-items: center; gap: 4px; padding: 11px 14px; background: var(--kc-card); border: 1px solid var(--kc-line); border-radius: 16px; border-top-left-radius: 5px; }
.kc-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--kc-accent); animation: kcDot 1s infinite ease-in-out; }
.kc-typing i:nth-child(2) { animation-delay: .15s; }
.kc-typing i:nth-child(3) { animation-delay: .3s; }
.kc-typing span { margin-left: 6px; font-size: 13px; color: var(--kc-muted); background: linear-gradient(90deg, var(--kc-muted) 30%, var(--kc-accent-light) 50%, var(--kc-muted) 70%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: kcShine 1.6s linear infinite; }
@keyframes kcDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes kcShine { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* The form for a call. */
.kc-form { align-self: stretch; display: grid; gap: 8px; margin-left: 34px; padding: 12px; background: var(--kc-card); border: 1px solid var(--kc-line); border-radius: 14px; }
.kc-follow { margin: 0 0 2px; font-size: 14px; color: var(--kc-ink); }
.kc-form label { display: grid; gap: 3px; font-size: 13px; font-weight: 600; color: var(--kc-ink); }
.kc-form input { width: 100%; height: 40px; padding: 0 11px; border: 1px solid var(--kc-line); border-radius: 9px; background: #fff; color: var(--kc-ink); font: inherit; font-size: 15px; font-weight: 400; }
.kc-form input:focus { border-color: var(--kc-accent); box-shadow: 0 0 0 3px var(--kc-accent-soft); outline: 0; }
.kc-form .kc-bad input { border-color: #b3261e; }
.kc-form .kc-err { font-size: 12.5px; font-weight: 400; color: #b3261e; }
.kc-form button { height: 42px; border: 0; border-radius: 10px; background: var(--kc-grad); color: #fff; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; }
.kc-form button:hover { filter: brightness(1.06); }
.kc-form button[disabled] { opacity: .6; cursor: default; }
.kc-form .kc-note { margin: 0; font-size: 12.5px; color: var(--kc-muted); }
.kc-form.is-folded { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; background: var(--kc-accent-soft); border-color: transparent; }
.kc-form.is-folded .kc-follow { flex: 1 1 100%; margin: 0; font-size: 13.5px; }
.kc-form.is-folded > label, .kc-form.is-folded > button[type="submit"], .kc-form.is-folded > .kc-note { display: none; }
.kc-form .kc-yes { height: 34px; padding: 0 14px; font-size: 14px; }
.kc-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* Where the question is typed. */
.kc-foot { padding: 10px 12px 10px; background: var(--kc-card); border-top: 1px solid var(--kc-line); }
.kc-ask { display: flex; gap: 6px; padding: 4px; border-radius: 16px; background: var(--kc-line); background: linear-gradient(var(--kc-line), var(--kc-line)); transition: background .2s; }
.kc-ask:focus-within { background: linear-gradient(120deg, var(--kc-accent-light), var(--kc-accent), #8e3f27); }
.kc-ask input { flex: 1; min-width: 0; height: 42px; padding: 0 12px; border: 0; border-radius: 12px; background: #fff; color: var(--kc-ink); font: inherit; font-size: 15px; }
.kc-ask input:focus { outline: 0; }
.kc-ask button { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border: 0; border-radius: 12px; background: var(--kc-grad); color: #fff; cursor: pointer; }
.kc-ask button:hover { filter: brightness(1.08); }
.kc-ask button svg { width: 18px; height: 18px; }
.kc-person { display: block; margin: 7px auto 0; padding: 2px 6px; border: 0; background: none; color: var(--kc-muted); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.kc-person:hover { color: var(--kc-ink); }

@media (max-width: 479px) {
  .kc-open { right: 14px; bottom: 14px; width: 54px; height: 54px; }
  .kc-tip { display: none; }
  .kc-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; border-radius: 0; border: 0; }
  .kc-ask input, .kc-form input { font-size: 16px; } /* no zoom on iPhone */
}
@media (prefers-reduced-motion: reduce) {
  .kc-open, .kc-open .kc-av--btn svg, .kc-dot::after, .kc-typing i, .kc-typing span { animation: none; }
  .kc-root.is-open .kc-panel { animation: none; }
  .kc-typing span { color: var(--kc-muted); background: none; }
}
@media print { .kc-root { display: none !important; } }

/* Phones: controls big enough for a thumb (about 40px). */
@media (pointer: coarse) {
  .kc-close { width: 42px; height: 42px; }
  .kc-clear { height: 40px; padding: 0 14px; border-radius: 20px; }
  .kc-person { padding: 10px 12px; }
}
