.public-vee {
  --vee-primary: var(--tenant-primary, var(--primary-color, #0f62fe));
  --vee-accent: var(--tenant-accent, var(--accent-color, #0b8d82));
  --vee-ink: #111b2f;
  --vee-muted: #607089;
  --vee-panel: #fff;
  --vee-border: rgba(93, 120, 160, 0.22);
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1250;
  display: grid;
  justify-items: end;
  max-width: calc(100vw - 32px);
  color: var(--vee-ink);
  font-family: inherit;
}

.public-vee--bottom-left {
  right: auto;
  left: max(20px, env(safe-area-inset-left));
  justify-items: start;
}

.public-vee *,
.public-vee *::before,
.public-vee *::after {
  box-sizing: border-box;
  min-width: 0;
}

.public-vee button,
.public-vee input,
.public-vee textarea {
  font: inherit;
}

.public-vee .visually-hidden {
  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;
}

.public-vee__launcher {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  max-width: min(238px, calc(100vw - 24px));
  padding: 6px 14px 6px 6px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--vee-primary), var(--vee-accent));
  box-shadow: 0 12px 30px rgba(15, 40, 80, 0.24), inset 0 1px rgba(255, 255, 255, 0.24);
  cursor: pointer;
}

.public-vee__launcher-avatar,
.public-vee__avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  padding: 1px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: var(--vee-primary);
  background: radial-gradient(circle at 50% 35%, #283dcc, #171a69 72%);
  box-shadow: 0 5px 14px rgba(14, 25, 85, 0.3);
}

.public-vee__launcher-avatar {
  width: 40px;
  height: 40px;
}

.public-vee__mascot {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.public-vee__mascot--launcher {
  transform: scale(1.04);
}

.public-vee__launcher-copy {
  display: grid;
  gap: 1px;
  text-align: left;
}

.public-vee__launcher-copy strong,
.public-vee__launcher-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-vee__launcher-copy small {
  opacity: 0.82;
  font-size: 0.72rem;
}

.public-vee__panel {
  display: grid;
  grid-template-rows: auto auto minmax(132px, 1fr) auto auto;
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 84px));
  max-height: calc(100dvh - 84px);
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--vee-border);
  border-radius: 20px;
  background: color-mix(in srgb, var(--vee-panel) 97%, #edf4ff);
  box-shadow: 0 24px 58px rgba(13, 29, 57, 0.22), 0 3px 12px rgba(13, 29, 57, 0.1);
  transform-origin: bottom right;
  animation: public-vee-enter 180ms ease-out;
}

.public-vee--bottom-left .public-vee__panel {
  transform-origin: bottom left;
}

.public-vee__panel[hidden],
.public-vee__handoff[hidden],
.public-vee__messages[hidden],
.public-vee__composer[hidden] {
  display: none !important;
}

.public-vee__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--vee-primary), var(--vee-accent));
}

.public-vee__avatar {
  width: 40px;
  height: 40px;
}

.public-vee__header > div {
  display: grid;
  gap: 1px;
}

.public-vee__header strong,
.public-vee__header small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-vee__header small {
  opacity: 0.8;
  font-size: 0.72rem;
}

.public-vee__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 11px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.public-vee__privacy,
.public-vee__disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--vee-muted);
  background: #f7f9fc;
}

.public-vee__privacy {
  padding: 7px 11px;
  border-bottom: 1px solid var(--vee-border);
  font-size: 0.69rem;
  line-height: 1.32;
}

.public-vee__privacy i {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--vee-accent);
}

