.xgg-layer {
  position: fixed;
  top: var(--xgg-card-top, 0px);
  z-index: 4;
  width: var(--xgg-width);
  height: var(--xgg-size);
  pointer-events: none;
  transition:
    left 180ms ease-out,
    top 180ms ease-out;
}

.xgg-layer [hidden],
.xgg-layer[hidden] {
  display: none;
}

.xgg-layer:has([data-mascot-arriving]) > .xgg-card {
  visibility: hidden;
}

.xgg-character {
  all: unset;
  display: block;
  cursor: pointer;
  pointer-events: auto;
  width: 100%;
  height: 100%;
}

.xgg-character > div {
  margin-inline: auto;
}

/* 后台预览与官网挂件共用外壳，官网可通过站点允许的外链加载。 */
.xgg-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
  width: var(--xgg-card-width, 276px);
  max-width: var(--xgg-card-max-width, calc(100vw - 16px));
  max-height: calc(100dvh - var(--xgg-card-top, 8px) - 8px);
  padding: 12px 13px 11px;
  border: 1px solid rgba(27, 36, 48, 0.09);
  border-radius: 16px;
  background: var(--chat-background, #ffffff);
  color: var(--chat-foreground, #1b2430);
  box-shadow:
    0 12px 32px -6px rgba(17, 32, 64, 0.16),
    0 2px 8px -2px rgba(17, 32, 64, 0.06);
  font:
    13px/1.45 -apple-system,
    BlinkMacSystemFont,
    'PingFang SC',
    'Hiragino Sans GB',
    'Microsoft YaHei',
    system-ui,
    sans-serif;
  text-align: start;
  pointer-events: auto;
  animation: xggEnter 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.xgg-card[data-titled][data-guidance-style='brand'] {
  border-color: color-mix(
    in srgb,
    var(--xgg-card-theme, var(--accent)) 45%,
    transparent
  );
}

.xgg-card[data-titled][data-guidance-style='diffusion'] {
  border-radius: 20px;
  background-image: radial-gradient(
    ellipse at top left,
    color-mix(in srgb, var(--xgg-card-theme, var(--accent)) 16%, transparent),
    transparent 75%
  );
}

.xgg-card[data-side='right'] {
  border-bottom-left-radius: 5px;
  transform-origin: 0 100%;
}

.xgg-card[data-side='left'] {
  border-bottom-right-radius: 5px;
  transform-origin: 100% 100%;
}

.xgg-card.is-shake {
  animation: xggShake 300ms ease;
}

@keyframes xggEnter {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes xggShake {
  0%,
  100% {
    transform: none;
  }
  22% {
    transform: translateX(-4px);
  }
  55% {
    transform: translateX(4px);
  }
  80% {
    transform: translateX(-2px);
  }
}

@keyframes xggSpin {
  to {
    transform: rotate(360deg);
  }
}

.xgg-card-header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 22px;
}

.xgg-card-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.xgg-card-dot {
  display: none;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--xgg-accent, #f27a1a);
  box-shadow: 0 0 0 3px
    color-mix(in srgb, var(--xgg-accent, #f27a1a) 18%, transparent);
}

.xgg-card[data-kind='lead'] .xgg-card-dot {
  display: block;
}

.xgg-card-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xgg-card-body {
  min-height: 0;
  overflow: auto;
  overflow-wrap: anywhere;
}

.xgg-card-close {
  display: grid;
  place-items: center;
  flex: none;
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  margin: -2px -4px -2px 0;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: color-mix(in srgb, currentColor 52%, transparent);
  cursor: pointer;
  transition:
    background-color 140ms ease,
    color 140ms ease;
}

.xgg-card-close:hover {
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: inherit;
}

.xgg-card-close:focus-visible {
  outline: 2px solid var(--xgg-accent, currentColor);
  outline-offset: -2px;
}

.xgg-card:not([data-titled]) .xgg-card-header {
  position: absolute;
  inset-block-start: 7px;
  inset-inline-end: 7px;
  z-index: 2;
  min-height: 0;
}

.xgg-card:not([data-titled]) .xgg-card-close {
  margin: 0;
}

.xgg-card:not([data-titled]) .xgg-card-title-wrap {
  display: none;
}

.xgg-card:not([data-titled]):not([data-kind='qr']):not([data-kind='lead-done'])
  .xgg-card-body
  > p:first-child {
  padding-inline-end: 24px;
}

.xgg-layer > .xgg-card {
  position: absolute;
  top: var(--xgg-bubble-offset, 0px);
  left: calc(100% + 8px);
}

.xgg-layer[data-side='left'] > .xgg-card {
  left: auto;
  right: calc(100% + 8px);
}

.xgg-layer
  .xgg-card:not([data-titled]):not([data-kind='qr']):not(
    [data-kind='lead-done']
  ) {
  width: max-content;
  min-width: 192px;
  max-width: min(268px, calc(100vw - 16px));
  padding: 13px 14px 13px 15px;
  border: 1px solid rgba(27, 36, 48, 0.08);
  background: var(--chat-background, #ffffff);
  font-size: 13.5px;
  font-weight: 450;
  line-height: 1.52;
  box-shadow:
    0 12px 32px -6px rgba(17, 32, 64, 0.16),
    0 2px 8px -2px rgba(17, 32, 64, 0.06);
}

.xgg-layer:not([data-entry-bubble])[data-side='right'] .xgg-card {
  border-bottom-left-radius: 5px;
}

.xgg-layer:not([data-entry-bubble])[data-side='left'] .xgg-card {
  border-bottom-right-radius: 5px;
}

.xgg-layer[data-entry-bubble] .xgg-card {
  left: 0;
  right: auto;
}

/* ---------- 通用内容与普通气泡按钮 ---------- */
.xgg-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.xgg-content p {
  margin: 0;
  overflow-wrap: anywhere;
}

.xgg-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  align-self: flex-start;
  box-sizing: border-box;
  height: 31px;
  padding: 0 11px 0 13px;
  border: 0;
  cursor: pointer;
  border-radius: 9px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  background: var(--xgg-accent, #f27a1a);
  color: var(--xgg-foreground, #ffffff);
  box-shadow:
    0 2px 8px -2px
      color-mix(in srgb, var(--xgg-accent, #f27a1a) 42%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition:
    filter 150ms ease,
    transform 150ms ease,
    opacity 150ms ease;
}

.xgg-action .xgg-action-arrow {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
  transition: transform 150ms ease;
}

.xgg-action:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.xgg-action:hover:not(:disabled) .xgg-action-arrow {
  transform: translateX(2px);
}

.xgg-action:active:not(:disabled) {
  transform: scale(0.98);
}

.xgg-action:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- 微缩留资表单（全站最小轻巧形态） ---------- */
.xgg-card[data-kind='lead'] {
  width: min(276px, var(--xgg-card-max-width, 276px));
  padding: 12px 13px 11px;
  gap: 8px;
}

.xgg-card[data-kind='lead'][data-multi='true'] {
  width: min(288px, var(--xgg-card-max-width, 288px));
}

.xgg-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.xgg-lead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 6px 7px;
}

.xgg-card[data-multi='true'] .xgg-lead-row {
  flex-direction: column;
  gap: 7px;
}

.xgg-field-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
}

.xgg-field-icon {
  position: absolute;
  left: 9px;
  display: grid;
  place-items: center;
  width: 13.5px;
  height: 13.5px;
  color: color-mix(in srgb, currentColor 45%, transparent);
  pointer-events: none;
  transition: color 140ms ease;
}

.xgg-field-icon svg {
  width: 13.5px;
  height: 13.5px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.95;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.xgg-req-star {
  position: absolute;
  right: 9px;
  color: #dc3f35;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.xgg-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 35px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 9px;
  padding: 0 10px 0 28px;
  background: color-mix(in srgb, currentColor 3%, var(--chat-background, #fff));
  color: inherit;
  font: inherit;
  font-size: 12.5px;
  outline: none;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

.xgg-input.has-req {
  padding-right: 20px;
}

.xgg-input::placeholder {
  color: color-mix(in srgb, currentColor 42%, transparent);
}

.xgg-input:hover:not(:focus):not([readonly]):not(:disabled) {
  border-color: color-mix(in srgb, currentColor 30%, transparent);
}

.xgg-input:focus {
  background: var(--chat-background, #ffffff);
  border-color: var(--xgg-accent, #f27a1a);
  box-shadow: inset 0 0 0 2px
    color-mix(in srgb, var(--xgg-accent, #f27a1a) 16%, transparent);
}

.xgg-input[aria-invalid='true'] {
  border-color: #dc3f35;
  background: color-mix(in srgb, #dc3f35 5%, var(--chat-background, #ffffff));
  box-shadow: inset 0 0 0 2px rgba(220, 63, 53, 0.13);
}

.xgg-field-wrap:focus-within .xgg-field-icon {
  color: var(--xgg-accent, #f27a1a);
}

.xgg-field-wrap:has([aria-invalid='true']) .xgg-field-icon {
  color: #dc3f35;
}

.xgg-extra-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
}

.xgg-extra-grid .xgg-field-wrap.is-full {
  grid-column: 1 / -1;
}

.xgg-extra-grid .xgg-input {
  height: 33px;
  font-size: 12px;
  border-radius: 8px;
}

.xgg-error {
  margin: -1px 0 0;
  flex: 1 0 100%;
  order: 3;
  font-size: 11.5px;
  line-height: 1.35;
  color: #c93228;
}

.xgg-error:empty {
  display: none;
}

.xgg-card[data-multi='true'] .xgg-error {
  order: 0;
  flex: none;
  width: 100%;
  margin: -2px 0 0;
}

.xgg-submit {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 35px;
  padding: 0 13px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(
    135deg,
    var(--xgg-accent, #f27a1a),
    color-mix(in srgb, var(--xgg-accent, #f27a1a) 86%, #000000)
  );
  color: var(--xgg-foreground, #ffffff);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px -3px
    color-mix(in srgb, var(--xgg-accent, #f27a1a) 44%, transparent);
  transition:
    filter 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.xgg-card[data-multi='true'] .xgg-submit {
  width: 100%;
}

.xgg-submit:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.xgg-submit:active:not(:disabled) {
  transform: none;
}

.xgg-submit:disabled {
  cursor: wait;
  opacity: 0.78;
}

.xgg-submit-arrow {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 150ms ease;
}

.xgg-submit:hover:not(:disabled) .xgg-submit-arrow {
  transform: translateX(1.5px);
}

.xgg-spin {
  display: none;
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: xggSpin 700ms linear infinite;
}

.xgg-submit.is-loading .xgg-spin {
  display: inline-block;
}

.xgg-submit.is-loading .xgg-submit-arrow {
  display: none;
}

.xgg-fine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 0;
  font-size: 11px;
  line-height: 1.3;
  color: color-mix(in srgb, currentColor 52%, transparent);
}

.xgg-fine-safe {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.xgg-fine-safe svg {
  flex: none;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

/* ---------- 一体化绿色完成确认微卡（无套娃框、无追问区） ---------- */
.xgg-card[data-kind='lead-done'] {
  width: min(272px, var(--xgg-card-max-width, 272px));
  padding: 12px 34px 12px 13px;
  background: linear-gradient(135deg, #f3fdf7 0%, #ffffff 100%);
  border-color: #bce8cc;
  color: #14532d;
}

.xgg-card[data-kind='lead-done'] .xgg-card-header {
  inset-block-start: 50%;
  inset-inline-end: 8px;
  transform: translateY(-50%);
}

.xgg-card[data-kind='lead-done'] .xgg-card-close {
  color: #5a8a6e;
}

.xgg-card[data-kind='lead-done'] .xgg-card-close:hover {
  background: rgba(22, 163, 74, 0.1);
  color: #14532d;
}

.xgg-done-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.xgg-done-check {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #0d9488);
  color: #ffffff;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.14);
}

.xgg-done-check svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.xgg-done-copy {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.xgg-done-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: #14532d;
}

.xgg-done-sub {
  display: block;
  font-size: 11.5px;
  line-height: 1.35;
  color: #4f7a60;
}

/* ---------- 二维码微缩卡片：精致竖向扫码视窗，完整展示 2 行说明不截断 ---------- */
.xgg-card[data-kind='qr'] {
  width: min(218px, var(--xgg-card-max-width, 218px));
  padding: 13px 14px 13px;
  gap: 0;
  text-align: center;
}

.xgg-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.xgg-qr-top {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 18px;
  box-sizing: border-box;
  font-size: 12px;
  font-weight: 600;
  color: #15803d;
}

.xgg-qr-top-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.16);
}

.xgg-qr-top.is-empty {
  color: color-mix(in srgb, currentColor 55%, transparent);
}

.xgg-qr-top.is-empty .xgg-qr-top-dot {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

.xgg-qr-stage {
  position: relative;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 150px;
  height: 150px;
  padding: 9px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid #e4eaf2;
  box-shadow: 0 6px 18px -6px rgba(17, 32, 64, 0.1);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.xgg-card[data-kind='qr']:hover .xgg-qr-stage:not(.is-empty) {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -6px rgba(17, 32, 64, 0.15);
}

.xgg-qr-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--xgg-accent, #f27a1a);
  opacity: 0.7;
  pointer-events: none;
}

.xgg-qr-corner.tl {
  top: 5px;
  left: 5px;
  border-right: 0;
  border-bottom: 0;
  border-radius: 4px 0 0 0;
}

.xgg-qr-corner.tr {
  top: 5px;
  right: 5px;
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 4px 0 0;
}

.xgg-qr-corner.bl {
  bottom: 5px;
  left: 5px;
  border-right: 0;
  border-top: 0;
  border-radius: 0 0 0 4px;
}

.xgg-qr-corner.br {
  bottom: 5px;
  right: 5px;
  border-left: 0;
  border-top: 0;
  border-radius: 0 0 4px 0;
}

.xgg-qr {
  display: block;
  width: 130px;
  height: 130px;
  border-radius: 4px;
  object-fit: contain;
}

.xgg-qr-stage.is-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  box-shadow: none;
  color: #7b8798;
  font-size: 11.5px;
  line-height: 1.35;
}

.xgg-qr-stage.is-empty svg {
  width: 28px;
  height: 28px;
  stroke: #94a3b8;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.xgg-qr-note {
  margin: 0;
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  color: inherit;
  text-wrap: balance;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.xgg-qr-sub {
  margin: -4px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: color-mix(in srgb, currentColor 54%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .xgg-layer,
  .xgg-card,
  .xgg-card.is-shake,
  .xgg-spin,
  .xgg-qr-stage {
    animation: none;
    transition: none;
  }
}
