.chat-fab {
  position: fixed;
  bottom: 4.25rem;
  right: 1.25rem;
  background: #1a1a1a;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  height: 47px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  z-index: 1000;
  transition: background 0.15s, box-shadow 0.15s;
}
.chat-fab:hover {
  background: #333;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.chat-fab svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.chat-panel {
  position: fixed;
  bottom: 7.5rem;
  right: 1.25rem;
  width: 380px;
  max-width: calc(100vw - 2.5rem);
  max-height: 520px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  z-index: 1001;
  overflow: hidden;
}
.chat-panel.open {
  display: flex;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #1a1a1a;
  color: #fff;
  flex-shrink: 0;
}
.chat-header-title {
  font-weight: 600;
  font-size: 14px;
}
.chat-header-subtitle {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}
.chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  padding: 0 4px;
  opacity: 0.7;
  line-height: 1;
}
.chat-close:hover {
  opacity: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
  max-height: 340px;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-msg a {
  color: inherit;
  text-decoration: underline;
}
.chat-msg-user {
  align-self: flex-end;
  background: #1a1a1a;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-assistant {
  align-self: flex-start;
  background: #f5f5f5;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
}

.chat-msg-assistant p {
  margin: 0 0 8px 0;
}
.chat-msg-assistant p:last-child {
  margin-bottom: 0;
}
.chat-msg-assistant ul, .chat-msg-assistant ol {
  margin: 4px 0;
  padding-left: 20px;
}
.chat-msg-assistant strong {
  font-weight: 600;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: #f5f5f5;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: chatBounce 1.4s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
  display: flex;
  padding: 12px;
  border-top: 1px solid #e5e5e5;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}
.chat-input {
  flex: 1;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}
.chat-input:focus {
  border-color: #1a1a1a;
}
.chat-send {
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.chat-send:hover {
  background: #333;
}
.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 11px;
  color: #999;
  border-top: 1px solid #f0f0f0;
  flex-shrink: 0;
}
.chat-footer a {
  color: #666;
}

/* New conversation button */
.chat-new-convo {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  opacity: 0.7;
  line-height: 1;
  margin-right: 8px;
}
.chat-new-convo:hover {
  opacity: 1;
  border-color: rgba(255,255,255,0.6);
}

/* Mobile: full-screen overlay */
@media (max-width: 600px) {
  .chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    max-width: 100%;
    border-radius: 0;
    border: none;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    background: #fff;
  }
  .chat-panel.open {
    display: flex;
  }
  .chat-header {
    flex-shrink: 0;
  }
  .chat-messages {
    flex: 1;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .chat-input-area {
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .chat-footer {
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .chat-fab {
    z-index: 1000;
  }
  .chat-panel {
    z-index: 1002;
  }
}
