/* Kinvra Assistant chat widget — self-contained, prefixed .ka- */

.ka-root {
  --ka-ink: #1d1d1f;
  --ka-ink-2: #424245;
  --ka-ink-3: #6e6e73;
  --ka-blue: #0071e3;
  --ka-link: #0066cc;
  --ka-grad: conic-gradient(from 200deg, #2997ff, #7a5cff, #ff4fd8, #2997ff);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
}
.ka-root *, .ka-root *::before, .ka-root *::after { box-sizing: border-box; }
.ka-root [hidden] { display: none !important; }

/* launcher */
.ka-launcher {
  position: fixed; right: 22px; bottom: 22px; z-index: 1000;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 10px; border: 0; border-radius: 980px; cursor: pointer;
  background: rgba(29, 29, 31, 0.9); color: #fff;
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  font: 600 15px/1 inherit; font-family: inherit; letter-spacing: -0.01em;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
  animation: ka-pop 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.8s both;
}
.ka-launcher:hover { transform: translateY(-2px) scale(1.02); }
.ka-launcher:focus-visible { outline: 3px solid rgba(0, 113, 227, 0.5); outline-offset: 3px; }
.ka-orb { position: relative; width: 30px; height: 30px; border-radius: 50%; background: var(--ka-grad); animation: ka-spin 7s linear infinite; }
.ka-orb::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 12%, rgba(255, 255, 255, 0.25) 13% 30%, transparent 31%), #1d1d1f; }
@keyframes ka-spin { to { transform: rotate(360deg); } }
@keyframes ka-pop { from { opacity: 0; transform: translateY(16px) scale(0.9); } }

