.cio-site-chat {
  position: fixed;
  z-index: 10040;
  display: flex;
  flex-direction: column;
  width: min(420px, calc(100vw - 24px));
  height: min(640px, calc(100dvh - 88px));
  right: 16px;
  bottom: 16px;
  background: #070a17;
  color: #fff;
  border: 1px solid rgba(0, 191, 255, 0.28);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

body.cio-chat-open .cio-site-chat {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.cio-site-chat-backdrop {
  display: none;
}

.cio-site-chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(180deg, #0c1224 0%, #070a17 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.cio-site-chat__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 191, 255, 0.14);
  color: #00bfff;
  flex-shrink: 0;
}

.cio-site-chat__head-text {
  min-width: 0;
  flex: 1;
}

.cio-site-chat__title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.cio-site-chat__sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: #8ea0c4;
  line-height: 1.3;
}

.cio-site-chat__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cio-site-chat__close:hover,
.cio-site-chat__close:focus-visible {
  background: #00bfff;
  color: #041018;
  outline: none;
}

.cio-site-chat__log {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.cio-site-chat__row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 100%;
}

.cio-site-chat__row--user {
  align-items: flex-end;
}

.cio-site-chat__row--bot {
  align-items: flex-start;
}

.cio-site-chat__bubble {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.cio-site-chat__bubble p {
  margin: 0 0 0.65em;
}

.cio-site-chat__bubble p:last-child {
  margin-bottom: 0;
}

.cio-site-chat__bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cio-site-chat__bubble--bot {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top-left-radius: 4px;
}

.cio-site-chat__bubble--user {
  background: #00bfff;
  color: #041018;
  border-top-right-radius: 4px;
}

.cio-site-chat__bubble--err {
  background: rgba(255, 80, 80, 0.14);
  border-color: rgba(255, 80, 80, 0.28);
}

.cio-site-chat__typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 18px;
}

.cio-site-chat__typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00bfff;
  opacity: 0.35;
  animation: cio-chat-dot 1s infinite ease-in-out;
}

.cio-site-chat__typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.cio-site-chat__typing i:nth-child(3) {
  animation-delay: 0.3s;
}

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

.cio-site-chat__sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.cio-site-chat__sources-label {
  width: 100%;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8ea0c4;
}

.cio-site-chat__source {
  display: inline-block;
  max-width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: #00bfff;
  background: rgba(0, 191, 255, 0.1);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cio-site-chat__source:hover {
  background: rgba(0, 191, 255, 0.22);
}

.cio-site-chat__hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}

.cio-site-chat__hint {
  border: 1px solid rgba(0, 191, 255, 0.28);
  background: transparent;
  color: #d5e4f7;
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  line-height: 1.3;
}

.cio-site-chat__hint:hover,
.cio-site-chat__hint:focus-visible {
  background: rgba(0, 191, 255, 0.14);
  color: #fff;
  outline: none;
}

.cio-site-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #050814;
  flex-shrink: 0;
}

.cio-site-chat__input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: #101624;
  color: #fff;
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}

.cio-site-chat__input:focus {
  outline: none;
  border-color: #00bfff;
  box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.15);
}

.cio-site-chat__send {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #00bfff;
  color: #041018;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cio-site-chat__send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.cio-site-chat__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.cio-chat-open .cio-chatbase-icon {
  color: #00bfff;
}

@media (max-width: 768px) {
  .cio-site-chat-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10035;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.cio-chat-open .cio-site-chat-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .cio-site-chat {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: calc(100dvh - var(--cio-header-h, 56px));
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform: translateY(16px);
  }

  body.cio-chat-open .cio-site-chat {
    transform: none;
  }

  body.cio-chat-open {
    overflow: hidden;
  }
}
