.credo-ai {
  --credo-blue: #143f72;
  --credo-blue-dark: #0c2d55;
  --credo-gold: #e6a922;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999999;
  font-family: Arial, Helvetica, sans-serif;
  color: #17202a;
}

.credo-ai *, .credo-ai *::before, .credo-ai *::after { box-sizing: border-box; }
.credo-ai__toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: 28px;
  background: var(--credo-blue);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 28px rgba(0,0,0,.22);
  cursor: pointer;
}
.credo-ai__toggle:hover, .credo-ai__toggle:focus { background: var(--credo-blue-dark); }
.credo-ai--open .credo-ai__toggle {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.credo-ai__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(400px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 44px));
  height: min(620px, calc(100dvh - 44px));
  overflow: hidden;
  overscroll-behavior: none;
  border: 1px solid rgba(20,63,114,.18);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(0,0,0,.25);
}
.credo-ai__panel[hidden] { display: none !important; }
.credo-ai__panel:not([hidden]) {
  display: grid !important;
  grid-template-rows: 58px minmax(0, 1fr) auto auto;
  grid-template-columns: minmax(0, 1fr);
}
.credo-ai__header {
  display: flex;
  flex: 0 0 58px;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 16px 0 18px;
  background: var(--credo-blue);
  color: #fff;
}
.credo-ai__close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  line-height: 1;
  place-items: center;
  cursor: pointer;
}
.credo-ai__messages {
  width: 100%;
  height: auto;
  max-height: none;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: none;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  background: #f4f6f8;
}
.credo-ai__message { display: flex; flex-direction: column; align-items: flex-start; margin: 0 0 14px; }
.credo-ai__message--user { align-items: flex-end; }
.credo-ai__bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 15px 15px 15px 4px;
  background: #fff;
  color: #17202a;
  font-size: 14px;
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(0,0,0,.09);
}
.credo-ai__message--user .credo-ai__bubble { border-radius: 15px 15px 4px 15px; background: var(--credo-blue); color: #fff; }
.credo-ai details { width: 88%; margin-top: 6px; padding: 7px 10px; border-radius: 8px; background: #fff; font-size: 12px; }
.credo-ai summary { cursor: pointer; color: var(--credo-blue); font-weight: 700; }
.credo-ai ol { margin: 7px 0 0 18px; padding: 0; }
.credo-ai li { margin-bottom: 5px; }
.credo-ai a { color: var(--credo-blue); text-decoration: underline; }
.credo-ai__form { display: flex; flex: 0 0 auto; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid #e1e5e8; background: #fff; }
.credo-ai__form textarea { flex: 1; min-height: 44px; max-height: 100px; resize: none; padding: 10px; border: 1px solid #b9c3cc; border-radius: 10px; font: inherit; }
.credo-ai__form textarea:focus { outline: 2px solid rgba(20,63,114,.25); border-color: var(--credo-blue); }
.credo-ai__form button { align-self: stretch; padding: 0 14px; border: 0; border-radius: 10px; background: var(--credo-gold); color: #17202a; font-weight: 700; cursor: pointer; }
.credo-ai__form button:disabled { opacity: .55; cursor: wait; }
.credo-ai__note { flex: 0 0 auto; margin: 0; padding: 0 12px 10px; background: #fff; color: #69747d; font-size: 10px; text-align: center; }
.credo-ai__loading { display: flex; gap: 4px; }
.credo-ai__loading span { width: 6px; height: 6px; border-radius: 50%; background: #718095; animation: credo-ai-pulse 1s infinite alternate; }
.credo-ai__loading span:nth-child(2) { animation-delay: .2s; }
.credo-ai__loading span:nth-child(3) { animation-delay: .4s; }
@keyframes credo-ai-pulse { to { opacity: .25; transform: translateY(-2px); } }
@media (max-width: 700px), (max-height: 680px) {
  .credo-ai { right: 14px; bottom: 14px; }
  .credo-ai__panel {
    position: fixed;
    inset: 10px;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 16px;
  }
  .credo-ai__header { flex-basis: 56px; }
  .credo-ai__panel:not([hidden]) { grid-template-rows: 56px minmax(0, 1fr) auto auto; }
  .credo-ai__form { padding: 10px; }
}
@media (max-width: 520px) {
  .credo-ai__toggle span:last-child { display: none; }
  .credo-ai__toggle { width: 52px; padding: 0; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .credo-ai__loading span { animation: none; } }
