:root {
  --essemme-teal: #269a9b;
  --essemme-teal-dark: #147b7d;
  --essemme-ink: #0d1d2d;
  --essemme-muted: #637181;
  --essemme-line: #dce5e8;
  --essemme-soft: #eef7f7;
}

.essemme-ai,
.essemme-ai * {
  box-sizing: border-box;
  letter-spacing: 0;
}

.essemme-ai [hidden] {
  display: none !important;
}

.essemme-ai {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 999999;
  color: var(--essemme-ink);
  font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
}

.essemme-ai button,
.essemme-ai textarea {
  font: inherit;
}

.essemme-ai__launcher {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 72px;
  padding: 5px 18px 5px 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--essemme-ink);
  color: #fff;
  box-shadow: 0 16px 38px rgba(13, 29, 45, 0.3), 0 0 0 3px rgba(38, 154, 155, 0.75);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.essemme-ai__launcher:hover,
.essemme-ai__launcher:focus-visible {
  background: #132b3d;
  box-shadow: 0 20px 46px rgba(13, 29, 45, 0.36), 0 0 0 4px rgba(38, 154, 155, 0.9);
  transform: translateY(-2px);
}

.essemme-ai__launcher > img {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 3px solid var(--essemme-teal);
  border-radius: 50%;
  background: var(--essemme-teal);
  object-fit: cover;
  object-position: center 16%;
}

.essemme-ai__launcher-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  white-space: nowrap;
}

.essemme-ai__launcher-copy small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 600;
}

.essemme-ai__launcher-copy strong {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.essemme-ai__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  width: min(390px, calc(100vw - 32px));
  height: min(650px, calc(100vh - 48px));
  max-height: 650px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(13, 29, 45, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(13, 29, 45, 0.26);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.97);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 220ms ease;
}

.essemme-ai.is-open .essemme-ai__panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.essemme-ai.is-open .essemme-ai__launcher {
  opacity: 0;
  pointer-events: none;
}

.essemme-ai__header {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 13px 16px;
  background: var(--essemme-ink);
  color: #fff;
}

.essemme-ai__identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.essemme-ai__identity > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.essemme-ai__identity strong {
  font-size: 15px;
  line-height: 1.25;
}

.essemme-ai__identity small {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.essemme-ai__identity small i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #54d3a6;
}

.essemme-ai__mark {
  display: block;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  overflow: hidden;
  border: 2px solid var(--essemme-teal);
  border-radius: 50%;
  background: var(--essemme-teal);
}

.essemme-ai__mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 16%;
}

.essemme-ai__close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.essemme-ai__close .dashicons {
  width: 24px;
  height: 24px;
  font-size: 24px;
}

.essemme-ai__messages {
  display: flex;
  min-height: 120px;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 16px 10px;
  background: #f5f8f9;
  scrollbar-width: thin;
  scrollbar-color: #bdc9cd transparent;
}

.essemme-ai__message {
  width: fit-content;
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 5px;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
}

.essemme-ai__message--assistant {
  align-self: flex-start;
  border: 1px solid var(--essemme-line);
  background: #fff;
}

.essemme-ai__message--user {
  align-self: flex-end;
  background: var(--essemme-teal);
  color: #fff;
}

.essemme-ai__message.is-typing {
  color: var(--essemme-muted);
  font-size: 12px;
}

.essemme-ai__message.is-typing-welcome::after {
  display: inline-block;
  width: 1px;
  height: 1em;
  margin-left: 3px;
  background: var(--essemme-teal-dark);
  content: "";
  vertical-align: -2px;
  animation: essemme-ai-caret 700ms steps(1, end) infinite;
}

@keyframes essemme-ai-caret {
  50% {
    opacity: 0;
  }
}

.essemme-ai__message.is-error {
  border-color: #f0c9c9;
  color: #8e2e2e;
}