/* panel */
.ka-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 1001;
  width: 400px; height: min(660px, calc(100vh - 44px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 28px; color: var(--ka-ink);
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(28px); backdrop-filter: saturate(180%) blur(28px);
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.07);
  transform-origin: bottom right;
  animation: ka-open 0.42s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes ka-open { from { opacity: 0; transform: translateY(20px) scale(0.94); } }

.ka-head { display: flex; align-items: center; gap: 11px; padding: 14px 14px 12px 16px; border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
.ka-avatar { position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--ka-grad); }
.ka-avatar::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 10%, rgba(255, 255, 255, 0.2) 11% 28%, transparent 29%), #1d1d1f; }
.ka-title { min-width: 0; }
.ka-title strong { display: block; font-size: 15px; font-weight: 600; }
.ka-title span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ka-ink-3); white-space: nowrap; }
.ka-title span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #30d158; }
.ka-actions { margin-left: auto; display: flex; gap: 6px; }
.ka-icon { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.05); color: var(--ka-ink-2); cursor: pointer; transition: background-color 0.2s; }
.ka-icon:hover { background: rgba(0, 0, 0, 0.1); }
.ka-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ka-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.ka-msg { max-width: 86%; padding: 10px 14px; border-radius: 20px; font-size: 15px; line-height: 1.42; overflow-wrap: anywhere; animation: ka-rise 0.3s ease; }
@keyframes ka-rise { from { opacity: 0; transform: translateY(6px); } }
.ka-msg p { margin: 0; }
.ka-msg p + p, .ka-msg p + ul, .ka-msg ul + p { margin-top: 8px; }
.ka-msg ul { margin: 6px 0 0; padding-left: 18px; }
.ka-msg li + li { margin-top: 3px; }
.ka-user { align-self: flex-end; background: var(--ka-blue); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.ka-ai { align-self: flex-start; background: #f0f0f2; color: var(--ka-ink); border-bottom-left-radius: 6px; }
.ka-ai a { color: var(--ka-link); text-decoration: underline; text-underline-offset: 2px; }
.ka-ai.streaming::after { content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--ka-ink-3); animation: ka-blink 1s steps(2) infinite; }
@keyframes ka-blink { 50% { opacity: 0; } }

.ka-typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 14px 16px; border-radius: 20px; border-bottom-left-radius: 6px; background: #f0f0f2; }
.ka-typing i { width: 7px; height: 7px; border-radius: 50%; background: #8e8e93; animation: ka-dot 1.2s ease-in-out infinite; }
.ka-typing i:nth-child(2) { animation-delay: 0.15s; }
.ka-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ka-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.ka-status { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 980px; background: rgba(0, 113, 227, 0.08); color: #0a5bd8; font-size: 13px; font-weight: 500; }
.ka-status::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: ka-spin 0.8s linear infinite; }
.ka-status.done { background: rgba(48, 209, 88, 0.12); color: #1b8a3a; }
.ka-status.done::before { border: 0; width: auto; height: auto; content: "✓"; animation: none; font-weight: 700; }
.ka-status.failed { background: rgba(255, 59, 48, 0.1); color: #c7281d; }
.ka-status.failed::before { border: 0; width: auto; height: auto; content: "!"; animation: none; font-weight: 700; }

.ka-note { align-self: center; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--ka-ink-3); }
.ka-note.ok { color: #1b8a3a; font-weight: 500; }
.ka-note.error { padding: 8px 12px; border-radius: 12px; background: rgba(255, 59, 48, 0.08); color: #c7281d; }

/* grade card */
.ka-card { align-self: stretch; padding: 16px; border-radius: 22px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 16px 34px -22px rgba(0, 0, 0, 0.35); animation: ka-rise 0.4s ease; }
.ka-card-top { display: flex; align-items: center; gap: 14px; }
.ka-ring { position: relative; flex: none; width: 64px; height: 64px; }
.ka-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ka-ring .track { fill: none; stroke: #ececf0; stroke-width: 7; }
.ka-ring .val { fill: none; stroke-width: 7; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ka-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 700; letter-spacing: -0.03em; }
.ka-card-host { font-size: 12px; color: var(--ka-ink-3); overflow-wrap: anywhere; }
.ka-card-verdict { margin-top: 2px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.ka-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 980px; font-size: 11px; font-weight: 700; color: #fff; vertical-align: 1px; }
.ka-bars { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.ka-bars li { display: grid; grid-template-columns: 1fr 34px; align-items: center; gap: 4px 10px; font-size: 12.5px; color: var(--ka-ink-2); }
.ka-bars li span:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ka-bars i { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: #ececf0; overflow: hidden; }
.ka-bars i::after { content: ""; display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--c); }
.ka-fixes { margin: 14px 0 0; padding: 12px 0 0; border-top: 1px solid rgba(0, 0, 0, 0.06); list-style: none; display: grid; gap: 6px; font-size: 13px; }
.ka-fixes li { display: flex; gap: 8px; }
.ka-fixes li::before { content: "→"; color: var(--ka-blue); font-weight: 600; }
.ka-card-link { display: inline-block; margin-top: 12px; font-size: 14px; font-weight: 500; color: var(--ka-link); text-decoration: none; }
.ka-card-link::after { content: " ›"; }

.ka-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; }
.ka-chip { border: 0; border-radius: 980px; padding: 8px 13px; background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); color: var(--ka-ink); font: 500 13px/1.1 inherit; font-family: inherit; cursor: pointer; transition: background-color 0.2s; }
.ka-chip:hover { background: #f5f5f7; }

.ka-form { display: flex; align-items: flex-end; gap: 8px; margin: 0 12px 8px; padding: 5px 5px 5px 14px; border-radius: 24px; background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); transition: box-shadow 0.2s; }
.ka-form:focus-within { box-shadow: inset 0 0 0 1px #0071e3, 0 0 0 4px rgba(0, 113, 227, 0.15); }
.ka-form textarea { flex: 1; min-width: 0; max-height: 120px; padding: 8px 0; border: 0; outline: none; resize: none; background: transparent; color: var(--ka-ink); font: 15px/1.4 inherit; font-family: inherit; letter-spacing: inherit; }
.ka-send { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--ka-blue); color: #fff; cursor: pointer; transition: opacity 0.2s, transform 0.2s; }
.ka-send:disabled { opacity: 0.35; cursor: default; }
.ka-send:not(:disabled):active { transform: scale(0.94); }
.ka-send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ka-foot { padding: 0 14px 10px; text-align: center; font-size: 11px; color: #86868b; }
.ka-foot a { color: inherit; }

/* live chat with a person */
.ka-person { padding: 0; border: 0; background: none; color: var(--ka-link); font: inherit; font-weight: 600; cursor: pointer; }
.ka-person:hover { text-decoration: underline; }
.ka-end { flex: none; white-space: nowrap; height: 32px; padding: 0 12px; border: 0; border-radius: 980px; background: rgba(255, 59, 48, 0.1); color: #c7281d; font: 600 12.5px/1 inherit; font-family: inherit; cursor: pointer; }
.ka-end:hover { background: rgba(255, 59, 48, 0.16); }
.ka-title span[data-state="waiting"]::before { background: #ff9f0a; animation: ka-wait 1.2s ease-in-out infinite; }
@keyframes ka-wait { 50% { opacity: 0.35; } }
.ka-avatar.person { display: grid; place-items: center; background: linear-gradient(135deg, #30d158, #0a84ff); color: #fff; font-size: 15px; font-weight: 700; }
.ka-avatar.person::after { display: none; }
.ka-agent { align-self: flex-start; background: #fff; color: var(--ka-ink); border-bottom-left-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.ka-agent-name { display: block; margin-bottom: 3px; font-size: 11.5px; font-weight: 600; color: #1b8a3a; }
.ka-note.live { padding: 6px 12px; border-radius: 980px; background: rgba(0, 113, 227, 0.07); color: #0a5bd8; font-weight: 500; }
.ka-contact { align-self: stretch; display: grid; gap: 8px; padding: 12px; border-radius: 16px; background: #f5f5f7; }
.ka-contact strong { font-size: 13.5px; }
.ka-contact input { width: 100%; padding: 9px 12px; border: 1px solid rgba(0, 0, 0, 0.14); border-radius: 10px; background: #fff; font: 14px/1.3 inherit; font-family: inherit; color: var(--ka-ink); }
.ka-contact input:focus { outline: none; border-color: var(--ka-blue); box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15); }
.ka-contact button { justify-self: start; padding: 8px 18px; border: 0; border-radius: 980px; background: var(--ka-blue); color: #fff; font: 600 14px/1 inherit; font-family: inherit; cursor: pointer; }
.ka-contact button:disabled { opacity: 0.5; }
.ka-contact-error { margin: 0; font-size: 12.5px; color: #c7281d; }
.ka-launcher.unread::after { content: ""; position: absolute; top: -2px; right: -2px; width: 14px; height: 14px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 0 3px #fff; }

@media (max-width: 520px) {
  .ka-panel { inset: 0; width: auto; height: auto; border-radius: 0; }
  .ka-launcher { right: 14px; bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ka-root *, .ka-root *::before, .ka-root *::after { animation: none !important; transition: none !important; }
}
