.kk-chat {
  position: fixed;
  right: 22px;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
}

.kk-chat * {
  box-sizing: border-box;
}

.kk-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #c71f32, #941524);
  box-shadow: 0 22px 42px rgba(98, 17, 25, 0.24);
  cursor: pointer;
  font-weight: 800;
  transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.kk-chat-toggle svg {
  width: 22px;
  height: 22px;
}

.kk-chat-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(420px, calc(100vw - 28px));
  height: min(680px, calc(100dvh - 128px));
  overflow: hidden;
  border: 1px solid rgba(88, 92, 102, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 72px rgba(33, 28, 28, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease;
}

.kk-chat.is-open .kk-chat-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.kk-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  color: #fff;
  background: #211b1b;
}

.kk-chat-title {
  display: grid;
  gap: 2px;
}

.kk-chat-title strong {
  font-size: 0.98rem;
  line-height: 1.25;
}

.kk-chat-title span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  font-weight: 700;
}

.kk-chat-close {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.kk-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: #f5f6f7;
}

.kk-chat-message {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 8px;
  white-space: pre-wrap;
  color: #252427;
  background: #fff;
  border: 1px solid rgba(88, 92, 102, 0.1);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.kk-chat-message.user {
  align-self: flex-end;
  color: #fff;
  background: #c71f32;
  border-color: #c71f32;
}

.kk-chat-message.system {
  max-width: 100%;
  color: #66666d;
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 0.76rem;
}

.kk-chat-message.loading {
  width: 76px;
}

.kk-chat-dots {
  display: inline-flex;
  gap: 4px;
}

.kk-chat-dots span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #c71f32;
  animation: kkPulse 900ms infinite ease-in-out;
}

.kk-chat-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.kk-chat-dots span:nth-child(3) {
  animation-delay: 240ms;
}

.kk-chat-chips,
.kk-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kk-chat-chip,
.kk-chat-action {
  min-height: 34px;
  border: 1px solid rgba(199, 31, 50, 0.18);
  border-radius: 999px;
  color: #941524;
  background: #fff;
  cursor: pointer;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
}

.kk-chat-action.primary {
  color: #fff;
  border-color: #c71f32;
  background: #c71f32;
}

.kk-chat-footer {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid rgba(88, 92, 102, 0.12);
  background: #fff;
}

.kk-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.kk-chat-input {
  min-height: 44px;
  max-height: 120px;
  resize: none;
  overflow-y: hidden;
  border: 1px solid rgba(88, 92, 102, 0.18);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
  line-height: 1.45;
}

.kk-chat-input:focus {
  border-color: rgba(199, 31, 50, 0.58);
  box-shadow: 0 0 0 3px rgba(199, 31, 50, 0.1);
}

.kk-chat-send {
  width: 44px;
  min-height: 44px;
  height: auto;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #c71f32;
  cursor: pointer;
  font-weight: 900;
}

.kk-chat-send:disabled,
.kk-chat-chip:disabled,
.kk-chat-action:disabled {
  cursor: progress;
  opacity: 0.58;
}

.kk-chat-privacy {
  color: #66666d;
  font-size: 0.72rem;
  line-height: 1.35;
}

@keyframes kkPulse {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 560px) {
  .kk-chat {
    right: 12px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .kk-chat-toggle span {
    display: none;
  }

  .kk-chat-toggle {
    width: 58px;
    height: 58px;
    justify-content: center;
    padding: 0;
  }

  .kk-chat-panel {
    position: fixed;
    inset: auto 10px calc(84px + env(safe-area-inset-bottom, 0px)) 10px;
    width: auto;
    height: min(660px, calc(100dvh - 104px));
    max-height: calc(100svh - 104px);
    transform-origin: bottom right;
  }

  .kk-chat.is-open .kk-chat-toggle {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.96);
  }

  .kk-chat-header {
    padding: 14px;
  }

  .kk-chat-messages {
    padding: 12px;
  }

  .kk-chat-footer {
    padding: 10px;
  }

  .kk-chat-input {
    min-height: 58px;
  }

  .kk-chat-chips {
    max-height: 86px;
    overflow-y: auto;
  }

  .kk-chat-chip,
  .kk-chat-action {
    padding: 8px 11px;
  }
}

@media (max-width: 380px) {
  .kk-chat-panel {
    inset-inline: 8px;
  }

  .kk-chat-title span {
    display: none;
  }
}
