.ai-chat-shell {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.ai-assistant-drawer {
  width: min(460px, 100vw) !important;
  border-left: 1px solid var(--art-line, #edf1f7);
}

.ai-drawer-header {
  background: var(--gradient-soft, linear-gradient(135deg, #f3f7ff 0%, #edfaff 100%));
  border-bottom: 1px solid var(--art-line, #edf1f7);
}

.ai-drawer-header .offcanvas-title {
  color: var(--text, #344054);
  font-size: 16px;
  font-weight: 760;
}

.ai-drawer-body {
  height: calc(100vh - 62px);
  padding: 14px;
  overflow: hidden;
}

.ai-chat-messages {
  border: 1px solid var(--art-line, #edf1f7);
  border-radius: 12px;
  background: #fbfcff;
  padding: 14px;
  overflow: auto;
  min-height: 0;
}

.ai-msg {
  display: flex;
  margin-bottom: 10px;
}

.ai-msg.user {
  justify-content: flex-end;
}

.ai-msg-bubble {
  max-width: min(78%, 720px);
  border: 1px solid var(--art-line, #edf1f7);
  border-radius: 12px;
  padding: 9px 11px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text, #344054);
  background: #fff;
}

.ai-msg.user .ai-msg-bubble {
  border-color: #d7e5ff;
  background: var(--art-blue-soft, #eef4ff);
  color: #2456a5;
}

.ai-msg.failed .ai-msg-bubble {
  border-color: var(--art-red-soft, #fff0f2);
  background: var(--art-red-soft, #fff0f2);
  color: var(--art-red, #ff6b7a);
}

.ai-msg.loading .ai-msg-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-mute, #8792a4);
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--art-blue, #5b8ff9);
  opacity: .42;
  animation: aiTyping 1.05s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) {
  animation-delay: .15s;
}

.ai-typing-dot:nth-child(3) {
  animation-delay: .3s;
}

.ai-loading-text {
  margin-left: 4px;
}

@keyframes aiTyping {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: .36;
  }

  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.ai-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.ai-chat-form textarea {
  min-height: 100px;
  max-height: 140px;
  resize: vertical;
  border-color: var(--art-line, #edf1f7);
  border-radius: 10px;
}

.ai-context-line {
  color: var(--text-mute, #8792a4);
  font-size: 12px;
  margin-top: 4px;
}

.ai-config-section {
  border: 1px solid var(--art-line, #edf1f7);
  border-radius: 12px;
  background: #fbfcff;
  padding: 12px;
  margin-bottom: 12px;
}

.ai-config-header {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text, #344054);
  font-weight: 760;
  font-size: 13px;
  margin-bottom: 10px;
}

.ai-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-config-grid .full {
  grid-column: 1 / -1;
}

.ai-role-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 10px;
  border: 1px solid var(--art-line, #edf1f7);
  border-radius: 10px;
  background: #fff;
}

@media (max-width: 768px) {
  .ai-chat-form,
  .ai-config-grid {
    grid-template-columns: 1fr;
  }

  .ai-msg-bubble {
    max-width: 92%;
  }
}
