:root {
  --ecr-float-size: 56px;
  --ecr-float-gap: 50px;
  --ecr-float-bottom: 24px;
  --ecr-chat-panel-height: min(410px, max(100px, calc(100dvh - 312px)));
}

#ecr-floating-tools-root {
  position: fixed;
  z-index: 1000;
  right: 24px;
  bottom: var(--ecr-float-bottom);
  width: 0;
  height: 0;
  color: #162536;
  font-family: Quicksand, "Trebuchet MS", Arial, sans-serif;
  pointer-events: none;
}

#ecr-floating-tools-root *,
#ecr-floating-tools-root *::before,
#ecr-floating-tools-root *::after { box-sizing: border-box; }

#ecr-floating-tools-root [hidden] { display: none !important; }

.ecr-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.ecr-float-button {
  position: absolute;
  right: 0;
  display: grid;
  width: var(--ecr-float-size);
  height: var(--ecr-float-size);
  place-items: center;
  padding: 0;
  border: 1px solid #d6e0e8;
  border-radius: 50%;
  background: #fff;
  color: #0d4f8b;
  box-shadow: 0 8px 24px #0d29451f, 0 2px 5px #0d294510;
  cursor: pointer;
  pointer-events: auto;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.ecr-float-button:hover,
.ecr-float-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 11px 28px #0d29452b, 0 2px 5px #0d294510;
}

.ecr-float-button:focus-visible,
.ecr-chat-panel button:focus-visible,
.ecr-chat-panel a:focus-visible,
.ecr-chat-panel input:focus-visible { outline: 3px solid #d8a83e; outline-offset: 3px; }

#ecr-back-to-top { bottom: calc(var(--ecr-float-size) + var(--ecr-float-gap)); }

#ecr-chat-toggle {
  bottom: 0;
  border-color: #0d4f8b;
  background: #0d4f8b;
  color: #fff;
}

#ecr-chat-toggle:hover,
#ecr-chat-toggle:focus-visible { background: #083760; }

.ecr-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(var(--ecr-float-size) + 16px);
  display: flex;
  width: min(366px, calc(100vw - 36px));
  height: var(--ecr-chat-panel-height);
  min-height: 100px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #dce5ec;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 18px 52px #0b294032, 0 4px 14px #0b294014;
  pointer-events: auto;
  transform-origin: bottom right;
}

.ecr-chat-panel.is-open { animation: ecr-chat-enter .2s ease-out both; }

@keyframes ecr-chat-enter {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#ecr-floating-tools-root.ecr-chat-open #ecr-back-to-top {
  bottom: calc(var(--ecr-float-size) + 16px + var(--ecr-chat-panel-height) + var(--ecr-float-gap));
}

.ecr-chat-header {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  background: #0d4f8b;
  color: #fff;
}

.ecr-chat-heading { min-width: 0; }
.ecr-chat-heading strong { display: block; font-size: 13px; font-weight: 700; letter-spacing: .1px; }
.ecr-chat-heading span { display: block; margin-top: 2px; color: #dceaf4; font-size: 10px; }

.ecr-chat-close {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #ffffff4d;
  border-radius: 50%;
  background: transparent;
  color: white;
  cursor: pointer;
}

.ecr-chat-notice {
  padding: 8px 12px;
  border-bottom: 1px solid #e9eef2;
  background: #f5f8fa;
  color: #637487;
  font-size: 9px;
  line-height: 1.45;
}

.ecr-chat-log {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  scrollbar-width: thin;
}

.ecr-chat-bubble {
  max-width: 92%;
  align-self: flex-start;
  padding: 9px 11px;
  border: 1px solid #e3eaf0;
  border-radius: 11px 11px 11px 3px;
  background: #f4f7f9;
  color: #263848;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.ecr-chat-bubble.is-user {
  align-self: flex-end;
  border-color: #d6e6f3;
  border-radius: 11px 11px 3px 11px;
  background: #eaf3f9;
}

.ecr-chat-bubble a { display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; color: #0d4f8b; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

.ecr-chat-prompts {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 11px 9px;
  scrollbar-width: none;
}

.ecr-chat-prompts::-webkit-scrollbar { display: none; }
.ecr-chat-prompts button { flex: 0 0 auto; padding: 6px 9px; border: 1px solid #cfdae3; border-radius: 999px; background: #fff; color: #204d73; font: inherit; font-size: 9px; cursor: pointer; }
.ecr-chat-prompts button:hover { border-color: #0d4f8b; background: #f0f6fa; }

.ecr-chat-form {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-top: 1px solid #e5ebf0;
  background: #fff;
}

.ecr-chat-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid #ccd7e0;
  border-radius: 8px;
  background: #fff;
  color: #1d2c3b;
  font: inherit;
  font-size: 11px;
}

.ecr-chat-input::placeholder { color: #718294; }
.ecr-chat-send { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 8px; background: #0d4f8b; color: #fff; cursor: pointer; }
.ecr-chat-send:hover { background: #083760; }

@media (max-width: 620px) {
  :root { --ecr-float-size: 54px; --ecr-float-bottom: max(16px, env(safe-area-inset-bottom)); --ecr-chat-panel-height: min(410px, max(100px, calc(100dvh - 292px))); }
  #ecr-floating-tools-root { right: 16px; }
  .ecr-chat-panel { width: min(366px, calc(100vw - 32px)); }
}

@media (prefers-reduced-motion: reduce) {
  .ecr-float-button { transition: none; }
  .ecr-chat-panel.is-open { animation: none; }
}
