:root {
  --bly-forest: #143227;
  --bly-pine: #214437;
  --bly-sand: #f5efe5;
  --bly-sun: #f4b35b;
  --bly-ink: #1e1f1c;
  --bly-card: #ffffff;
  --bly-shadow: 0 20px 45px rgba(12, 26, 20, 0.18);
}

.bly-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  font-family: "Manrope", "Trebuchet MS", sans-serif;
}

.bly-chat.embed {
  position: static;
  right: auto;
  bottom: auto;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bly-chat-toggle {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.2rem;
  background: var(--bly-forest);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: var(--bly-shadow);
  cursor: pointer;
}

.bly-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 30, 24, 0.55);
  backdrop-filter: blur(6px);
  display: none;
}

.bly-chat[data-open="true"] .bly-chat-overlay {
  display: block;
}

.bly-chat-panel {
  width: 100%;
  height: 100%;
  background: var(--bly-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bly-chat-header {
  background: var(--bly-pine);
  color: #fff;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.bly-chat-header strong {
  font-family: "Fraunces", "Times New Roman", serif;
  font-size: 1.1rem;
}

.bly-chat-header span {
  display: block;
  font-size: 0.75rem;
  opacity: 0.8;
  margin-top: 0.2rem;
}

.bly-chat-close {
  border: none;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.bly-chat-voice {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.95rem;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  cursor: pointer;
}

.bly-chat-voice.is-active {
  background: var(--bly-sun);
  color: #3b2b16;
}

.bly-chat-header-title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.bly-chat-header-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.55rem;
}

.bly-chat-play,
.bly-chat-stop {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.9rem;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  cursor: pointer;
}

.bly-chat-play:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bly-chat-messages {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 260px;
  overflow-y: auto;
  background: #faf6ef;
}

.bly-chat-message {
  padding: 0.6rem 0.75rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  max-width: 90%;
}

.bly-chat-message.user {
  align-self: flex-end;
  background: #f3e6d6;
  color: #3b2b16;
}

.bly-chat-message.bly {
  align-self: flex-start;
  background: #fdfcf9;
  border: 1px solid rgba(20, 50, 39, 0.15);
}

.bly-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.9rem 1rem 0.75rem;
  border-top: 1px solid rgba(20, 50, 39, 0.12);
  background: #fff;
}

.bly-chat-form input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(20, 50, 39, 0.2);
  font-family: inherit;
  font-size: 0.9rem;
}

.bly-chat-form button {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  background: var(--bly-sun);
  color: #3b2b16;
  font-weight: 700;
  cursor: pointer;
}

.bly-chat-mic {
  border: 1px solid rgba(20, 50, 39, 0.2);
  background: #fff;
  color: var(--bly-ink);
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}

.bly-chat-mic.is-listening {
  background: var(--bly-sun);
  color: #3b2b16;
  border-color: transparent;
  box-shadow: 0 0 0 6px rgba(244, 179, 91, 0.25);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0% { box-shadow: 0 0 0 2px rgba(244, 179, 91, 0.25); }
  70% { box-shadow: 0 0 0 10px rgba(244, 179, 91, 0.05); }
  100% { box-shadow: 0 0 0 2px rgba(244, 179, 91, 0.25); }
}

.bly-chat-note {
  margin: 0;
  padding: 0 1rem 0.9rem;
  font-size: 0.75rem;
  color: rgba(30, 31, 28, 0.6);
  background: #fff;
}

@media (max-width: 600px) {
  .bly-chat {
    right: 16px;
    bottom: 16px;
    left: auto;
    pointer-events: auto;
  }

  .bly-chat-toggle {
    width: auto;
    margin: 0;
    pointer-events: auto;
  }

  .bly-chat-form {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  .bly-chat.embed {
    pointer-events: auto;
    left: auto;
    right: auto;
    bottom: auto;
  }

  .bly-chat.embed .bly-chat-toggle {
    width: 100%;
    margin: 0.5rem 0 0;
  }
}
