body.referral-open { overflow: hidden; }
body.referral-open .bottom-nav { visibility: hidden; }

.referral-page {
  --ref-blue: #0876ef;
  --ref-deep: #0648c8;
  --ref-red: #e52d4d;
  position: fixed;
  z-index: 30;
  inset: 0;
  left: 50%;
  width: min(100%, 520px);
  overflow: hidden;
  color: #171b24;
  background: #f5f6fb;
  font-family: Inter, "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 180ms ease, visibility 180ms ease;
  -webkit-font-smoothing: antialiased;
}
.referral-page.open { opacity: 1; visibility: visible; pointer-events: auto; }
.referral-page *, .referral-page *::before, .referral-page *::after { box-sizing: border-box; }
.referral-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.referral-scroll::-webkit-scrollbar { display: none; }

.referral-hero {
  position: relative;
  height: 286px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(ellipse at 82% 88%, rgba(77, 176, 255, .48), transparent 38%),
    linear-gradient(145deg, #0879f4 0%, #086ce5 54%, #0759d4 100%);
}
.referral-hero::before,
.referral-hero::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 255, 255, .13);
  transform: rotate(31deg);
  pointer-events: none;
}
.referral-hero::before {
  width: 180px;
  height: 54px;
  top: 85px;
  right: -48px;
  border-radius: 22px;
}
.referral-hero::after {
  width: 110px;
  height: 34px;
  top: 138px;
  right: 22px;
  border-radius: 18px;
}
.referral-brand { position: absolute; top: 58px; left: 50%; width: 178px; height: auto; transform: translateX(-50%); }
.referral-hero-copy { position: absolute; z-index: 2; top: 123px; left: 24px; width: 62%; }
.referral-kicker { margin: 0 0 7px; color: rgba(255,255,255,.76); font-size: 9px; font-weight: 700; letter-spacing: 1.5px; }
.referral-hero-copy h1 {
  margin: 0;
  color: #ffbd19;
  font-size: clamp(31px, 8.4vw, 42px);
  font-weight: 800;
  line-height: .96;
  letter-spacing: -.9px;
  text-shadow: 1px 2px 0 #e85b0c, 2px 4px 0 rgba(4,53,145,.54);
}
.referral-hero-copy h1 span { color: #ffd442; }
.referral-hero-note { margin: 10px 0 0; max-width: 175px; color: rgba(255,255,255,.88); font-size: 11px; line-height: 1.35; }

.referral-art { position: absolute; right: 15px; bottom: 13px; width: 164px; height: 162px; }
.referral-orbit {
  position: absolute;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
}
.referral-orbit-one { inset: 11px 8px 4px 20px; transform: rotate(-24deg) scaleY(.7); }
.referral-orbit-two { inset: 24px 0 20px 34px; transform: rotate(28deg) scaleY(.65); }
.referral-person { position: absolute; z-index: 1; bottom: 8px; width: 53px; height: 99px; }
.referral-person i {
  position: absolute;
  top: 1px;
  left: 13px;
  width: 25px;
  height: 27px;
  border-radius: 48% 48% 42% 42%;
  background: #f2c49e;
  box-shadow: inset -5px 0 #d99b7e;
}
.referral-person i::before {
  position: absolute;
  top: -5px;
  left: -1px;
  width: 27px;
  height: 13px;
  content: "";
  border-radius: 15px 15px 6px 6px;
  background: #332d36;
}
.referral-person b {
  position: absolute;
  top: 24px;
  left: 4px;
  width: 43px;
  height: 68px;
  border-radius: 19px 19px 8px 8px;
  background: linear-gradient(135deg, #fff 0%, #dceaff 50%, #bcd8ff 100%);
  box-shadow: 0 8px 14px rgba(5,48,134,.2);
}
.referral-person-one { left: 3px; transform: scale(.83) rotate(-7deg); }
.referral-person-two { right: 1px; transform: scale(.96) rotate(7deg); }
.referral-person-two b { background: linear-gradient(135deg, #fdfdff, #b5c9ff); }
.referral-phone {
  position: absolute;
  z-index: 3;
  top: 18px;
  left: 54px;
  width: 61px;
  height: 116px;
  padding: 15px 8px 8px;
  border: 3px solid rgba(255,255,255,.92);
  border-radius: 13px;
  background: linear-gradient(160deg, #f9fcff, #dce9ff);
  box-shadow: 0 9px 20px rgba(4,40,119,.32);
  transform: rotate(-5deg);
}
.referral-phone-speaker { position: absolute; top: 6px; left: 22px; width: 13px; height: 2px; border-radius: 2px; background: #8da6d6; }
.referral-phone-logo { display: grid; place-items: center; width: 27px; height: 27px; margin: 8px auto 10px; border-radius: 50%; color: #fff; background: #174bc7; font-size: 8px; font-weight: 800; }
.referral-phone-line { display: block; height: 4px; margin: 5px 0; border-radius: 5px; background: #bfd1f3; }
.referral-phone-line.short { width: 67%; }
.referral-phone-button { display: block; height: 10px; margin-top: 8px; border-radius: 6px; background: #1478ed; }
.referral-coin {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #fff3b0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #ffd84d, #f5a51a);
  box-shadow: 0 4px 9px rgba(5,49,138,.25);
  font-size: 16px;
  font-weight: 800;
}
.referral-coin-one { top: 2px; right: 5px; }
.referral-coin-two { bottom: 24px; left: 19px; width: 23px; height: 23px; font-size: 14px; }

.referral-card {
  position: relative;
  z-index: 4;
  margin: -24px 22px 0;
  padding: 21px 19px 18px;
  border: 1px solid rgba(22,112,235,.32);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 9px 25px rgba(19,58,114,.11);
}
.referral-card-intro { margin: 0 0 18px; color: #343a45; font-size: 15px; font-weight: 500; line-height: 1.4; }
.referral-details { display: grid; grid-template-columns: minmax(0,1fr) 102px; align-items: center; gap: 12px; }
.referral-fields { min-width: 0; display: grid; gap: 13px; }
.referral-field { display: grid; gap: 6px; min-width: 0; color: #626a76; font-size: 12px; }
.referral-input-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 39px;
  border: 1px solid #e1e5eb;
  border-radius: 8px;
  background: #f3f4f6;
}
.referral-input-wrap input {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0 9px;
  border: 0;
  outline: 0;
  color: #252a32;
  background: transparent;
  font: 13px Inter, "DM Sans", sans-serif;
  text-overflow: ellipsis;
}
.referral-copy {
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-right: 2px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ref-blue);
  background: transparent;
  cursor: pointer;
}
.referral-copy:active { background: #e5efff; }
.referral-copy svg { width: 19px; height: 19px; }
.referral-qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; color: #657080; font-size: 11px; white-space: nowrap; }
.referral-qr {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  padding: 3px;
  border: 1px solid #e9edf2;
  border-radius: 8px;
  background: #fff;
}
.referral-qr img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.referral-qr-center {
  position: absolute;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: #1248c7;
  box-shadow: 0 0 0 2px #1248c7;
  font-size: 6px;
  font-weight: 800;
}
.referral-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  margin-top: 19px;
  border: 0;
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(100deg, #0877ef, #0868e8);
  box-shadow: 0 6px 14px rgba(8,105,232,.2);
  font: 600 16px Inter, "DM Sans", sans-serif;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}
.referral-share:active { transform: scale(.985); box-shadow: none; }
.referral-share svg { width: 21px; height: 21px; }

.referral-list { min-height: 236px; margin-top: 23px; padding: 23px 25px 20px; border-top: 7px solid #eeeff3; background: #fff; }
.referral-list h2 { margin: 0; color: #454951; font-size: 18px; font-weight: 650; }
.referral-list h2 span { font-weight: 500; }
.referral-empty { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin: 50px auto 0; color: #8892a1; font-size: 12px; }
.referral-empty > span { width: 7px; height: 7px; border-radius: 50%; background: #1677eb; animation: referral-pulse 1.1s ease-in-out infinite; }
.referral-empty > span:nth-child(2) { animation-delay: .15s; }
.referral-empty > span:nth-child(3) { animation-delay: .3s; }
.referral-empty p { flex-basis: 100%; margin: 9px 0 0; text-align: center; }
@keyframes referral-pulse { 0%, 60%, 100% { opacity: .34; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.referral-nav {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  align-items: stretch;
  height: calc(68px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid #e4e9f0;
  background: rgba(255,255,255,.97);
  box-shadow: 0 -7px 22px rgba(21,48,88,.07);
}
.referral-nav button {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 1px 2px;
  border: 0;
  color: #969ba4;
  background: transparent;
  font: 11px Inter, "DM Sans", sans-serif;
  cursor: pointer;
}
.referral-nav button.active { color: #0876ef; }
.referral-nav button svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.referral-nav button.active::after { position: absolute; right: 50%; bottom: 0; width: 5px; height: 5px; border-radius: 50%; content: ""; background: #0876ef; transform: translateX(50%); }
.referral-nav .referral-nav-scan {
  align-self: start;
  justify-self: center;
  width: 58px;
  height: 58px;
  margin-top: -20px;
  border: 4px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg,#147ff4,#075bdc);
  box-shadow: 0 4px 12px rgba(8,105,232,.24);
}
.referral-nav .referral-nav-scan svg { width: 27px; height: 27px; }
.referral-toast {
  position: absolute;
  z-index: 8;
  right: 20px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 20px;
  width: fit-content;
  max-width: calc(100% - 40px);
  margin: auto;
  padding: 10px 16px;
  border-radius: 20px;
  color: #fff;
  background: rgba(19,29,44,.91);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.referral-toast.show { opacity: 1; transform: translateY(0); }

@media (max-height: 740px) {
  .referral-hero { height: 250px; }
  .referral-brand { top: 49px; width: 158px; }
  .referral-hero-copy { top: 108px; }
  .referral-art { transform: scale(.88); transform-origin: bottom right; }
  .referral-card { padding-top: 17px; padding-bottom: 15px; }
  .referral-list { min-height: 190px; }
  .referral-empty { margin-top: 35px; }
}
@media (max-width: 360px) {
  .referral-hero { height: 266px; }
  .referral-hero-copy { left: 18px; width: 64%; }
  .referral-art { right: 5px; transform: scale(.86); transform-origin: bottom right; }
  .referral-card { margin-right: 14px; margin-left: 14px; padding-right: 13px; padding-left: 13px; }
  .referral-details { grid-template-columns: minmax(0,1fr) 90px; gap: 7px; }
  .referral-qr { width: 86px; height: 86px; }
  .referral-card-intro { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .referral-page, .referral-share, .referral-toast { transition: none; }
  .referral-empty > span { animation: none; }
}
