:root {
  --page-top: #55b4e3;
  --page-bottom: #347fba;
  --card: #ffffff;
  --card-soft: #eef6fa;
  --text: #17242d;
  --muted: #687781;
  --accent: #419fd3;
  --accent-hover: #328bbd;
  --border: #dce8ee;
  --shadow: 0 18px 44px rgb(17 73 110 / 24%);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--text);
  background: var(--page-bottom);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: linear-gradient(180deg, var(--page-top), var(--page-bottom));
  background-attachment: fixed;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.brand {
  min-height: 52px;
  display: flex;
  align-items: center;
}

.brand__home {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brand__icon {
  width: 43px;
  height: 43px;
}

.brand__name {
  font-size: clamp(25px, 7vw, 31px);
  font-weight: 900;
  letter-spacing: -1.2px;
  line-height: 1;
  text-shadow: 0 2px 10px rgb(13 72 109 / 16%);
}

.share-button {
  width: 44px;
  height: 44px;
  margin-left: auto;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 15px;
  color: #fff;
  background: rgb(0 0 0 / 16%);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}

.share-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-button:hover {
  background: rgb(0 0 0 / 25%);
  transform: translateY(-1px);
}

.share-button:active {
  transform: scale(.95);
}

.content {
  flex: 1;
  padding: 30px 0 20px;
  display: flex;
  align-items: center;
}

.card {
  width: 100%;
  border-radius: 30px;
  color: var(--text);
  background: var(--card);
  box-shadow: var(--shadow);
}

.profile-card {
  min-height: 430px;
  padding: 36px 27px 28px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.state {
  width: 100%;
  display: grid;
  place-items: center;
  transform-origin: center;
}

.state--out {
  animation: state-out .18s ease-in both;
}

.state--in {
  animation: state-pop .38s ease-out both;
}

.loader {
  min-height: 100px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.loader span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s infinite ease-in-out;
}

.loader span:nth-child(2) {
  animation-delay: .13s;
}

.loader span:nth-child(3) {
  animation-delay: .26s;
}

.profile,
.error-state {
  width: 100%;
  text-align: center;
}

.avatar-wrap {
  width: 132px;
  height: 132px;
  margin: 0 auto 22px;
  position: relative;
}

.avatar {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card-soft);
  box-shadow: 0 8px 25px rgb(23 72 101 / 18%);
}

.avatar--fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #66bce5, #3189be);
  font-size: 52px;
  font-weight: 900;
  text-transform: uppercase;
}

.profile__name {
  margin: 0;
  font-size: clamp(27px, 7.5vw, 34px);
  line-height: 1.08;
  letter-spacing: -.8px;
  overflow-wrap: anywhere;
}

.verified-badge {
  width: 21px;
  height: 21px;
  margin-left: 6px;
  display: inline-grid;
  place-items: center;
  vertical-align: 3px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.profile__username {
  margin-top: 7px;
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
}

.profile__meta {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.profile__description {
  max-width: 440px;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-line;
}

.telegram-button,
.copy-button {
  width: 100%;
  margin-top: 25px;
  padding: 16px 22px;
  display: block;
  border: 0;
  border-radius: 17px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 9px 22px rgb(65 159 211 / 27%);
  text-align: center;
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}

.telegram-button:hover,
.copy-button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.telegram-button:active,
.copy-button:active {
  transform: scale(.98);
}

.error-state__code {
  color: var(--accent);
  font-size: 72px;
  font-weight: 950;
  letter-spacing: -5px;
  line-height: 1;
}

.error-state h1 {
  margin: 24px 0 9px;
  font-size: 29px;
  letter-spacing: -.7px;
}

.error-state p,
.desktop-qr p,
.share-dialog p {
  margin: 0 auto;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}

.desktop-qr {
  display: none;
}

.qr-code {
  width: fit-content;
  padding: 13px;
  border-radius: 18px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e1e9ed;
}

.qr-code img,
.qr-code canvas {
  display: block;
}

.share-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 25px;
  color: var(--text);
  background: var(--card);
  box-shadow: 0 22px 60px rgb(8 35 52 / 58%), inset 0 0 0 1px rgb(95 172 214 / 55%);
}

.share-dialog[open] {
  animation: state-pop .4s ease-out both;
}

.share-dialog--closing[open] {
  animation: dialog-close .22s ease-in both;
}

.share-dialog::backdrop {
  background: rgb(16 49 70 / 25%);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  animation: backdrop-in .24s ease-out both;
}

.share-dialog--closing::backdrop {
  animation: backdrop-out .22s ease-in both;
}

.share-dialog__content {
  padding: 35px 26px 26px;
  position: relative;
  text-align: center;
}

.share-dialog h2 {
  margin: 0 38px 8px;
  font-size: 27px;
}

.share-dialog__qr {
  margin: 20px auto;
}

.share-dialog__qr img,
.share-dialog__qr canvas {
  width: min(190px, 54vw) !important;
  height: min(190px, 54vw) !important;
}

.dialog-close {
  width: 38px;
  height: 38px;
  padding: 0;
  position: absolute;
  top: 15px;
  right: 16px;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--card-soft);
  cursor: pointer;
}

