.referral-dialog {
  --ref-ink: #161615;
  --ref-text: #47463f;
  --ref-muted: #8b8a83;
  --ref-line: #ebe9e3;
  --ref-gold: #a37a34;
  --ref-gold-soft: #f8f3e7;
  --ref-num: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'PingFang SC', sans-serif;
  box-sizing: border-box;
  width: min(500px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 26px 26px 24px;
  border: 1px solid #e4e2dc;
  border-radius: 12px;
  color: var(--ref-ink);
  background: #fff;
  box-shadow: 0 32px 80px -24px #11110f61, 0 2px 6px #11110f0d;
  font: 13px/1.65 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: contain;
}
.referral-dialog::backdrop { background: #1212106b; backdrop-filter: blur(6px); }
.referral-dialog *, .referral-dialog *::before, .referral-dialog *::after { box-sizing: border-box; }
.referral-dialog [hidden] { display: none !important; }
.referral-dialog :is(h2,h3,p,dl,dd) { margin: 0; }
.referral-dialog button, .referral-dialog input, .referral-dialog textarea { font: inherit; }
.referral-dialog button { cursor: pointer; }
.referral-dialog button:disabled { cursor: not-allowed; }
.referral-dialog :focus-visible { outline: 2px solid var(--ref-gold); outline-offset: 3px; }
.referral-dialog a { color: var(--ref-ink); text-decoration: none; }
.ref-icon { width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Heading */
.ref-heading { position: relative; padding-right: 40px; }
.ref-title-row { display: flex; align-items: center; gap: 13px; }
.ref-badge { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px; background: linear-gradient(145deg, #fcf8ee, #f0e4c8); box-shadow: inset 0 0 0 1px #e9dab7; }
.ref-crown { width: 21px; height: 21px; }
.referral-dialog h2 { font-size: 20px; font-weight: 600; line-height: 1.3; letter-spacing: -.3px; }
.ref-subtitle { margin-top: 2px !important; color: var(--ref-muted); font-size: 12.5px; word-break: keep-all; }
.ref-close { display: grid; place-items: center; position: absolute; right: -8px; top: -6px; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 7px; background: none; color: #a09f98; transition: background .15s, color .15s; }
.ref-close:hover { background: #f4f3ef; color: var(--ref-ink); }
.ref-close:focus-visible { outline-offset: 0; }

/* Invitation card: the code and link are the main actions. */
.ref-card { margin-top: 22px; padding: 18px 18px 16px; border-radius: 10px; color: #f3ecdd; background: radial-gradient(130% 160% at 100% 0%, #3b3223 0%, #1d1c19 50%, #141413 100%); box-shadow: inset 0 1px 0 #ffffff12, 0 12px 26px -16px #14120cb3; }
.ref-code-row { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.ref-code-label { display: block; color: #c9b17e; font-size: 11.5px; letter-spacing: .12em; }
.ref-code { display: block; margin-top: 3px; color: #fff; font: 600 27px/1.25 var(--ref-num); letter-spacing: .16em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ref-copy-code { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; color: #eadfc6; background: #ffffff0a; border: 1px solid #ffffff2e; border-radius: 7px; font-size: 12px !important; flex-shrink: 0; transition: background .15s, border-color .15s; }
.ref-copy-code .ref-icon { width: 13px; height: 13px; }
.ref-copy-code:hover:not(:disabled) { background: #ffffff17; border-color: #ffffff4d; }
.ref-link-row { display: flex; align-items: stretch; gap: 8px; }
.ref-link-field { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; padding: 9px 12px; background: #ffffff0f; border: 1px solid #ffffff1a; border-radius: 7px; color: #a59a84; }
.ref-link-field .ref-icon { width: 14px; height: 14px; }
.ref-link-field input { min-width: 0; width: 100%; padding: 0; border: 0; background: transparent; color: #d8cfbd; text-overflow: ellipsis; font-size: 12px; outline-offset: 6px; }
.ref-link-field input::placeholder { color: #8e8574; }
.ref-copy-link { flex-shrink: 0; padding: 9px 16px; border: 0; border-radius: 7px; color: #241b08; background: linear-gradient(180deg, #ecd39b, #cda558); box-shadow: inset 0 1px 0 #ffffff59; font-size: 12.5px !important; font-weight: 600; transition: filter .15s; }
.ref-copy-link:hover:not(:disabled) { filter: brightness(1.05); }
.ref-copy-link:disabled, .ref-copy-code:disabled { opacity: .4; }
.ref-feedback { color: #e6cd94; font-size: 12px; margin-top: 10px !important; }
.ref-fallback { margin-top: 10px; }
.ref-fallback label { display: block; color: #c9b17e; font-size: 11.5px; margin-bottom: 5px; }
.ref-fallback textarea { display: block; width: 100%; padding: 8px 10px; background: #ffffff0f; border: 1px solid #ffffff24; border-radius: 7px; font-size: 12px; color: #f3ecdd; resize: vertical; }

/* Stats */
.ref-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px !important; border: 1px solid var(--ref-line); border-radius: 10px; }
.ref-stats > div { padding: 12px 16px 11px; }
.ref-stats > div + div { border-left: 1px solid var(--ref-line); }
.ref-stats dt { color: var(--ref-muted); font-size: 12px; }
.ref-stats dd { margin-top: 2px; font: 600 24px/1.35 var(--ref-num); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ref-stats dd small { margin-left: 3px; color: var(--ref-muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.ref-stats > div:last-child dd { color: var(--ref-gold); }

/* Rules */
.ref-rules { margin-top: 22px; }
.referral-dialog h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.ref-rule { display: flex; gap: 12px; align-items: baseline; margin-top: 8px; }
.ref-rule-index { display: inline-block; width: 18px; flex-shrink: 0; color: var(--ref-gold); font: 600 12px/1 var(--ref-num); font-variant-numeric: tabular-nums; }
.ref-rule p { font-size: 13px; color: var(--ref-text); text-wrap: pretty; }
.ref-rule strong { color: var(--ref-ink); font-weight: 600; }
.ref-examples { margin: 10px 0 0 30px !important; padding: 8px 12px; border-radius: 7px; background: var(--ref-gold-soft); color: #7a6136; font-size: 12px; text-wrap: balance; }
.ref-examples span { white-space: nowrap; }
.ref-conditions { margin-top: 12px !important; font-size: 12px; color: var(--ref-muted); line-height: 1.75; text-wrap: pretty; }
.ref-footer { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--ref-line); font-size: 11.5px; color: var(--ref-muted); }
.ref-state-action { color: var(--ref-ink); font-weight: 600; white-space: nowrap; padding: 0; border: 0; background: none; font-size: 12px !important; }
body:has(.referral-dialog[open]) { overflow: hidden; }
@media (max-width: 480px) {
  .referral-dialog { padding: 22px 18px 20px; width: calc(100% - 24px); }
  .ref-badge { width: 36px; height: 36px; }
  .ref-crown { width: 19px; height: 19px; }
  .referral-dialog h2 { font-size: 19px; }
  .ref-card { margin-top: 18px; padding: 16px 14px 14px; }
  .ref-code { font-size: 23px; letter-spacing: .12em; }
  .ref-link-field { padding: 9px 10px; }
  .ref-link-field > .ref-icon { display: none; }
  .ref-copy-link { padding: 9px 12px; }
  .ref-stats > div { padding: 10px 12px 9px; }
  .ref-stats dd { font-size: 21px; }
  .ref-rules { margin-top: 18px; }
  .ref-examples { margin-left: 0 !important; }
}
