.fwa-widget-root {
  bottom: max(18px, env(safe-area-inset-bottom));
  position: fixed;
  right: 18px;
  z-index: 9998;
}

.fwa-toggle,
.fwa-form button {
  background: #111;
  border: 1px solid #111;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.fwa-toggle {
  border-radius: 4px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  min-height: 44px;
  padding: 12px 16px;
}

.fwa-panel {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  bottom: 58px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  color: #111;
  display: flex;
  flex-direction: column;
  max-height: min(640px, calc(100vh - 110px));
  position: absolute;
  right: 0;
  width: min(360px, calc(100vw - 36px));
}

.fwa-panel[hidden] {
  display: none;
}

.fwa-header {
  align-items: center;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
}

.fwa-icon {
  background: transparent;
  border: 0;
  color: #111;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  min-height: 36px;
  min-width: 36px;
}

.fwa-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
}

.fwa-message {
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.45;
  max-width: 92%;
  overflow-wrap: break-word;
  padding: 10px 12px;
  white-space: pre-wrap;
}

.fwa-user {
  align-self: flex-end;
  background: #111;
  color: #fff;
}

.fwa-assistant {
  align-self: flex-start;
  background: #f5f5f5;
  color: #111;
}

.fwa-actions {
  align-items: center;
  border-top: 1px solid #eee;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 10px 14px;
}

.fwa-actions a,
.fwa-clear {
  background: transparent;
  border: 0;
  color: #111;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}

.fwa-form {
  border-top: 1px solid #eee;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.fwa-form textarea {
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  min-height: 44px;
  padding: 9px 10px;
  resize: vertical;
}

.fwa-form button {
  border-radius: 4px;
  min-height: 44px;
  padding: 0 14px;
}

.fwa-form button:disabled {
  cursor: wait;
  opacity: 0.55;
}

@media (max-width: 640px) {
  .fwa-widget-root {
    bottom: max(12px, env(safe-area-inset-bottom));
    right: 12px;
  }

  .fwa-panel {
    bottom: 56px;
    max-height: min(520px, calc(100vh - 96px));
    width: min(330px, calc(100vw - 24px));
  }

  .woocommerce-cart .fwa-widget-root,
  .woocommerce-checkout .fwa-widget-root {
    bottom: max(82px, env(safe-area-inset-bottom));
  }
}