.essemme-ai__quick {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  overflow: visible;
  padding: 10px 16px 12px;
  background: #f5f8f9;
  scrollbar-width: none;
}

.essemme-ai__quick::-webkit-scrollbar {
  display: none;
}

.essemme-ai__quick button {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  height: auto;
  padding: 7px 8px;
  border: 1px solid #c7dfe0;
  border-radius: 5px;
  background: #fff;
  color: var(--essemme-teal-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  white-space: normal;
}

.essemme-ai__recommendations,
.essemme-ai__lead {
  flex: 0 0 auto;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--essemme-line);
  background: #fff;
}

.essemme-ai__section-title {
  display: block;
  margin-bottom: 8px;
  color: var(--essemme-ink);
  font-size: 12px;
  text-transform: uppercase;
}

.essemme-ai__vehicle-rail {
  display: grid;
  grid-auto-columns: minmax(250px, 84%);
  grid-auto-flow: column;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 3px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.essemme-ai__vehicle {
  display: grid;
  min-height: 88px;
  grid-template-columns: 94px 1fr;
  overflow: hidden;
  border: 1px solid var(--essemme-line);
  border-radius: 6px;
  color: var(--essemme-ink);
  text-decoration: none;
  scroll-snap-align: start;
}

.essemme-ai__vehicle:hover {
  border-color: var(--essemme-teal);
  color: var(--essemme-ink);
}

.essemme-ai__vehicle img {
  width: 94px;
  height: 100%;
  min-height: 88px;
  object-fit: cover;
}

.essemme-ai__vehicle-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: 9px 10px;
}

.essemme-ai__vehicle-body strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.essemme-ai__vehicle-body small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--essemme-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.essemme-ai__vehicle-body b {
  margin-top: 5px;
  color: var(--essemme-teal-dark);
  font-size: 13px;
}

.essemme-ai__lead-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 5px;
  background: var(--essemme-soft);
  font-size: 12px;
}

.essemme-ai__consent {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  margin: 10px 0;
  color: var(--essemme-muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1.4;
}

.essemme-ai__consent input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--essemme-teal);
}

.essemme-ai__consent a {
  color: var(--essemme-teal-dark);
}

.essemme-ai__send-lead {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 5px;
  background: var(--essemme-teal);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.essemme-ai__send-lead:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.essemme-ai__success {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border-radius: 5px;
  background: #e9f8f1;
  color: #176a4d;
  font-size: 11px;
  line-height: 1.4;
}

.essemme-ai__composer {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
  padding: 12px 14px 8px;
  border-top: 1px solid var(--essemme-line);
  background: #fff;
}

.essemme-ai__composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid #ccd7da;
  border-radius: 5px;
  outline: none;
  color: var(--essemme-ink);
  font-size: 13px;
  line-height: 1.45;
}

.essemme-ai__composer textarea:focus {
  border-color: var(--essemme-teal);
  box-shadow: 0 0 0 3px rgba(38, 154, 155, 0.12);
}

.essemme-ai__composer button {
  display: grid;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: var(--essemme-teal);
  color: #fff;
  cursor: pointer;
}

.essemme-ai__composer button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.essemme-ai__footnote {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px 10px;
  background: #fff;
  color: #84919d;
  font-size: 9px;
  line-height: 1.35;
  text-align: center;
}

@media (max-width: 600px) {
  .essemme-ai {
    right: 14px;
    bottom: 14px;
  }

  .essemme-ai__launcher {
    min-height: 68px;
    padding: 4px 15px 4px 4px;
  }

  .essemme-ai__launcher > img {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  .essemme-ai__panel {
    position: fixed;
    inset: 10px;
    width: auto;
    height: auto;
    max-height: none;
    transform-origin: bottom right;
  }

  .essemme-ai__messages {
    padding-top: 14px;
  }

  .essemme-ai__quick button {
    min-height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .essemme-ai__launcher,
  .essemme-ai__panel {
    transition: none;
  }
}