.public-vee__messages {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  background: linear-gradient(180deg, #f6f9fe, #fff 42%);
  scrollbar-width: thin;
}

.public-vee__message {
  display: flex;
  width: 100%;
  margin: 0 0 9px;
}

.public-vee__message--visitor {
  justify-content: flex-end;
}

.public-vee__bubble {
  max-width: 94%;
  padding: 10px 11px;
  border: 1px solid var(--vee-border);
  border-radius: 15px 15px 15px 5px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(19, 44, 82, 0.065);
  font-size: 0.88rem;
}

.public-vee__message--visitor .public-vee__bubble {
  color: #fff;
  border-color: transparent;
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(135deg, var(--vee-primary), color-mix(in srgb, var(--vee-primary) 68%, #142b55));
}

.public-vee__bubble p,
.public-vee__card p,
.public-vee__handoff header p,
.public-vee__disclaimer span {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.42;
}

.public-vee__thinking {
  width: fit-content;
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 14px;
  color: var(--vee-muted);
  background: #edf3fb;
  font-size: 0.82rem;
}

.public-vee__cards {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.public-vee__card {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #dbe5f2;
  border-radius: 12px;
  background: #f9fbfe;
}

.public-vee__card p,
.public-vee__card small {
  color: var(--vee-muted);
}

.public-vee__actions,
.public-vee__suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.public-vee__action,
.public-vee__suggestion {
  max-width: 100%;
  padding: 6px 9px;
  overflow-wrap: anywhere;
  border: 1px solid color-mix(in srgb, var(--vee-primary) 45%, #d7e1ee);
  border-radius: 999px;
  color: var(--vee-primary);
  background: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.public-vee__action--primary {
  color: #fff;
  border-color: transparent;
  background: var(--vee-primary);
}

.public-vee__composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 7px;
  padding: 9px 10px;
  border-top: 1px solid var(--vee-border);
  background: #fff;
}

.public-vee__composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 88px;
  resize: none;
  padding: 10px 11px;
  border: 1px solid #cbd8e9;
  border-radius: 12px;
  color: var(--vee-ink);
  background: #fff;
}

.public-vee__send,
.public-vee__handoff-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 14px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--vee-primary);
  font-weight: 800;
  cursor: pointer;
}

.public-vee__send:disabled,
.public-vee__handoff-submit:disabled {
  opacity: 0.58;
  cursor: wait;
}

.public-vee__disclaimer {
  padding: 7px 10px;
  border-top: 1px solid var(--vee-border);
  font-size: 0.64rem;
  line-height: 1.32;
}

.public-vee__handoff {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.public-vee__handoff-form,
.public-vee__handoff-form header,
.public-vee__handoff-grid {
  display: grid;
  gap: 12px;
}

.public-vee__handoff-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  color: var(--vee-primary);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.public-vee__handoff-form h3 {
  margin: 0;
}

.public-vee__handoff-form header p {
  color: var(--vee-muted);
  font-size: 0.82rem;
}

.public-vee__handoff-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.public-vee__handoff-grid label {
  display: grid;
  gap: 5px;
  color: #36455c;
  font-size: 0.78rem;
  font-weight: 700;
}

.public-vee__handoff-grid input,
.public-vee__handoff-grid textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd8e9;
  border-radius: 10px;
  color: var(--vee-ink);
  background: #fff;
}

.public-vee__handoff-message,
.public-vee__handoff-consent {
  grid-column: 1 / -1;
}

.public-vee__handoff-consent {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.public-vee__handoff-consent input {
  width: 18px;
  height: 18px;
}

.public-vee__honeypot {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
}

.public-vee__handoff-status {
  min-height: 20px;
  margin: 0;
  color: var(--vee-muted);
  font-size: 0.82rem;
}

.public-vee__handoff-status[data-state="success"] {
  color: #087a54;
}

.public-vee__handoff-status[data-state="error"] {
  color: #b42318;
}

.public-vee :focus-visible {
  outline: 3px solid color-mix(in srgb, var(--vee-primary) 40%, transparent);
  outline-offset: 2px;
}

@keyframes public-vee-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 720px) {
  .public-vee,
  .public-vee--bottom-left {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: auto;
    justify-items: end;
    max-width: none;
  }

  .public-vee--bottom-left {
    right: auto;
    left: max(10px, env(safe-area-inset-left));
    justify-items: start;
  }

  .public-vee__panel {
    position: static;
    width: min(380px, calc(100vw - 20px));
    height: min(500px, calc(100dvh - 78px));
    max-height: calc(100dvh - 78px);
    margin-bottom: 8px;
    border-radius: 18px;
  }

  .public-vee__launcher {
    max-width: calc(100vw - 20px);
  }
}

@media (max-width: 460px) {
  .public-vee__handoff-grid {
    grid-template-columns: 1fr;
  }

  .public-vee__handoff-message,
  .public-vee__handoff-consent {
    grid-column: auto;
  }

  .public-vee__send span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

@media (max-width: 420px) {
  .public-vee,
  .public-vee--bottom-left {
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
  }

  .public-vee__panel {
    position: fixed;
    inset: 8px;
    width: auto;
    height: auto;
    max-height: none;
    margin: 0;
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .public-vee__panel {
    animation: none;
  }
}
