:root {
  --hao-referral-control-height: 36px;
  --hao-referral-control-radius: 10px;
  --hao-referral-control-padding: 0 10px;
  --hao-referral-control-border: color-mix(in srgb, currentColor 13%, transparent);
  --hao-referral-control-background: transparent;
  --hao-referral-control-hover-background: color-mix(in srgb, currentColor 6%, transparent);
  --hao-referral-control-focus: color-mix(in srgb, currentColor 34%, transparent);
}

.hao-referral-mount {
  display: inline-flex;
  align-items: center;
  color: inherit;
  font: inherit;
}

.hao-referral-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: var(--hao-referral-control-height);
  padding: var(--hao-referral-control-padding);
  border: 1px solid var(--hao-referral-control-border);
  border-radius: var(--hao-referral-control-radius);
  background: var(--hao-referral-control-background);
  color: inherit;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.hao-referral-trigger:hover {
  border-color: color-mix(in srgb, currentColor 24%, transparent);
  background: var(--hao-referral-control-hover-background);
}

.hao-referral-trigger:focus-visible {
  outline: 3px solid var(--hao-referral-control-focus);
  outline-offset: 2px;
}

.hao-referral-trigger svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hao-referral-overlay[hidden] {
  display: none !important;
}

.hao-referral-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 8, 12, 0.48);
  backdrop-filter: blur(8px);
}

.hao-referral-dialog {
  width: min(460px, 100%);
  max-height: min(720px, calc(100dvh - 32px));
  overflow: auto;
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 18px;
  background: Canvas;
  color: CanvasText;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  padding: 22px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hao-referral-dialog header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.hao-referral-dialog h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hao-referral-intro {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  opacity: .62;
}

.hao-referral-close {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 9px;
  background: color-mix(in srgb, currentColor 6%, transparent);
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.hao-referral-close:focus-visible,
.hao-referral-link button:focus-visible,
.hao-referral-status button:focus-visible,
.hao-referral-share:focus-visible {
  outline: 3px solid color-mix(in srgb, currentColor 24%, transparent);
  outline-offset: 2px;
}

.hao-referral-benefit {
  display: grid;
  gap: 7px;
  padding: 15px 16px;
  border: 1px solid color-mix(in srgb, currentColor 9%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, currentColor 3.5%, transparent);
}

.hao-referral-benefit.is-pro {
  border-color: color-mix(in srgb, #d9a400 28%, transparent);
  background: color-mix(in srgb, #d9a400 7%, Canvas);
}

.hao-referral-benefit strong {
  font-size: 14px;
  line-height: 1.35;
}

.hao-referral-benefit span {
  font-size: 12px;
  line-height: 1.55;
  opacity: .7;
}

.hao-referral-link {
  margin-top: 18px;
}

.hao-referral-link > span {
  display: block;
  margin: 0 0 7px;
  font-size: 11px;
  font-weight: 650;
  opacity: .62;
}

.hao-referral-link > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px 5px 5px 11px;
  border: 1px solid color-mix(in srgb, currentColor 10%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, currentColor 3%, transparent);
}

.hao-referral-link code {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  opacity: .72;
}

.hao-referral-link button,
.hao-referral-status button,
.hao-referral-share {
  appearance: none;
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 9px;
  background: Canvas;
  color: inherit;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.hao-referral-link button {
  min-height: 32px;
  flex: 0 0 auto;
  padding: 0 10px;
}

.hao-referral-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
}

.hao-referral-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 11px;
  opacity: .62;
}

.hao-referral-stats strong {
  color: CanvasText;
  font-size: 12px;
  opacity: 1;
}

.hao-referral-share {
  min-height: 38px;
  padding: 0 15px;
  border-color: CanvasText;
  background: CanvasText;
  color: Canvas;
}

.hao-referral-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 16px;
  border-radius: 14px;
  background: color-mix(in srgb, currentColor 3.5%, transparent);
}

.hao-referral-loading span {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, currentColor 16%, transparent);
  border-top-color: currentColor;
  border-radius: 999px;
  animation: hao-referral-spin .8s linear infinite;
}

.hao-referral-loading p {
  margin: 0;
  font-size: 12px;
  opacity: .66;
}

.hao-referral-status.is-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, #d33 28%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, #d33 5%, Canvas);
}

.hao-referral-status.is-error p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.hao-referral-status.is-error button {
  min-height: 30px;
  padding: 0 9px;
  flex: 0 0 auto;
}

@keyframes hao-referral-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hao-referral-trigger,
  .hao-referral-loading span {
    transition: none;
    animation: none;
  }
}

@media (pointer: coarse) {
  .hao-referral-trigger {
    min-height: max(44px, var(--hao-referral-control-height));
  }
}

@media (max-width: 560px) {
  .hao-referral-overlay {
    align-items: end;
    padding: 0;
  }

  .hao-referral-dialog {
    width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 20px 16px max(18px, env(safe-area-inset-bottom));
  }

  .hao-referral-footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .hao-referral-share {
    width: 100%;
  }
}
