.aca-ai-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  font-family: inherit;
}

.aca-ai-chat-panel {
  display: none;
  width: min(420px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 16px;
  background: rgba(18,18,18,.96);
  color: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.32);
}

.aca-ai-chat.is-open .aca-ai-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
}

.aca-ai-chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #d7192a, #980b18);
}

.aca-ai-chat-head strong,
.aca-ai-chat-head span {
  display: block;
}

.aca-ai-chat-head span {
  margin-top: 3px;
  opacity: .86;
  font-size: 12px;
}

.aca-ai-chat-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.aca-ai-chat-close,
.aca-ai-chat-reset,
.chat-reset,
.aca-ai-chat-toggle,
.aca-ai-chat-form button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.aca-ai-chat-reset,
.chat-reset {
  white-space: nowrap;
  border-radius: 999px;
  color: #fff;
  background: rgba(255,255,255,.16);
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 900;
}

.aca-ai-chat-close {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255,255,255,.14);
  font-size: 20px;
}

.aca-ai-chat-body {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
}

.aca-ai-chat-status {
  color: #49d68f;
  font-size: 12px;
  font-weight: 800;
}

.aca-ai-chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  line-height: 1.45;
  font-size: 13px;
}

.aca-ai-chat-message.expert {
  border-left: 3px solid #d7192a;
}

.aca-ai-chat-message.user {
  justify-self: end;
  color: #fff;
  background: linear-gradient(135deg, #0f8de8, #0b64b1);
  border-right: 3px solid rgba(255,255,255,.65);
}

.chat-message.user {
  justify-self: end;
  color: #fff;
  background: linear-gradient(135deg, #0f8de8, #0b64b1);
  border-right: 3px solid rgba(255,255,255,.65);
}

.aca-ai-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.aca-ai-chat-form input {
  min-width: 0;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  color: inherit;
  padding: 11px 13px;
}

.aca-ai-chat-form button,
.aca-ai-chat-toggle {
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #e52739, #a70d1c);
  font-weight: 900;
  box-shadow: 0 14px 34px rgba(215,25,42,.25);
}

.aca-ai-chat-form button {
  padding: 0 16px;
}

.aca-ai-chat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 17px;
}

.aca-ai-chat-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
}

html[data-theme="light"] .aca-ai-chat-panel {
  color: #2b241e;
  border-color: rgba(92,70,42,.16);
  background: rgba(255,250,242,.98);
}

html[data-theme="light"] .aca-ai-chat-message {
  background: rgba(112,84,52,.08);
}

html[data-theme="light"] .aca-ai-chat-form input {
  color: #2b241e;
  border-color: rgba(92,70,42,.18);
  background: rgba(255,255,255,.78);
}

html[data-theme="light"] .chat-reset {
  color: #fff;
}

@media (max-width: 640px) {
  .aca-ai-chat {
    right: 12px;
    bottom: 12px;
  }

  .aca-ai-chat.is-open {
    left: 12px;
  }

  .aca-ai-chat-toggle span:last-child {
    display: none;
  }

  .aca-ai-chat-reset,
  .chat-reset {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