.dialog-close::before,
.dialog-close::after {
  content: "";
  width: 18px;
  height: 3px;
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 99px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.dialog-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

#share-url {
  width: 100%;
  margin-top: 20px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  background: var(--card-soft);
  font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-button {
  margin-top: 13px;
}

.copy-button--success {
  animation: copy-success .42s ease-in-out;
}

@keyframes bounce {
  0%, 55%, 100% { transform: translateY(0); opacity: .42; }
  28% { transform: translateY(-14px); opacity: 1; }
}

@keyframes state-out {
  to { opacity: 0; transform: scale(.84); }
}

@keyframes state-pop {
  0% { opacity: 0; transform: scale(.72); }
  65% { opacity: 1; transform: scale(1.025); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes dialog-close {
  to { opacity: 0; transform: translateY(12px) scale(.92); }
}

@keyframes backdrop-in {
  from { -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); }
}

@keyframes backdrop-out {
  to { opacity: 0; -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0); }
}

@keyframes copy-success {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.055); }
  72% { transform: scale(.98); }
}

@media (min-width: 760px) {
  .page {
    width: min(100%, 1050px);
    padding-inline: 28px;
  }

  .share-button {
    display: none !important;
  }

  .content {
    display: grid;
    grid-template-columns: minmax(280px, .78fr) minmax(420px, 1.22fr);
    gap: 22px;
  }

  .content--profile-ready .desktop-qr:not([hidden]) {
    min-height: 430px;
    padding: 36px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: qr-slide-out .52s cubic-bezier(.22, .75, .25, 1) both;
  }

  .desktop-qr__code {
    margin-bottom: 24px;
  }

  .desktop-qr__code img,
  .desktop-qr__code canvas {
    width: 210px !important;
    height: 210px !important;
  }

  .desktop-qr h2 {
    margin: 0 0 8px;
    font-size: 23px;
  }

  .profile-card {
    min-height: 430px;
    grid-column: 1 / -1;
    width: min(100%, 600px);
    justify-self: center;
    position: relative;
    z-index: 2;
    will-change: transform;
  }

  .content--profile-ready .profile-card {
    grid-column: 2;
    width: 100%;
  }
}

@keyframes qr-slide-out {
  from {
    opacity: 0;
    transform: translateX(calc(100% + 22px)) scale(.96);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-top: #245f83;
    --page-bottom: #163e59;
    --card: #152630;
    --card-soft: #203640;
    --text: #f3f7f9;
    --muted: #afbdc5;
    --border: #58717e;
    --shadow: 0 18px 45px rgb(0 15 24 / 45%);
  }

  .avatar {
    box-shadow: 0 8px 25px rgb(0 8 12 / 38%);
  }

  .qr-code {
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-height: 680px) and (max-width: 759px) {
  .page {
    padding-top: 16px;
  }

  .content {
    padding-top: 18px;
  }

  .profile-card {
    min-height: 365px;
    padding-block: 26px;
  }

  .avatar-wrap {
    width: 105px;
    height: 105px;
    margin-bottom: 16px;
  }
}
