#fac-ai-chat {
  --fac-bottom: 92px;
  --fac-right: 24px;
  position: fixed;
  right: var(--fac-right);
  bottom: var(--fac-bottom);
  z-index: 999999;
  font-family: Arial, Helvetica, sans-serif;
}

#fac-ai-chat * {
  box-sizing: border-box;
}

#fac-ai-chat .fac-chat-toggle {
  width: 62px;
  height: 62px;
  min-width: 62px;
  min-height: 62px;
  border-radius: 999px;
  border: 0;
  background: #111;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0,0,0,.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
}

#fac-ai-chat .fac-chat-toggle-icon {
  width: 32px;
  height: 32px;
  display: block;
  color: inherit;
  pointer-events: none;
}

#fac-ai-chat .fac-chat-toggle-icon svg {
  width: 32px;
  height: 32px;
  display: block;
  fill: currentColor;
}

#fac-ai-chat .fac-chat-toggle:hover {
  transform: translateY(-1px);
}

.fac-chat-window {
  width: 370px;
  max-width: calc(100vw - 28px);
  height: 590px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(0,0,0,.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fac-chat-header {
  background: #111;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fac-chat-header strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.fac-chat-header span {
  display: block;
  font-size: 12px;
  opacity: .72;
  margin-top: 2px;
}

.fac-chat-close {
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.fac-chat-disclaimer {
  font-size: 11px;
  line-height: 1.35;
  color: #777;
  background: #f7f7f7;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

.fac-age-panel {
  padding: 10px 12px;
  background: #fffbe8;
  border-bottom: 1px solid #f2e6a8;
  font-size: 13px;
}

.fac-age-panel p {
  margin: 0 0 8px;
}

.fac-age-confirm,
.fac-handoff-send,
.fac-handoff-cancel,
.fac-handoff-open,
.fac-send {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.fac-age-confirm,
.fac-handoff-send,
.fac-send {
  background: #111;
  color: #fff;
  padding: 9px 14px;
}

.fac-handoff-cancel,
.fac-handoff-open {
  background: #eee;
  color: #111;
  padding: 9px 14px;
}

.fac-chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: #f5f5f5;
}

.fac-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 15px;
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.42;
  word-wrap: break-word;
}

.fac-msg a {
  color: inherit;
  text-decoration: underline;
}

.fac-msg-assistant {
  background: #fff;
  color: #111;
  border: 1px solid #eee;
}

.fac-msg-user {
  background: #111;
  color: #fff;
  margin-left: auto;
}

.fac-chat-form {
  border-top: 1px solid #eee;
  background: #fff;
  padding: 10px;
}

.fac-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.fac-chat-input,
.fac-handoff-contact,
.fac-handoff-note {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  outline: none;
}

.fac-chat-input {
  border-radius: 999px;
}

.fac-chat-input:focus,
.fac-handoff-contact:focus,
.fac-handoff-note:focus {
  border-color: #111;
}

.fac-handoff-panel {
  padding: 12px;
  background: #fff;
  border-top: 1px solid #eee;
}

.fac-handoff-panel label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 8px;
}

.fac-handoff-panel input,
.fac-handoff-panel textarea {
  margin-top: 4px;
}

.fac-handoff-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 480px) {
  #fac-ai-chat {
    right: 14px !important;
    bottom: 76px !important;
  }

  .fac-chat-window {
    width: calc(100vw - 28px);
    height: 72vh;
    max-height: 720px;
  }

  #fac-ai-chat .fac-chat-toggle {
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
  }

  #fac-ai-chat .fac-chat-toggle-icon,
  #fac-ai-chat .fac-chat-toggle-icon svg {
    width: 30px;
    height: 30px;
  }
}

#fac-ai-chat .fac-msg p {
  margin: 0 0 8px;
}

#fac-ai-chat .fac-msg p:last-child {
  margin-bottom: 0;
}

#fac-ai-chat .fac-msg ul,
#fac-ai-chat .fac-msg ol {
  margin: 6px 0 10px 20px;
  padding: 0;
}

#fac-ai-chat .fac-msg li {
  margin: 0 0 6px;
  padding-left: 2px;
}

#fac-ai-chat .fac-msg li:last-child {
  margin-bottom: 0;
}

#fac-ai-chat .fac-msg strong {
  font-weight: 700;
}

#fac-ai-chat .fac-msg code {
  background: rgba(0,0,0,.06);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: .92em;
}

/* Store context */
#fac-ai-chat .fac-store-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: #fff;
  border-bottom: 1px solid #eee;
  font-size: 11px;
  line-height: 1.2;
}

#fac-ai-chat .fac-store-label {
  color: #777;
  flex: 0 0 auto;
}

#fac-ai-chat .fac-store-current {
  border: 0;
  background: transparent;
  padding: 2px 0;
  color: #111;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  text-align: left;
}

#fac-ai-chat .fac-store-current.fac-store-unset {
  color: #8a5a00;
}

#fac-ai-chat .fac-store-picker-card {
  width: 100%;
  margin: 0 0 10px;
  padding: 8px;
  background: #fffaf0;
  border: 1px solid #ead9b6;
  border-radius: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,.05);
}

#fac-ai-chat .fac-store-picker-heading {
  margin: 0 0 6px;
  color: #444;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 700;
}

#fac-ai-chat .fac-store-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

#fac-ai-chat .fac-store-option {
  min-height: 38px;
  border: 1px solid #d8d8d8;
  border-radius: 9px;
  background: #fff;
  color: #111;
  padding: 7px 6px;
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
  font-weight: 600;
  cursor: pointer;
  white-space: normal;
}

#fac-ai-chat .fac-store-option:hover,
#fac-ai-chat .fac-store-option.is-selected {
  border-color: #111;
  background: #f0f0f0;
}

#fac-ai-chat .fac-store-cancel {
  display: inline-flex;
  margin-top: 5px;
  border: 0;
  background: transparent;
  color: #777;
  padding: 3px 2px;
  font: inherit;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Animated typing indicator */
#fac-ai-chat .fac-msg-typing {
  width: 54px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
}

#fac-ai-chat .fac-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}

#fac-ai-chat .fac-typing-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #777;
  animation: facTypingBounce 1.15s infinite ease-in-out;
}

#fac-ai-chat .fac-typing-dots i:nth-child(2) {
  animation-delay: .14s;
}

#fac-ai-chat .fac-typing-dots i:nth-child(3) {
  animation-delay: .28s;
}

@keyframes facTypingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: .45;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

#fac-ai-chat .fac-chat-input:disabled,
#fac-ai-chat .fac-send:disabled {
  opacity: .6;
  cursor: wait;
}

@media (prefers-reduced-motion: reduce) {
  #fac-ai-chat .fac-typing-dots i {
    animation: none;
    opacity: .65;
  }
}
