#agroterra-chat-open {
  position: fixed;
  inset-inline-end: max(1rem, env(safe-area-inset-right));
  inset-block-end: max(1rem, env(safe-area-inset-bottom));
  z-index: 1000;
  box-shadow: 0 4px 20px #24184633;
  cursor: pointer;
}

#agroterra-chat {
  border: 1px solid #dad4f1;
  border-radius: 20px;
  box-sizing: border-box;
  padding: 1.15rem;
  width: min(100% - 2rem, 25rem);
  max-height: 82dvh;
  margin: auto max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) auto;
  background: #fff;
  color: #251d3a;
  box-shadow: 0 12px 48px #24184633;
}

#agroterra-chat::backdrop { background: #20163466; }
#agroterra-chat header { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; }
#agroterra-chat h2 { font-size: 1.3rem; margin: 0; }
#agroterra-chat p { margin: 0.4rem 0; line-height: 1.45; }
#agroterra-chat [data-chat-close] {
  background: #f1edfc;
  border: 0;
  border-radius: 50%;
  color: #251d3a;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.4rem;
  cursor: pointer;
}

#agroterra-chat [role="log"] {
  max-height: min(35dvh, 17rem);
  overflow: auto;
  margin: 0.75rem 0;
  display: grid;
  gap: 0.5rem;
}

#agroterra-chat [role="log"] div {
  background: #f5f1ff;
  border-radius: 12px;
  padding: 0.65rem;
  overflow-wrap: anywhere;
}

#agroterra-chat [role="log"] a { color: #422b91; text-decoration: underline; }
#agroterra-chat [role="status"] { min-height: 1.2em; font-size: 0.9rem; }
#agroterra-chat label { display: block; margin-bottom: 0.3rem; }
#agroterra-chat form div { display: flex; gap: 0.5rem; }
#agroterra-chat input {
  flex: 1;
  min-width: 0;
  border: 1px solid #786d94;
  border-radius: 8px;
  padding: 0.65rem;
  font: inherit;
}

#agroterra-chat form button { padding: 0.65rem 0.85rem; border: 0; cursor: pointer; }
#agroterra-chat form button:disabled { opacity: 0.65; cursor: wait; }
#agroterra-chat :focus-visible, #agroterra-chat-open:focus-visible { outline: 2px solid #422b91; outline-offset: 2px; }

#agroterra-chat-open[hidden] { display: none; }
