/* The assistant in the corner. Dark on every page, including the cream bands. */

.kchat { position: fixed; right: clamp(14px, 2vw, 26px); bottom: clamp(14px, 2vw, 26px); z-index: 300; }
.kchat.with-bar { bottom: 74px; }

/* ---------- the button ---------- */
.kchat-launch {
  position: relative; display: grid; place-items: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--ink-2, #14110e); border: 1px solid var(--gold, #c9a45c);
  color: var(--gold-hi, #e0be7e); cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  transition: transform .35s var(--ease, ease), background .35s, color .35s;
}
.kchat-launch:hover { transform: translateY(-2px); background: var(--gold, #c9a45c); color: #17130f; }
.kchat-launch svg { position: absolute; width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; transition: opacity .25s, transform .25s; }
.kchat-ico-close { opacity: 0; transform: rotate(-45deg); }
.kchat.open .kchat-ico-open { opacity: 0; transform: rotate(45deg); }
.kchat.open .kchat-ico-close { opacity: 1; transform: none; }

/* ---------- the panel ---------- */
.kchat-panel {
  position: absolute; right: 0; bottom: 70px;
  width: min(370px, calc(100vw - 28px)); height: min(520px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--ink, #0b0a09); border: 1px solid var(--line-strong, #2a251f);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  opacity: 0; transform: translateY(10px) scale(.98); transform-origin: bottom right;
  transition: opacity .3s var(--ease, ease), transform .3s var(--ease, ease);
}
.kchat.open .kchat-panel { opacity: 1; transform: none; }
.kchat-panel[hidden] { display: none; }

.kchat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line, #201c18); background: var(--ink-2, #14110e);
}
.kchat-head b { display: block; font: 400 1.15rem/1.2 var(--serif, Georgia, serif); color: var(--bone, #efe9e0); }
.kchat-head span { display: block; margin-top: 3px; font: 500 9px/1 var(--sans, system-ui); letter-spacing: .2em; text-transform: uppercase; color: var(--gold, #c9a45c); }
.kchat-x { position: relative; width: 30px; height: 30px; border: 1px solid var(--line, #201c18); color: var(--muted, #9b9187); background: none; cursor: pointer; flex: none; transition: border-color .3s, color .3s; }
.kchat-x:hover { border-color: var(--gold, #c9a45c); color: var(--gold-hi, #e0be7e); }
.kchat-x::before, .kchat-x::after { content: ''; position: absolute; left: 50%; top: 50%; width: 11px; height: 1px; background: currentColor; }
.kchat-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.kchat-x::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* ---------- messages ---------- */
.kchat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 9px; scroll-behavior: smooth; }
.kchat-msg {
  max-width: 88%; padding: 10px 13px; font: 400 14px/1.6 var(--sans, system-ui);
  animation: kchat-in .32s var(--ease, ease) both;
}
@keyframes kchat-in { from { opacity: 0; transform: translateY(6px); } }
.kchat-msg.bot { align-self: flex-start; background: #15120f; border: 1px solid var(--line, #201c18); color: var(--text, #cfc7bd); }
.kchat-msg.me { align-self: flex-end; background: var(--gold, #c9a45c); color: #17130f; }
.kchat-msg b { color: var(--bone, #efe9e0); font-weight: 500; }
.kchat-msg.me b { color: inherit; }
.kchat-msg a { color: var(--gold-hi, #e0be7e); text-decoration: underline; text-underline-offset: 3px; }
.kchat-msg a:hover { color: var(--bone, #efe9e0); }

.kchat-msg.typing { display: flex; gap: 4px; padding: 13px; }
.kchat-msg.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-dark, #6c655d); animation: kchat-dot 1.1s infinite; }
.kchat-msg.typing i:nth-child(2) { animation-delay: .16s; }
.kchat-msg.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes kchat-dot { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

/* ---------- suggested questions ---------- */
.kchat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.kchat-chip {
  padding: 7px 11px; background: none; border: 1px solid var(--line-strong, #2a251f);
  color: var(--muted, #9b9187); font: 400 12.5px/1.3 var(--sans, system-ui);
  cursor: pointer; text-align: left; transition: border-color .3s, color .3s;
}
.kchat-chip:hover { border-color: var(--gold, #c9a45c); color: var(--gold-hi, #e0be7e); }

/* ---------- the box you type in ---------- */
.kchat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line, #201c18); background: var(--ink-2, #14110e); }
.kchat-form input {
  flex: 1; min-width: 0; padding: 10px 12px; background: #0c0a08;
  border: 1px solid var(--line-strong, #2a251f); color: var(--text, #cfc7bd);
  font: 400 14px/1.4 var(--sans, system-ui); border-radius: 0;
}
.kchat-form input:focus { outline: none; border-color: var(--gold, #c9a45c); }
.kchat-form button {
  display: grid; place-items: center; width: 42px; flex: none;
  background: var(--gold, #c9a45c); border: 0; color: #17130f; cursor: pointer; transition: background .3s;
}
.kchat-form button:hover { background: var(--gold-hi, #e0be7e); }
.kchat-form button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .kchat-panel { height: min(460px, calc(100vh - 120px)); }
}
@media (prefers-reduced-motion: reduce) {
  .kchat-panel, .kchat-launch, .kchat-msg { transition: none; animation: none; }
}

/* ---------- the nudge that pops up beside the button ---------- */
.kchat-nudge {
  position: absolute; right: 68px; bottom: 9px;
  display: flex; align-items: stretch; gap: 0;
  background: var(--ink-2, #14110e); border: 1px solid var(--gold, #c9a45c);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  opacity: 0; transform: translateX(8px) scale(.96); transform-origin: right center;
  transition: opacity .32s var(--ease, ease), transform .32s var(--ease, ease);
  pointer-events: none;
}
.kchat-nudge.show { opacity: 1; transform: none; pointer-events: auto; }
.kchat-nudge[hidden] { display: none; }
/* the little tail pointing at the button */
.kchat-nudge::after {
  content: ''; position: absolute; right: -6px; top: 50%; width: 9px; height: 9px;
  transform: translateY(-50%) rotate(45deg);
  background: var(--ink-2, #14110e);
  border-right: 1px solid var(--gold, #c9a45c); border-top: 1px solid var(--gold, #c9a45c);
}
.kchat-nudge-open {
  padding: 11px 6px 11px 15px; background: none; border: 0; cursor: pointer;
  color: var(--bone, #efe9e0); font: 400 13.5px/1.2 var(--sans, system-ui);
  white-space: nowrap; transition: color .3s;
}
.kchat-nudge-open:hover { color: var(--gold-hi, #e0be7e); }
.kchat-nudge-x {
  position: relative; width: 28px; background: none; border: 0; cursor: pointer;
  color: var(--muted-dark, #6c655d); transition: color .3s;
}
.kchat-nudge-x:hover { color: var(--bone, #efe9e0); }
.kchat-nudge-x::before, .kchat-nudge-x::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 9px; height: 1px; background: currentColor;
}
.kchat-nudge-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.kchat-nudge-x::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* on a phone it sits above the button rather than beside it */
@media (max-width: 480px) {
  .kchat-nudge { right: 0; bottom: 68px; transform: translateY(8px) scale(.96); transform-origin: bottom right; }
  .kchat-nudge.show { transform: none; }
  .kchat-nudge::after { right: 20px; top: auto; bottom: -6px; transform: rotate(135deg); }
  .kchat-nudge-open { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .kchat-nudge { transition: none; } }
