:root {
  --metafive-primary: #111827;
}

.metafive-chat-root,
.metafive-chat-root * {
  box-sizing: border-box;
}

.metafive-chat-toggle {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  border: 0;
  background: var(--metafive-primary);
  color: #ffffff;
  font-size: 27px;
  cursor: pointer;
  z-index: 999999;
  box-shadow: 0 14px 35px rgba(0, 0, 0, .25);
}

.metafive-chat-box {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(380px, calc(100vw - 28px));
  height: 560px;
  max-height: calc(100vh - 40px);
  background: #ffffff;
  border-radius: 22px;
  overflow: hidden;
  z-index: 999999;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
  display: none;
  border: 1px solid rgba(17, 24, 39, .1);
}

.metafive-chat-box.is-open {
  display: flex;
  flex-direction: column;
}

.metafive-chat-header {
  padding: 16px;
  background: var(--metafive-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.metafive-chat-header span {
  display: block;
  opacity: .82;
  font-size: 12px;
  margin-top: 3px;
}

.metafive-chat-header button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #ffffff;
  background: rgba(255,255,255,.16);
  font-size: 24px;
  line-height: 1;
}

.metafive-chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: #f8fafc;
}

.metafive-message {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 15px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.metafive-bot {
  background: #ffffff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 5px;
}

.metafive-user {
  margin-left: auto;
  background: var(--metafive-primary);
  color: #ffffff;
  border-bottom-right-radius: 5px;
}

.metafive-thinking {
  opacity: .75;
  font-style: italic;
}

.metafive-message a {
  color: inherit;
  text-decoration: underline;
}

.metafive-products {
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
}

.metafive-product-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 12px;
}

.metafive-product-card strong,
.metafive-product-card span,
.metafive-product-card small {
  display: block;
  margin-bottom: 5px;
}

.metafive-product-actions {
  display: flex;
  gap: 8px;
  margin-top: 9px;
}

.metafive-product-actions a {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--metafive-primary);
  color: #ffffff !important;
  text-decoration: none;
  font-size: 12px;
}

.metafive-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.metafive-chat-form input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 11px 14px;
  outline: none;
  min-width: 0;
}

.metafive-chat-form button {
  border: 0;
  border-radius: 999px;
  padding: 11px 15px;
  background: var(--metafive-primary);
  color: #ffffff;
  cursor: pointer;
}

@media (max-width: 480px) {
  .metafive-chat-box {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }
}
