:root {
  --ka-green: #28df7a;
  --ka-ink: #07111f;
  --ka-panel: #0b1726;
  --ka-line: #263b52;
  --ka-muted: #90a4b9;
}

.ka-launcher {
  position: fixed;
  z-index: 80;
  right: 22px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  isolation: isolate;
  transition: transform 180ms ease;
}

.ka-launcher:hover { transform: translateY(-2px); }
.ka-launcher:focus-visible {
  outline: 2px solid #8ff6b9;
  outline-offset: 5px;
  border-radius: 18px;
}

.ka-launcher img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  filter: drop-shadow(0 9px 9px #0009) drop-shadow(0 0 8px #28df7a66);
  animation: ka-attention-breathe 10s ease-in-out 2.2s infinite;
}

.ka-launcher[aria-expanded="true"] img {
  filter: drop-shadow(0 7px 8px #0008) drop-shadow(0 0 11px #28df7a80);
}

.ka-launcher::before,
.ka-launcher::after {
  position: absolute;
  left: 50%;
  z-index: 1;
  pointer-events: none;
  content: "";
  opacity: 0;
}

.ka-launcher::before {
  bottom: 20px;
  width: 74px;
  height: 190px;
  clip-path: polygon(39% 0, 61% 0, 100% 100%, 0 100%);
  background: linear-gradient(to bottom, #baffdc00 0%, #7dffc944 28%, #32f28e9e 78%, #d5ffeb26 100%);
  filter: blur(4px);
  transform: translateX(-50%) scaleY(.12);
  transform-origin: center bottom;
}

.ka-launcher::after {
  bottom: -9px;
  width: 54px;
  height: 17px;
  border: 2px solid #77ffc0;
  border-radius: 50%;
  box-shadow: 0 0 13px #28df7acc, inset 0 0 8px #28df7a8c;
  transform: translateX(-50%) scale(.2);
}

.ka-launcher--arriving {
  animation: ka-icon-materialize 1.55s cubic-bezier(.2, .84, .28, 1) both;
}

.ka-launcher--arriving::before {
  animation: ka-landing-beam 1.45s ease-out both;
}

.ka-launcher--arriving::after {
  animation: ka-landing-ring 1.15s ease-out .28s both;
}

@keyframes ka-icon-materialize {
  0%, 12% { opacity: 0; transform: translateY(-90px) scale(.35) rotate(-7deg); filter: blur(7px); }
  44% { opacity: .82; transform: translateY(-29px) scale(.76) rotate(2deg); filter: blur(2px); }
  76% { opacity: 1; transform: translateY(3px) scale(1.04) rotate(0); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes ka-landing-beam {
  0% { opacity: 0; transform: translateX(-50%) scaleY(.1); }
  16% { opacity: .75; }
  58% { opacity: .95; transform: translateX(-50%) scaleY(1); }
  100% { opacity: 0; transform: translateX(-50%) scaleY(.92); }
}

@keyframes ka-landing-ring {
  0% { opacity: 0; transform: translateX(-50%) scale(.2); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1.65); }
}

@keyframes ka-attention-breathe {
  0%, 78%, 92%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 9px 9px #0009) drop-shadow(0 0 8px #28df7a66);
  }
  84% {
    transform: scale(1.045);
    filter: drop-shadow(0 10px 10px #0009) drop-shadow(0 0 15px #28df7aa6);
  }
}

.ka-panel {
  position: fixed;
  z-index: 81;
  right: 22px;
  bottom: 96px;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100dvh - 122px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--ka-line);
  border-radius: 26px;
  background: var(--ka-panel);
  color: #f6f9fc;
  box-shadow: 0 26px 80px #000c;
  transform-origin: bottom right;
  transition: opacity 160ms ease, transform 160ms ease;
}

.ka-panel[hidden] { display: none; }

.ka-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--ka-line);
  background: linear-gradient(135deg, #10263a, #0b1c2b);
}

.ka-header img { width: 42px; height: 42px; border-radius: 14px; }
.ka-title { min-width: 0; display: grid; gap: 2px; }
.ka-title strong { font-size: 14px; }
.ka-title span { color: #8ff6b9; font-size: 10px; }
.ka-close {
  margin-left: auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  background: #ffffff0d;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.ka-messages {
  overflow-y: auto;
  padding: 18px 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  scrollbar-width: thin;
  scrollbar-color: #3b526b transparent;
}

.ka-message {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 17px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ka-message--assistant {
  align-self: flex-start;
  border: 1px solid #28425a;
  border-bottom-left-radius: 5px;
  background: #13263a;
}

.ka-message--user {
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  background: var(--ka-green);
  color: #04150b;
  font-weight: 650;
}

.ka-message--status { color: var(--ka-muted); font-style: italic; }

.ka-manual-shortcut {
  align-self: flex-start;
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  border: 1px solid #28df7a73;
  border-radius: 12px;
  background: #0e2b22;
  color: #83f4b3;
  font-size: 11px;
  font-weight: 850;
  text-decoration: none;
}

.ka-manual-shortcut:hover { background: #123a2c; }
.ka-manual-shortcut:focus-visible { outline: 2px solid #8ff6b9; outline-offset: 3px; }

.ka-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
  padding: 12px;
  border-top: 1px solid var(--ka-line);
  background: #091421;
}

.ka-form textarea {
  min-height: 48px;
  max-height: 112px;
  resize: none;
  border: 1px solid #30475f;
  border-radius: 15px;
  outline: 0;
  background: #111f30;
  color: #fff;
  padding: 13px;
  font: inherit;
  font-size: 13px;
}

.ka-form textarea:focus { border-color: var(--ka-green); box-shadow: 0 0 0 3px #28df7a1a; }
.ka-form textarea::placeholder { color: #71869c; }
.ka-send {
  align-self: end;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 15px;
  background: var(--ka-green);
  color: #04150b;
  cursor: pointer;
  font-size: 22px;
  font-weight: 900;
}
.ka-send:disabled { cursor: wait; opacity: .55; }
.ka-note { grid-column: 1 / -1; margin: 0 3px; color: #71869c; font-size: 9px; }

@media (width <= 600px) {
  .ka-launcher { right: 14px; bottom: calc(82px + env(safe-area-inset-bottom)); width: 56px; height: 56px; }
  .ka-panel {
    right: 7px;
    bottom: calc(146px + env(safe-area-inset-bottom));
    width: calc(100vw - 14px);
    height: min(590px, calc(100dvh - 164px));
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ka-launcher,
  .ka-launcher img,
  .ka-launcher::before,
  .ka-launcher::after,
  .ka-panel {
    animation: none !important;
    transition: none;
  }

  .ka-launcher--arriving { opacity: 1; transform: none; filter: none; }
}
