.wd-chat {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 45;
  color: var(--ink, #1b1d1d);
}

.wd-chat :is(button, select, input) { font: inherit; color: inherit; }
.wd-chat button { cursor: pointer; }
.wd-chat :is(button, select, input, a):focus-visible {
  outline: 3px solid #365f19;
  outline-offset: 2px;
}

.wd-chat .wd-chat-toggle,
.wd-chat .wd-chat-form button {
  min-height: 44px;
  padding: .6rem .95rem;
  border: 1px solid #76af3d;
  border-radius: .5rem;
  background: var(--green, #9bdc53);
  font-weight: 800;
}

.wd-chat-toggle { box-shadow: 0 5px 18px #14270c29; }
.wd-chat :is(.wd-chat-toggle, .wd-chat-form button):hover { background: #b3eb76; }
.wd-chat-panel[hidden] { display: none; }

.wd-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + .6rem);
  display: flex;
  flex-direction: column;
  width: min(24rem, calc(100vw - 2rem));
  height: min(32rem, calc(100dvh - 5.75rem));
  background: #fff;
  border: 1px solid #c8d5c1;
  border-radius: .75rem;
  box-shadow: 0 12px 40px #14270c36;
}

.wd-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .5rem;
  padding: .35rem .65rem .35rem 1rem;
  color: #172311;
  background: #eef6e7;
  border-radius: .7rem .7rem 0 0;
  border-bottom: 1px solid #d5e5cc;
}

.wd-chat-header h2 { margin: 0; font-size: 1.15rem; }
.wd-chat button.wd-chat-close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: .4rem;
  background: transparent;
  font-size: 1.65rem;
}
.wd-chat button.wd-chat-close:hover { background: #dfeeda; }

.wd-chat-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: .85rem;
  scrollbar-gutter: stable;
}

.wd-chat-intro, .wd-chat-turn p { margin: 0; overflow-wrap: anywhere; }
.wd-chat-turn { display: grid; gap: .45rem; padding-block: .35rem .65rem; }
.wd-chat-visitor, .wd-chat-reply { border-radius: .55rem; padding: .6rem .75rem; }
.wd-chat-visitor { justify-self: end; background: #e2f3d5; }
.wd-chat-reply { justify-self: start; background: #f1f3ef; }
.wd-chat-reply a { display: inline-block; margin-top: .25rem; font-weight: 750; color: #31581e; }
.wd-chat-picker { display: grid; gap: .4rem; margin-top: .75rem; }
.wd-chat-picker label { font-weight: 750; }
.wd-chat-questions { display: grid; gap: .35rem; }

.wd-chat-questions button, .wd-chat select, .wd-chat input {
  min-width: 0;
  min-height: 44px;
  padding: .45rem .6rem;
  background: #fff;
  border: 1px solid #aab7a3;
  border-radius: .4rem;
}
.wd-chat-questions button { text-align: left; }
.wd-chat-questions button:hover { background: #eff7e8; border-color: #609333; }

.wd-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .4rem;
  padding: .6rem;
  border-top: 1px solid #d5e5cc;
}

@media (max-width: 540px) {
  .wd-chat-panel { width: min(24rem, calc(100vw - 1.5rem)); }
  .wd-chat { right: max(.75rem, env(safe-area-inset-right)); }
}
