.chat-card {
  position: fixed;
  bottom: 84px; /* weiter oben, nicht über der Statusleiste */
  right: 24px;
  background: color-mix(in srgb, var(--color-ink-2) 18%, transparent);
  backdrop-filter: blur(14px);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(10, 26, 43, 0.16);
  padding: 12px;
  width: min(420px, 90vw);
  max-height: min(80vh, 500px);
  display: none;
  flex-direction: column;
  z-index: 50;
  transform-origin: bottom right;
  will-change: transform;
  pointer-events: auto;
}

.chat-card.active {
  display: flex;
}

.header-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  margin-top: -30px;
}

.zoom-btn,
/*Head Button*/
.close-btn {
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
  border-radius: 6px;
}

.zoom-btn:hover,
.close-btn:hover {
  color: #3b1e34;
  background: #f1f5f9;
}

.chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: color-mix(in srgb, var(--color-ink-2) 60%, transparent);
  border-radius: 999px;
  border: none;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(15, 39, 59, 0.24);
  z-index: 60;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  min-height: 44px;
}

.chat-bubble .bubble-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-bubble:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(15, 39, 59, 0.28);
  background: color-mix(in srgb, var(--color-ink-2) 75%, transparent);
}

.chat-bubble.hidden {
  display: none !important;
}

.chat-header {
  font-size: 1.5rem;
  font-weight: 600;
  color: #bdc0c5;
  margin-bottom: 16px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
  padding: 12px 8px;
  background: transparent;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.structured-response h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: #0f172a;
}

.structured-response h4 {
  margin: 8px 0 4px;
  font-size: 0.95rem;
  color: #0f172a;
}

.structured-response p {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 0.9rem;
}

.structured-response ul {
  margin: 6px 0 8px 18px;
  color: #0f172a;
}

.message {
  padding: 10px 12px;
  border-radius: 8px;
  max-width: 90%;
  word-wrap: break-word;
  font-size: 0.9rem;
  line-height: 1.4;
}

.message.assistant {
  white-space: pre-wrap;
}

/*Chat verlauf eigener Text*/
.message.user {
  background: var(--color-ki-blau);
  color: #e2e8f0;
  align-self: flex-end;
  margin-left: auto;
}

.message.assistant {
  background: #e2e8f0;
  color: #0f172a;
  align-self: flex-start;
}

.message.assistant.thinking {
  opacity: 0.7;
  font-style: italic;
  position: relative;
}

.message.assistant.thinking::after {
  content: "...";
  display: inline-block;
  margin-left: 0.2rem;
  animation: chatbot-dots 1.2s infinite steps(4, end);
  vertical-align: bottom;
}

@keyframes chatbot-dots {
  0%, 20% { content: ""; }
  40% { content: "."; }
  60% { content: ".."; }
  80%, 100% { content: "..."; }
}

.chat-input-area {
  display: flex;
  gap: 8px;
}

#chatInput {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: Arial, sans-serif;
  background: #f8fafc;
  color: #0f172a;
}

#chatInput:focus {
  outline: none;
  border-color: var(--color-ki-blau-300);
  box-shadow: 0 0 0 3px rgba(227, 230, 234, 0.1);
}

#sendBtn {
  background: var(--color-ki-blau);
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

#sendBtn:hover {
  background: var(--color-ki-blau-300);
}

#sendBtn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.counter-card.active {
  display: block;
}

.counter-card {
  display: none;
}

@media (max-width: 640px) {
  .chat-card {
    right: 14px;
    left: 14px;
    width: auto;
    max-height: calc(100vh - 72px);
  }

  .chat-bubble {
    right: 16px;
    bottom: 16px;
  }
}
