.k-chat {
  --k-chat-z: 80;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}
.k-chat__fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: var(--k-chat-z);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: #0069b4;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(11, 58, 92, 0.28);
}
.k-chat__fab:hover { background: #005a9c; }
.k-chat__fab[aria-expanded="true"] { background: #0b3a5c; }

.k-chat__panel {
  position: fixed;
  right: 1.25rem;
  bottom: 4.75rem;
  z-index: var(--k-chat-z);
  width: min(380px, calc(100vw - 1.5rem));
  height: min(560px, calc(100vh - 6.5rem));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d7e4f2;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(11, 58, 92, 0.18);
  overflow: hidden;
}
.k-chat__panel[hidden] { display: none !important; }

.k-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  background: #0b3a5c;
  color: #fff;
}
.k-chat__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}
.k-chat__sub {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: #93a8bc;
}
.k-chat__close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
}

.k-chat__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #e8eef5;
  background: #f7fafc;
}
.k-chat__chip {
  border: 1px solid #d7e4f2;
  background: #fff;
  color: #0b3a5c;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 650;
  cursor: pointer;
}
.k-chat__chip:hover { border-color: #009ef7; color: #0069b4; }

.k-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  background: #fff;
}
.k-chat__bubble {
  max-width: 88%;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.k-chat__bubble--bot {
  align-self: flex-start;
  background: #f0f6fb;
  color: #0b3a5c;
  border: 1px solid #e1ebf4;
}
.k-chat__bubble--user {
  align-self: flex-end;
  background: #0069b4;
  color: #fff;
}
.k-chat__md {
  white-space: normal;
}
.k-chat__md p {
  margin: 0 0 0.45em;
}
.k-chat__md p:last-child {
  margin-bottom: 0;
}
.k-chat__md ul,
.k-chat__md ol {
  margin: 0.35em 0 0.15em;
  padding-left: 1.15em;
}
.k-chat__md li {
  margin: 0.15em 0;
}
.k-chat__md h4 {
  margin: 0 0 0.4em;
  font-size: 0.9em;
  font-weight: 750;
  letter-spacing: -0.01em;
}
.k-chat__md strong {
  font-weight: 750;
}
.k-chat__md a {
  color: #0069b4;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.k-chat__md code {
  font-size: 0.85em;
  background: rgba(11, 58, 92, 0.08);
  padding: 0.05em 0.3em;
  border-radius: 4px;
}
.k-chat__md pre {
  margin: 0.4em 0 0;
  padding: 0.55em 0.65em;
  background: rgba(11, 58, 92, 0.06);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8em;
}
.k-chat__md pre code {
  background: none;
  padding: 0;
}
.k-chat__bubble--typing {
  min-height: 2.4rem;
  display: inline-flex;
  align-items: center;
}
.k-chat__dots {
  display: inline-flex;
  gap: 0.28rem;
  align-items: center;
  padding: 0.1rem 0.15rem;
}
.k-chat__dots i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: #6b8aa3;
  display: block;
  animation: k-chat-dot 1.2s ease-in-out infinite;
}
.k-chat__dots i:nth-child(2) { animation-delay: 0.15s; }
.k-chat__dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes k-chat-dot {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.k-chat__form {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid #e8eef5;
  background: #fff;
}
.k-chat__input {
  flex: 1;
  min-width: 0;
  border: 1px solid #d7e4f2;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.875rem;
  color: #0b3a5c;
}
.k-chat__input:focus {
  outline: 2px solid #009ef7;
  outline-offset: 1px;
}
.k-chat__send {
  border: 0;
  border-radius: 10px;
  background: #0069b4;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.k-chat__send:disabled {
  opacity: 0.7;
  cursor: wait;
}
.k-chat__lgpd {
  margin: 0;
  padding: 0 0.75rem 0.65rem;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #64748b;
}

.k-chat__toast {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: calc(var(--k-chat-z) + 1);
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: #0b3a5c;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.k-chat__toast--ok { background: #047857; }
.k-chat__toast--err { background: #b91c1c; }
.k-chat__toast[hidden] { display: none !important; }

.k-chat__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

@media (max-width: 640px) {
  .k-chat__panel {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 4.5rem;
    width: auto;
    height: min(70vh, 560px);
  }
  .k-chat__fab {
    right: 0.75rem;
    bottom: 0.75rem;
  }
}
