#sircoi-chat-root {
  --chat-primary: #006e62;
  --chat-primary-dark: #005a51;
  --chat-bg: #ffffff;
  --chat-muted: #64748b;
  --chat-border: #e2e8f0;
  --chat-shadow: 0 12px 40px rgba(15, 23, 42, 0.18);
  --chat-z: 99999;
  font-family: Inter, system-ui, sans-serif;
}

#sircoi-chat-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  border: 2px solid #fff;
  background: #fff;
  padding: 0;
  cursor: pointer;
  box-shadow: var(--chat-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  z-index: var(--chat-z);
  transform: translateZ(0);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#sircoi-chat-toggle:hover {
  transform: translateZ(0) scale(1.05);
  box-shadow: 0 16px 48px rgba(0, 110, 98, 0.35);
}

#sircoi-chat-toggle.proactive-hint::before {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: var(--chat-primary);
  border: 2px solid #fff;
  pointer-events: none;
  z-index: 2;
}

#sircoi-chat-toggle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

#sircoi-chat-panel {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  width: min(400px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 7rem));
  background: var(--chat-bg);
  border-radius: 1rem;
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: var(--chat-z);
  transform: translateZ(0);
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#sircoi-chat-panel.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

#sircoi-chat-header {
  background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
  color: #fff;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

#sircoi-chat-header img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

#sircoi-chat-header h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
}

#sircoi-chat-header p {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  opacity: 0.9;
}

#sircoi-chat-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0.85;
}

#sircoi-chat-close:hover {
  opacity: 1;
}

#sircoi-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #f8fafc;
  overscroll-behavior: contain;
}

.chat-msg {
  max-width: 88%;
  padding: 0.625rem 0.875rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-primary);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}

.chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #1e293b;
  border: 1px solid var(--chat-border);
  border-bottom-left-radius: 0.25rem;
}

.chat-msg.bot strong {
  font-weight: 600;
  color: var(--chat-primary-dark);
}

.chat-msg.bot em {
  font-style: normal;
  font-weight: 500;
  color: #334155;
}

.chat-msg--streaming::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--chat-primary);
  opacity: 0.7;
}

#sircoi-chat-typing {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.5rem;
  font-size: 0.8125rem;
  color: var(--chat-muted);
  padding: 0.25rem 1rem 0.5rem;
  background: #f8fafc;
  visibility: hidden;
  opacity: 0;
  flex-shrink: 0;
}

#sircoi-chat-typing.visible {
  visibility: visible;
  opacity: 1;
}

#sircoi-chat-typing::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--chat-primary);
  opacity: 0.45;
  box-shadow: 10px 0 0 rgba(0, 110, 98, 0.35), 20px 0 0 rgba(0, 110, 98, 0.35);
}

#sircoi-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0 1rem 0.75rem;
  background: #f8fafc;
  flex-shrink: 0;
}

.chat-suggestion {
  font-size: 0.75rem;
  padding: 0.375rem 0.625rem;
  border-radius: 9999px;
  border: 1px solid var(--chat-border);
  background: #fff;
  color: var(--chat-primary-dark);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-suggestion:hover {
  background: #e6f5f3;
  border-color: var(--chat-primary);
}

#sircoi-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--chat-border);
  background: #fff;
  flex-shrink: 0;
}

#sircoi-chat-input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
}

#sircoi-chat-input:focus {
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 2px rgba(0, 110, 98, 0.15);
}

#sircoi-chat-send {
  border: none;
  border-radius: 0.5rem;
  background: var(--chat-primary);
  color: #fff;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

#sircoi-chat-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  #sircoi-chat-panel {
    transition: none;
  }

  #sircoi-chat-toggle:hover {
    transform: translateZ(0);
  }
}

@media (max-width: 480px) {
  #sircoi-chat-panel {
    right: 0.75rem;
    bottom: 5rem;
    width: calc(100vw - 1.5rem);
    height: calc(100vh - 6rem);
  }

  #sircoi-chat-toggle {
    right: 0.75rem;
    bottom: 1rem;
  }
}

@media print {
  #sircoi-chat-root {
    display: none !important;
  }
}
