
.ds-chat-launcher {
  position: fixed;
  right: var(--ds-space-6);
  bottom: var(--ds-space-6);
  width: 4rem;
  height: 4rem;
  border-radius: var(--ds-radius-full);
  background: var(--ds-color-primary-600);
  color: var(--ds-color-text-on-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--ds-shadow-lg);
  transition: var(--ds-transition-transform), var(--ds-transition-shadow);
  z-index: 1300;
}
/* In der gemeinsamen Aktionsleiste steht der KI-Chat ganz unten. */
.ds-chat-widget-root--rail .ds-chat-launcher {
  right: var(--ds-space-4);
  bottom: var(--ds-space-4);
  width: calc(3rem + 0.5rem);
  height: calc(3rem + 0.5rem);
}
.ds-chat-launcher:hover {
  background: var(--ds-color-primary-700);
  transform: scale(1.05);
}
.ds-chat-launcher:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-focus-ring);
}
.ds-chat-launcher .ds-chat-launcher-icon {
  width: 2rem;
  height: 2rem;
}
.ds-chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: var(--ds-radius-full);
  background: var(--ds-color-danger);
  color: var(--ds-color-text-on-primary);
  font-family: var(--ds-font-body);
  font-size: 0.6875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  box-shadow: var(--ds-shadow-sm);
}

.ds-chat-window {
  position: fixed;
  right: var(--ds-space-6);
  bottom: calc(4rem + var(--ds-space-4));
  width: 23.75rem; /* komponenteneigene Fenstergröße, keine Token-Entsprechung */
  max-width: calc(100vw - 2rem);
  height: 37.5rem; /* komponenteneigene Fenstergröße, keine Token-Entsprechung */
  max-height: calc(100vh - 4rem - var(--ds-space-8));
  background: var(--ds-color-bg-surface);
  border-radius: var(--ds-radius-xl);
  box-shadow: var(--ds-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--ds-font-body);
  z-index: 1300;
  opacity: 0;
  transform: translateY(1rem) scale(0.98);
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1),
    transform 200ms cubic-bezier(0.2, 0, 0, 1);
}
.ds-chat-window--open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.ds-chat-widget-root--rail .ds-chat-window {
  right: var(--ds-space-4);
  bottom: calc(3rem + 0.5rem + var(--ds-space-8));
  max-height: calc(100vh - 4rem - var(--ds-space-8));
}
@media (prefers-reduced-motion: reduce) {
  .ds-chat-window { transition: opacity 120ms linear; transform: none; }
}
@media (max-width: 640px) {
  .ds-chat-window {
    right: var(--ds-space-4);
    left: var(--ds-space-4);
    bottom: calc(4rem + var(--ds-space-3));
    width: auto;
    height: calc(100vh - 4rem - var(--ds-space-6));
  }
  .ds-chat-widget-root--rail .ds-chat-window {
    bottom: calc(3rem + 0.5rem + var(--ds-space-4));
    height: auto;
    max-height: calc(100vh - 4rem - var(--ds-space-6));
  }
}

.ds-chat-header {
  display: flex;
  align-items: center;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  background: var(--ds-color-primary-600);
  color: var(--ds-color-text-on-primary);
  flex-shrink: 0;
}
.ds-chat-header-info {
  flex: 1;
  min-width: 0;
}
.ds-chat-header-name {
  font-family: var(--ds-font-heading);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ds-chat-header-status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  opacity: 0.9;
}
.ds-chat-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--ds-radius-full);
  background: var(--ds-color-success);
  flex-shrink: 0;
}
.ds-chat-status-dot--offline {
  background: var(--ds-color-text-inverse);
  opacity: 0.5;
}
.ds-chat-new-conversation {
  flex-shrink: 0;
  max-width: 132px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--ds-radius-md);
  background: transparent;
  color: inherit;
  padding: 0.5rem 0.5rem;
  font: inherit;
  font-size: 0.72rem;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}
.ds-chat-new-conversation:hover { background: rgba(255, 255, 255, 0.15); }
.ds-chat-new-conversation:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.ds-chat-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  width: 2rem;
  height: 2rem;
  border-radius: var(--ds-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ds-transition-colors);
  flex-shrink: 0;
}
.ds-chat-close:hover {
  background: rgba(255, 255, 255, 0.15);
}
.ds-chat-close:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-focus-ring);
}

.ds-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--ds-space-4);
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-3);
  background: var(--ds-color-bg-page);
}

