.ec-chat-dock, .ec-chat-panel {
  --chat-green: #123d31;
  --chat-deep: #092f25;
  --chat-gold: #e9cb8f;
  --chat-paper: #f8f7f1;
  --chat-border: #d3ded5;
  font: 400 15px/1.45 system-ui, sans-serif;
}

.ec-chat-dock {
  position: fixed;
  z-index: 80;
  inset: auto max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) auto;
}

.ec-chat-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: transparent;
  color: var(--chat-deep);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.ec-chat-dismiss {
  position: absolute;
  z-index: 1;
  top: -10px;
  right: -9px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid #ded8c8;
  border-radius: 50%;
  background: #fffaf0;
  color: var(--chat-deep);
  box-shadow: 0 3px 12px #0b29283a;
  font: 600 21px/1 system-ui, sans-serif;
  cursor: pointer;
}

.ec-chat-dismiss:hover { background: #f3e6c6; }

.ec-chat-badge {
  position: relative;
  flex: none;
  width: 106px;
  height: 110px;
  box-sizing: border-box;
  isolation: isolate;
  border-radius: 46% 46% 29% 29%;
  background: linear-gradient(145deg, #fff 2%, #9dada4 23%, #f8f6e8 44%, #687d71 58%, #f6f5ed 79%, #96ab9f);
  box-shadow: 0 10px 26px #0b29285c, inset 0 0 1px 1px #e4e9df;
}

.ec-chat-badge::before {
  content: '';
  position: absolute;
  inset: 4px;
  z-index: -1;
  border: 1px solid #f7e7b5a6;
  border-radius: inherit;
  background: radial-gradient(ellipse at 48% 20%, #3d6955, var(--chat-deep) 74%);
}

.ec-chat-wave {
  position: absolute;
  inset: auto -3px 3px auto;
  display: block;
  width: 108px;
  height: 128px;
  max-width: none;
  object-fit: cover;
  object-position: center top;
  clip-path: inset(0 0 0 0 round 0 0 28px 28px);
  filter: drop-shadow(0 1px 1px #0d2e20a0);
}

.ec-chat-portrait {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 52% 29%;
}

.ec-chat-invitation {
  position: relative;
  display: grid;
  gap: 4px;
  max-width: 171px;
  padding: 11px 14px;
  border: 1px solid #d6bd87;
  border-radius: 15px;
  background: #fffaf0;
  text-align: left;
  box-shadow: 0 6px 28px #0b29283a;
}

.ec-chat-invitation::after {
  content: '';
  position: absolute;
  right: -6px;
  top: calc(50% - 5px);
  width: 10px;
  height: 10px;
  transform: rotate(-45deg);
  border-right: 1px solid #d6bd87;
  border-bottom: 1px solid #d6bd87;
  background: #fffaf0;
}

.ec-chat-launch-title { font-size: .95rem; line-height: 1.1; }
.ec-chat-launch-label { color: #4d685b; font-size: .74rem; font-weight: 600; }
.ec-chat-launcher:hover .ec-chat-invitation { background: #f7edd6; }
.ec-chat-launcher:hover .ec-chat-invitation::after { background: #f7edd6; }

.ec-chat-panel {
  position: fixed;
  inset: auto max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) auto;
  width: min(406px, calc(100% - 44px));
  max-width: none;
  max-height: calc(100dvh - 44px);
  height: min(585px, calc(100dvh - 44px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--chat-border);
  border-radius: 24px;
  color: var(--chat-deep);
  background: var(--chat-paper);
  box-shadow: 0 22px 72px #08261d40;
}

.ec-chat-panel[open] { display: flex; flex-direction: column; }
.ec-chat-panel:has(.ec-chat-bubble:only-child) { height: min(450px, calc(100dvh - 44px)); }
.ec-chat-panel:has(.ec-chat-bubble:only-child) .ec-chat-footer { display: none; }
.ec-chat-panel::backdrop { background: #0c2d2626; }

.ec-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(125deg, var(--chat-green), var(--chat-deep));
  border-bottom: 2px solid #d0ac66;
  color: #fff;
}

.ec-chat-header-portrait {
  flex: none;
  width: 94px;
  height: 98px;
  overflow: hidden;
  border: 1px solid var(--chat-gold);
  border-radius: 14px;
  background: #f5eedc;
}

.ec-chat-identity { flex: 1; min-width: 0; }
.ec-chat-panel .ec-chat-title { margin: 0; color: #fff; font: 700 1.22rem/1.2 system-ui, sans-serif; letter-spacing: 0; }
.ec-chat-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #ffffff16; color: #fff; font: 400 26px/1 system-ui, sans-serif; cursor: pointer; }

.ec-chat-transcript {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 13px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 19px 16px 12px;
}

.ec-chat-panel .ec-chat-bubble {
  align-self: flex-start;
  max-width: 91%;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #e4e8de;
  border-radius: 16px 16px 16px 4px;
  background: #fff;
  color: #183d31;
  overflow-wrap: anywhere;
}

.ec-chat-panel .ec-chat-visitor {
  align-self: flex-end;
  border-color: transparent;
  border-radius: 16px 16px 4px 16px;
  background: var(--chat-green);
  color: #fff;
}

.ec-chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: flex-start;
  max-height: 40%;
  overflow: auto;
  padding: 7px 16px 12px;
}

.ec-chat-choice, .ec-chat-continue, .ec-chat-reset {
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  background: #fff;
  color: var(--chat-deep);
  font: 650 .875rem/1.3 system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}

.ec-chat-choice:hover { background: #e9f1e9; }
.ec-chat-intake {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}
.ec-chat-field {
  display: grid;
  gap: 6px;
  flex: 1 1 100%;
  min-width: 0;
  color: var(--chat-deep);
  font: 600 .85rem/1.3 system-ui, sans-serif;
}
.ec-chat-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  color: var(--chat-deep);
  background: #fff;
  font: 400 16px/1.3 system-ui, sans-serif;
}
.ec-chat-input:focus-visible { outline: 3px solid #a17122; outline-offset: 3px; }
.ec-chat-panel:has(.ec-chat-bubble:only-child) .ec-chat-choice:first-child { border-color: #bd9f60; background: #f3e6c6; }
.ec-chat-continue { flex: 1 1 100%; display: flex; align-items: center; justify-content: center; background: var(--chat-deep); color: #fff; text-decoration: none; }
.ec-chat-continue:hover { background: var(--chat-green); color: #fff; }
.ec-chat-footer { border-top: 1px solid #e4e8de; padding: 2px 8px; background: #fff8; }
.ec-chat-reset { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.ec-chat-dock button:focus-visible, .ec-chat-panel :is(button, a):focus-visible { outline: 3px solid #a17122; outline-offset: 3px; }

@media (max-width: 540px) {
  .ec-chat-dock { inset: auto max(16px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) auto; }
  .ec-chat-panel { inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px; width: auto; height: min(600px, calc(100dvh - 16px - env(safe-area-inset-bottom))); max-height: none; }
  .ec-chat-panel::backdrop { background: #0c2d264d; }
  .ec-chat-header-portrait { width: 80px; height: 88px; }
  .ec-chat-badge { width: 84px; height: 89px; }
  .ec-chat-wave { width: 86px; height: 103px; clip-path: inset(0 0 0 0 round 0 0 23px 23px); }
}
