.espa {
  --espa-primary: #007a53;
  --espa-text: #17221f;
  --espa-muted: #5c6c67;
  --espa-border: #d7dfdc;
  --espa-bg: #ffffff;
  --espa-soft: #f3f7f5;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 999999;
  font-family: inherit;
  color: var(--espa-text);
}

.espa *, .espa *::before, .espa *::after { box-sizing: border-box; }
.espa [hidden] { display: none !important; }

.espa__launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px 10px 10px;
  min-height: 48px;
  background: var(--espa-primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
}

.espa__launcher:focus-visible,
.espa button:focus-visible,
.espa a:focus-visible,
.espa input:focus-visible {
  outline: 3px solid #111;
  outline-offset: 3px;
}

.espa__launcher-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  font-size: 20px;
}

.espa__dialog {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: min(390px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 110px));
  background: var(--espa-bg);
  border: 1px solid var(--espa-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.espa__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: var(--espa-primary);
  color: #fff;
}

.espa__eyebrow { font-size: 12px; opacity: .86; margin-bottom: 2px; }
.espa__header h2 { margin: 0; color: inherit; font-size: 22px; line-height: 1.2; }
.espa__close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.espa__messages {
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
}

.espa__message {
  max-width: 88%;
  padding: 11px 13px;
  margin: 0 0 10px;
  border-radius: 15px;
  line-height: 1.45;
  font-size: 15px;
}
.espa__message p { margin: 0; }
.espa__message--bot { background: var(--espa-soft); border-bottom-left-radius: 5px; }
.espa__message--user { margin-left: auto; background: var(--espa-primary); color: #fff; border-bottom-right-radius: 5px; }

.espa__choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.espa__choice {
  border: 1px solid var(--espa-primary);
  border-radius: 999px;
  padding: 8px 11px;
  background: #fff;
  color: var(--espa-primary);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.espa__choice:hover { background: var(--espa-soft); }

.espa__results { display: grid; gap: 8px; margin: 0 0 14px; }
.espa__result {
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--espa-border);
  border-radius: 12px;
  color: var(--espa-text);
  text-decoration: none;
  background: #fff;
}
.espa__result:hover { border-color: var(--espa-primary); }
.espa__result strong { color: var(--espa-primary); }
.espa__result span { font-size: 13px; color: var(--espa-muted); line-height: 1.35; }
.espa__result small { font-size: 11px; color: var(--espa-muted); }

.espa__privacy {
  padding: 8px 14px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--espa-muted);
  background: #fbfcfc;
  border-top: 1px solid var(--espa-border);
}

.espa__form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--espa-border);
}
.espa__form input {
  min-width: 0;
  min-height: 44px;
  border: 1px solid #9eaaa6;
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  color: var(--espa-text);
  background: #fff;
}
.espa__form button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 0 14px;
  background: var(--espa-primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.espa__form button:disabled, .espa__form input:disabled { opacity: .65; cursor: wait; }

@media (max-width: 520px) {
  .espa { right: 10px; bottom: 10px; }
  .espa__launcher-label { display: none; }
  .espa__launcher { padding: 9px; }
  .espa__dialog {
    position: fixed;
    left: 8px;
    right: 8px;
    top: 8px;
    bottom: 70px;
    width: auto;
    height: auto;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .espa__dialog { animation: espa-in .16s ease-out; }
  @keyframes espa-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
}