.ds-chat-quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 var(--ds-space-4) var(--ds-space-3);
  background: var(--ds-color-bg-page);
  flex-shrink: 0;
}
.ds-chat-quick-questions:empty { display: none; }
.ds-chat-quick-questions-label {
  width: 100%;
  color: var(--ds-color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.ds-chat-quick-question {
  border: 1px solid var(--ds-color-border-default);
  border-radius: var(--ds-radius-full);
  padding: 0.25rem 0.75rem;
  background: var(--ds-color-bg-surface);
  color: var(--ds-color-primary-700);
  cursor: pointer;
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: left;
  transition: var(--ds-transition-colors), var(--ds-transition-shadow);
}
.ds-chat-quick-question:hover:not(:disabled) {
  border-color: var(--ds-color-primary-500);
  background: color-mix(in srgb, var(--ds-color-primary-100) 42%, var(--ds-color-bg-surface));
}
.ds-chat-quick-question:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-focus-ring);
}
.ds-chat-quick-question:disabled { cursor: default; opacity: 0.6; }

.ds-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 85%;
}
.ds-chat-row--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.ds-chat-row--assistant {
  align-self: flex-start;
}

.ds-chat-avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--ds-radius-full);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ds-font-heading);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ds-color-text-on-primary);
  background: var(--ds-color-secondary-600);
}
.ds-chat-row--user .ds-chat-avatar {
  background: var(--ds-color-primary-600);
}

.ds-chat-bubble-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.ds-chat-bubble {
  padding: 0.5rem 0.75rem;
  border-radius: var(--ds-radius-lg);
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ds-chat-row--assistant .ds-chat-bubble {
  background: var(--ds-color-bg-elevated);
  color: var(--ds-color-text-primary);
  border-bottom-left-radius: var(--ds-radius-sm);
}
.ds-chat-row--user .ds-chat-bubble {
  background: var(--ds-color-primary-600);
  color: var(--ds-color-text-on-primary);
  border-bottom-right-radius: var(--ds-radius-sm);
}
.ds-chat-bubble--error {
  background: var(--ds-color-danger);
  color: var(--ds-color-text-on-primary);
}
.ds-chat-meta {
  font-size: 0.6875rem;
  color: var(--ds-color-text-muted);
  padding: 0 0.25rem;
}
.ds-chat-row--user .ds-chat-meta {
  text-align: right;
}
.ds-chat-meta--error {
  color: var(--ds-color-danger);
}

.ds-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
}
.ds-chat-typing-dot {
  width: 0.25rem;
  height: 0.25rem;
  border-radius: var(--ds-radius-full);
  background: var(--ds-color-text-muted);
  animation: ds-chat-typing-bounce 1.2s infinite ease-in-out;
}
.ds-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ds-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ds-chat-typing-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-0.25rem); }
}
@media (prefers-reduced-motion: reduce) {
  .ds-chat-typing-dot { animation: none; }
}

.ds-chat-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-2);
  padding: 0.5rem var(--ds-space-4);
  font-size: 0.8125rem;
  flex-shrink: 0;
}
.ds-chat-banner--error {
  background: var(--ds-color-danger);
  color: var(--ds-color-text-on-primary);
}
.ds-chat-banner--offline {
  background: var(--ds-color-text-muted);
  color: var(--ds-color-text-on-primary);
}
.ds-chat-banner-retry {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: var(--ds-radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--ds-transition-colors);
}
.ds-chat-banner-retry:hover {
  background: rgba(255, 255, 255, 0.15);
}

.ds-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--ds-space-2);
  padding: var(--ds-space-3);
  border-top: 1px solid var(--ds-color-border-subtle);
  background: var(--ds-color-bg-surface);
  flex-shrink: 0;
}
.ds-chat-textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--ds-color-border-default);
  border-radius: var(--ds-radius-md);
  padding: 0.5rem 0.75rem;
  font-family: var(--ds-font-body);
  font-size: 0.875rem;
  line-height: 1.4;
  max-height: 6rem;
  color: var(--ds-color-text-primary);
  background: var(--ds-color-bg-page);
  transition: var(--ds-transition-colors);
}
.ds-chat-textarea:focus-visible {
  outline: none;
  border-color: var(--ds-color-border-focus);
  box-shadow: var(--ds-shadow-focus-ring);
}
.ds-chat-textarea:disabled {
  opacity: 0.6;
}
.ds-chat-send {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--ds-radius-md);
  border: none;
  background: var(--ds-color-primary-600);
  color: var(--ds-color-text-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--ds-transition-colors);
}
.ds-chat-send:hover:not(:disabled) {
  background: var(--ds-color-primary-700);
}
.ds-chat-send:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-focus-ring);
}
.ds-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
