.cn-chat {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1030;
  font-family: Inter, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.cn-chat__launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  min-width: 3.5rem;
  padding: 0;
  border: 0 !important;
  border-radius: 999px !important;
  background: #0130c8 !important;
  color: #fff !important;
  box-shadow: 0 10px 24px rgba(1, 48, 200, 0.32);
  cursor: pointer;
}

.cn-chat__launcher:hover {
  background: #001d5e !important;
}

.cn-chat__icon {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
}

.cn-chat__launcher[aria-expanded="false"] .cn-chat__icon--close,
.cn-chat__launcher[aria-expanded="true"] .cn-chat__icon--open {
  display: none;
}

.cn-chat__launcher:focus-visible,
.cn-chat__panel button:focus-visible,
.cn-chat__input:focus-visible {
  outline: 3px solid #34e7bf;
  outline-offset: 2px;
}

.cn-chat__panel {
  position: absolute;
  right: 0;
  bottom: 4.2rem;
  width: min(22.5rem, calc(100vw - 1.5rem));
  height: min(32rem, calc(100vh - 6.5rem));
  background: #fff;
  color: #001d5e;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 29, 94, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cn-chat__panel[hidden] {
  display: none !important;
}

.cn-chat__header {
  flex: 0 0 auto;
  background: linear-gradient(135deg, #001d5e, #0130c8);
  color: #fff;
  padding: 0.7rem 0.8rem 0.6rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.15rem 0.5rem;
}

.cn-chat__header h2 {
  grid-column: 1;
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.3;
  color: #fff;
}

.cn-chat__subtitle {
  grid-column: 1;
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.3;
  color: #dbe4ff;
}

.cn-chat__header-actions {
  grid-row: 1 / span 2;
  grid-column: 2;
  display: flex;
  gap: 0.35rem;
  align-items: start;
}

.cn-chat__header-actions button {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  border-radius: 999px !important;
  min-width: 0 !important;
  width: auto !important;
  min-height: 1.75rem;
  padding: 0.15rem 0.65rem;
  font-size: 0.75rem !important;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.cn-chat__header-actions button:hover {
  background: #fff !important;
  color: #001d5e !important;
}

.cn-chat__log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.7rem 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: #f4f6fb;
}

.cn-chat__msg {
  max-width: 92%;
  padding: 0.5rem 0.7rem;
  line-height: 1.45;
  font-size: 0.8125rem;
}

.cn-chat__msg--user {
  align-self: flex-end;
  background: #0130c8;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
}

.cn-chat__msg--assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px 16px 16px 4px;
}

.cn-chat__body p {
  margin: 0 0 0.45rem;
}

.cn-chat__body p:last-child {
  margin-bottom: 0;
}

.cn-chat__list {
  margin: 0.1rem 0 0.35rem;
  padding-left: 1.05rem;
  font-size: 0.8125rem;
}

.cn-chat__body a {
  color: #0130c8;
  font-weight: 600;
}

.cn-chat__sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.cn-chat__sources a {
  display: inline-flex;
  align-items: center;
  min-height: 1.7rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #eef3ff;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0130c8;
  text-decoration: none;
}

.cn-chat__sources a:hover {
  background: #0130c8;
  color: #fff;
}

.cn-chat__typing {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  width: fit-content;
  min-height: 2.2rem;
  padding: 0.55rem 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px 16px 16px 4px;
}

.cn-chat__typing span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: #0130c8;
  animation: cn-chat-dot 1s infinite ease-in-out;
}

.cn-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.cn-chat__typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cn-chat-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.cn-chat__error {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.4rem 0.75rem;
  background: #fff4f4;
  color: #9b1c1c;
  font-size: 0.75rem;
}

.cn-chat__error button {
  margin-left: 0.45rem;
  background: #fff !important;
  border: 1px solid #0130c8 !important;
  border-radius: 999px !important;
  color: #0130c8 !important;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  min-height: 1.8rem;
  padding: 0.1rem 0.7rem;
  cursor: pointer;
}

.cn-chat__form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.65rem;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.cn-chat__input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: 2.5rem;
  resize: none;
  overflow: hidden;
  min-height: 2.5rem;
  max-height: 2.5rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-family: inherit;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #001d5e;
}

.cn-chat__send {
  position: static !important;
  flex: 0 0 auto;
  align-self: center;
  height: 2.5rem;
  min-height: 2.5rem !important;
  width: auto !important;
  min-width: 4.25rem !important;
  max-width: 5.5rem;
  margin: 0 !important;
  padding: 0 0.85rem !important;
  background: #0130c8 !important;
  color: #fff !important;
  border: 0 !important;
  border-radius: 8px !important;
  font-size: 0.8125rem !important;
  font-weight: 600;
  line-height: 1 !important;
  cursor: pointer;
}

.cn-chat__send:hover:not(:disabled) {
  background: #001d5e !important;
}

.cn-chat__send:disabled,
.cn-chat__input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.cn-chat__noscript {
  position: absolute;
  right: 0;
  bottom: 4.2rem;
  width: min(24rem, calc(100vw - 2rem));
  background: #fff;
  border-radius: 8px;
  padding: 0.8rem;
  box-shadow: 0 8px 24px rgba(0, 29, 94, 0.15);
}
