:root {
  --ew8-deep: #073f43;
  --ew8-teal: #0f8f8d;
  --ew8-teal-light: #e8f7f5;
  --ew8-lime: #9fca3b;
  --ew8-lime-dark: #709622;
  --ew8-ink: #173236;
  --ew8-muted: #627477;
  --ew8-border: #dce8e7;
  --ew8-white: #ffffff;
  --ew8-shadow: 0 22px 60px rgba(7, 63, 67, 0.22);
}

.ew8-chat-root,
.ew8-chat-root * {
  box-sizing: border-box;
}

.ew8-chat-root {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ew8-ink);
  line-height: 1.45;
}

.ew8-chat-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 7px 18px 7px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--ew8-deep);
  color: var(--ew8-white);
  box-shadow: 0 14px 34px rgba(7, 63, 67, 0.28);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.ew8-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(7, 63, 67, 0.34);
}

.ew8-chat-launcher:focus-visible,
.ew8-chat-panel button:focus-visible,
.ew8-chat-panel textarea:focus-visible {
  outline: 3px solid rgba(159, 202, 59, 0.55);
  outline-offset: 2px;
}

.ew8-chat-launcher.is-hidden {
  pointer-events: none;
  opacity: 0;
  transform: scale(0.85);
}

.ew8-chat-eight,
.ew8-chat-brand-eight {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--ew8-lime);
  color: var(--ew8-deep);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.ew8-chat-eight {
  width: 42px;
  height: 42px;
  font-size: 29px;
  line-height: 1;
}

.ew8-chat-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(190px, 1fr) auto auto auto;
  width: min(390px, calc(100vw - 28px));
  height: min(650px, calc(100vh - 36px));
  max-height: 650px;
  overflow: hidden;
  border: 1px solid rgba(7, 63, 67, 0.12);
  border-radius: 24px;
  background: var(--ew8-white);
  box-shadow: var(--ew8-shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 180ms ease;
}

.ew8-chat-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.ew8-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 16px 15px;
  background: var(--ew8-deep);
  color: var(--ew8-white);
}

.ew8-chat-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.ew8-chat-brand-eight {
  width: 40px;
  height: 40px;
  font-size: 27px;
}

.ew8-chat-brand div {
  min-width: 0;
}

.ew8-chat-brand strong,
.ew8-chat-brand span {
  display: block;
}

.ew8-chat-brand strong {
  font-size: 16px;
  letter-spacing: 0.01em;
}

.ew8-chat-brand span {
  margin-top: 1px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
}

.ew8-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.ew8-chat-header-actions button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font: inherit;
  font-size: 22px;
}

.ew8-chat-header-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ew8-white);
}

.ew8-chat-messages {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 10px;
  background:
    radial-gradient(circle at 100% 0, rgba(159, 202, 59, 0.09), transparent 34%),
    linear-gradient(180deg, #fbfdfd 0%, #ffffff 100%);
  scrollbar-width: thin;
  scrollbar-color: #b8ccca transparent;
}

.ew8-chat-message-row {
  display: flex;
  margin: 0 0 12px;
}

.ew8-chat-message-row.is-user {
  justify-content: flex-end;
}

.ew8-chat-message {
  max-width: 84%;
  padding: 11px 13px;
  border-radius: 17px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.ew8-chat-message-row.is-assistant .ew8-chat-message {
  border: 1px solid var(--ew8-border);
  border-bottom-left-radius: 6px;
  background: var(--ew8-white);
  color: var(--ew8-ink);
  box-shadow: 0 5px 16px rgba(7, 63, 67, 0.06);
}

.ew8-chat-message-row.is-user .ew8-chat-message {
  border-bottom-right-radius: 6px;
  background: var(--ew8-teal);
  color: var(--ew8-white);
}

.ew8-chat-quick-replies {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 8px 14px 10px;
  border-top: 1px solid #edf3f2;
  background: var(--ew8-white);
  scrollbar-width: none;
}

.ew8-chat-quick-replies::-webkit-scrollbar {
  display: none;
}

.ew8-chat-quick-replies[hidden] {
  display: none;
}

.ew8-chat-quick-replies button {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid #cfe1df;
  border-radius: 999px;
  background: var(--ew8-teal-light);
  color: var(--ew8-deep);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.ew8-chat-quick-replies button:hover {
  border-color: var(--ew8-teal);
  background: #dff3f1;
}

.ew8-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 9px;
  padding: 11px 12px 8px;
  border-top: 1px solid var(--ew8-border);
  background: var(--ew8-white);
}

.ew8-chat-form textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  padding: 11px 13px;
  border: 1px solid #cbdcda;
  border-radius: 15px;
  background: #fbfdfd;
  color: var(--ew8-ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
}

.ew8-chat-form textarea::placeholder {
  color: #829294;
}

.ew8-chat-send {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--ew8-lime);
  color: var(--ew8-deep);
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  font-weight: 900;
}

.ew8-chat-send:hover {
  background: #acd64b;
}

.ew8-chat-send:disabled,
.ew8-chat-form textarea:disabled {
  cursor: wait;
  opacity: 0.62;
}

.ew8-chat-note {
  margin: 0;
  padding: 0 14px 10px;
  background: var(--ew8-white);
  color: var(--ew8-muted);
  font-size: 10.5px;
  text-align: center;
}

.ew8-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 54px;
}

.ew8-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ew8-teal);
  animation: ew8-chat-bounce 1.1s infinite ease-in-out;
}

.ew8-chat-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.ew8-chat-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.ew8-chat-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes ew8-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 520px) {
  .ew8-chat-root {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .ew8-chat-panel {
    width: calc(100vw - 20px);
    height: min(720px, calc(100dvh - 20px));
    max-height: calc(100dvh - 20px);
    border-radius: 20px;
  }

  .ew8-chat-launcher-label {
    display: none;
  }

  .ew8-chat-launcher {
    width: 58px;
    height: 58px;
    min-height: 58px;
    padding: 8px;
  }

  .ew8-chat-eight {
    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ew8-chat-launcher,
  .ew8-chat-panel,
  .ew8-chat-typing span {
    transition: none;
    animation: none;
  }
}
