:root {
  color-scheme: light;
  --ink: #111b2d;
  --muted: #6c788a;
  --blue: #3484f4;
  --blue-strong: #176de3;
  --page-start: #f8fbff;
  --page-middle: #e7f2ff;
  --page-end: #cfe6ff;
  --grid-dot: rgba(48, 110, 199, 0.11);
  --surface: rgba(255, 255, 255, 0.78);
  --surface-border: rgba(255, 255, 255, 0.9);
  --control: rgba(255, 255, 255, 0.78);
  --control-hover: #ffffff;
  --item: rgba(255, 255, 255, 0.8);
  --item-border: rgba(58, 104, 165, 0.1);
  --item-hover-border: rgba(52, 132, 244, 0.28);
  --shadow: rgba(35, 84, 146, 0.17);
  --item-shadow: rgba(38, 79, 130, 0.08);
  --soft-blue: rgba(52, 132, 244, 0.11);
  --footer: #8491a3;
  --status-ring: #ffffff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f2f6fc;
  --muted: #a6b0bf;
  --blue: #65a8ff;
  --blue-strong: #82b9ff;
  --page-start: #111722;
  --page-middle: #090d14;
  --page-end: #06080d;
  --grid-dot: rgba(126, 174, 238, 0.08);
  --surface: rgba(20, 25, 34, 0.78);
  --surface-border: rgba(255, 255, 255, 0.09);
  --control: rgba(255, 255, 255, 0.07);
  --control-hover: rgba(255, 255, 255, 0.12);
  --item: rgba(255, 255, 255, 0.065);
  --item-border: rgba(255, 255, 255, 0.08);
  --item-hover-border: rgba(101, 168, 255, 0.32);
  --shadow: rgba(0, 0, 0, 0.42);
  --item-shadow: rgba(0, 0, 0, 0.18);
  --soft-blue: rgba(101, 168, 255, 0.13);
  --footer: #8793a4;
  --status-ring: #151b24;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--page-end);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page-end);
  font-family: "MiSans", "Xiaomi Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  font: inherit;
}

.page-shell {
  position: relative;
  display: grid;
  min-height: 100vh;
  place-items: center;
  overflow: hidden;
  padding: 44px 18px;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 255, 255, 0.88) 0 7%, transparent 28%),
    radial-gradient(circle at 92% 88%, rgba(75, 151, 255, 0.28) 0 11%, transparent 30%),
    linear-gradient(145deg, var(--page-start), var(--page-middle) 50%, var(--page-end));
  transition: background 0.4s ease;
}

:root[data-theme="dark"] .page-shell {
  background:
    radial-gradient(circle at 14% 0%, rgba(75, 133, 211, 0.2), transparent 28%),
    radial-gradient(circle at 92% 88%, rgba(34, 108, 224, 0.22), transparent 31%),
    linear-gradient(145deg, var(--page-start), var(--page-middle) 48%, var(--page-end));
}

.page-shell::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.55;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}

.ambient {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  animation: ambient-float 10s ease-in-out infinite alternate;
}

.ambient-one {
  top: -90px;
  right: -72px;
  width: 280px;
  height: 280px;
  background: linear-gradient(145deg, rgba(87, 160, 255, 0.58), rgba(255, 255, 255, 0.1));
}

.ambient-two {
  bottom: -94px;
  left: -56px;
  width: 190px;
  height: 190px;
  border: 42px solid rgba(255, 255, 255, 0.32);
  animation-delay: -4s;
}

:root[data-theme="dark"] .ambient-two {
  border-color: rgba(72, 137, 232, 0.12);
}

.profile-card {
  position: relative;
  z-index: 1;
  width: min(100%, 540px);
  padding: 32px 28px 26px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  border-radius: 38px;
  background: var(--surface);
  box-shadow: 0 30px 80px var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(28px) saturate(135%);
  animation: card-in 0.7s cubic-bezier(0.2, 0.85, 0.25, 1) both;
  transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

.profile-card::before {
  position: absolute;
  top: -90px;
  left: 10%;
  width: 80%;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  filter: blur(32px);
  content: "";
  pointer-events: none;
}

:root[data-theme="dark"] .profile-card::before {
  background: rgba(83, 145, 230, 0.1);
}

.card-actions {
  position: absolute;
  z-index: 2;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--item-border);
  border-radius: 15px;
  color: var(--ink);
  background: var(--control);
  box-shadow: 0 6px 18px var(--item-shadow);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.25s ease, border-color 0.25s ease;
}

.icon-button:hover {
  border-color: var(--item-hover-border);
  background: var(--control-hover);
  transform: translateY(-2px);
}

.icon-button:active {
  transform: scale(0.94);
}

.icon-button:focus-visible,
.social-chip:focus-visible,
.link-card:focus-visible,
.download-button:focus-visible {
  outline: 3px solid rgba(52, 132, 244, 0.28);
  outline-offset: 3px;
}

.share-button {
  font-size: 14px;
  letter-spacing: 1px;
}

.theme-icon {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffb629;
  box-shadow: 0 0 0 2px rgba(255, 182, 41, 0.12);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s ease, box-shadow 0.3s ease;
}

.theme-icon::after {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--control);
  content: "";
  opacity: 0;
  transform: translate(5px, -5px) scale(0.7);
  transition: opacity 0.25s ease, transform 0.4s ease;
}

.theme-button[data-mode="dark"] .theme-icon {
  background: #8dbbff;
  box-shadow: 0 0 0 2px rgba(141, 187, 255, 0.12);
  transform: rotate(25deg);
}

.theme-button[data-mode="dark"] .theme-icon::after {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

.profile-header {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  align-items: center;
  gap: 22px;
  margin-top: 4px;
  padding-right: 108px;
}

.avatar-wrap {
  position: relative;
  width: 104px;
  flex: 0 0 104px;
}

.avatar {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 5px solid rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  object-fit: cover;
  box-shadow: 0 14px 30px rgba(40, 99, 177, 0.22);
}

:root[data-theme="dark"] .avatar {
  border-color: rgba(255, 255, 255, 0.13);
}

.avatar-placeholder {
  color: #fff;
  background: linear-gradient(145deg, #72b2ff, #2f78ef 58%, #1f57c4);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.status-dot {
  position: absolute;
  right: -2px;
  bottom: 6px;
  width: 20px;
  height: 20px;
  border: 4px solid var(--status-ring);
  border-radius: 50%;
  background: #31cc79;
  box-shadow: 0 0 0 4px rgba(49, 204, 121, 0.11);
}

.identity {
  min-width: 0;
  flex: 1;
  text-align: left;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 36px);
  font-weight: 820;
  letter-spacing: -0.04em;
}

.handle {
  margin: 6px 0 0;
  color: var(--blue);
  font-size: 14px;
  font-weight: 750;
}

.bio {
  max-width: 390px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.social-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 20px 0 23px;
}

.social-chip,
.link-icon {
  display: grid;
  place-items: center;
  font-weight: 800;
}

.social-chip {
  width: 42px;
  height: 42px;
  border: 1px solid var(--item-border);
  border-radius: 15px;
  background: var(--control);
  box-shadow: 0 8px 20px var(--item-shadow);
  animation: social-in 0.48s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(0.24s + var(--social-delay));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.social-chip:hover {
  border-color: var(--item-hover-border);
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 24px var(--item-shadow);
}

.link-list {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
}

.link-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 13px;
  min-height: 86px;
  padding: 12px 16px 12px 12px;
  border: 1px solid var(--item-border);
  border-radius: 24px;
  background: var(--item);
  box-shadow: 0 8px 25px var(--item-shadow);
  animation: rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: var(--delay);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease, background 0.35s ease;
}

.link-card:hover {
  border-color: var(--item-hover-border);
  transform: translateY(-3px) scale(1.008);
  box-shadow: 0 15px 32px var(--item-shadow);
}

.link-card.has-download {
  grid-template-columns: 54px minmax(0, 1fr) auto;
}

.link-icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #72b2ff, #347df4);
  font-size: 20px;
  box-shadow: 0 8px 18px rgba(51, 121, 237, 0.2);
}

.social-chip.has-custom-icon,
.link-icon.has-custom-icon {
  overflow: hidden;
  padding: 0;
  border-color: transparent;
  background: transparent !important;
}

.social-chip .custom-icon,
.link-icon .custom-icon {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: inherit;
  object-fit: cover;
  pointer-events: none;
  transform: scale(1.075);
  transform-origin: center;
}

.link-copy {
  min-width: 0;
}

.link-copy strong,
.link-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-copy strong {
  font-size: 15px;
  line-height: 1.25;
}

.link-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.preview-hint {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 4px 0 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  color: var(--blue) !important;
  background: transparent;
  font-size: 11px !important;
  font-weight: 750;
  line-height: 1.2;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
}

.preview-hint:hover {
  color: var(--blue-strong) !important;
  transform: translateX(2px);
}

.preview-hint:focus-visible {
  outline: 2px solid rgba(52, 132, 244, 0.3);
  outline-offset: 3px;
  border-radius: 4px;
}

.preview-hint::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 6px 1px 1px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px var(--soft-blue);
  content: "";
}

.link-copy .download-count {
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 720;
}

.download-count[data-state="loading"] {
  opacity: 0.65;
}

.download-count[data-state="error"] {
  color: var(--muted);
}

.download-button {
  display: inline-flex;
  min-width: 74px;
  height: 39px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #65adff, #2f7cf4);
  box-shadow: 0 8px 18px rgba(51, 121, 237, 0.24);
  font-size: 13px;
  font-weight: 760;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.download-button:hover {
  box-shadow: 0 11px 23px rgba(51, 121, 237, 0.32);
  filter: saturate(1.08);
  transform: translateY(-2px);
}

.download-button:active {
  transform: scale(0.96);
}

.arrow {
  color: var(--muted);
  font-size: 17px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.link-card:hover .arrow {
  color: var(--blue);
  transform: translate(2px, -2px);
}

footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--footer);
  font-size: 11px;
}

.footer-mark {
  display: block;
  width: 19px;
  height: 19px;
  border-radius: 6px;
  object-fit: cover;
}

.theme-changing *,
.theme-changing *::before,
.theme-changing *::after {
  transition-delay: 0s !important;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes social-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.85);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ambient-float {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  to {
    transform: translate3d(12px, 18px, 0) rotate(5deg);
  }
}

@media (max-width: 560px) {
  .page-shell {
    align-items: start;
    padding: 14px 9px;
  }

  .profile-card {
    padding: 25px 16px 21px;
    border-radius: 31px;
  }

  .card-actions {
    top: 18px;
    right: 16px;
    gap: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 13px;
  }

  .profile-header {
    gap: 14px;
    padding-right: 86px;
  }

  .avatar-wrap {
    width: 82px;
    flex-basis: 82px;
  }

  .avatar {
    width: 82px;
    height: 82px;
    border-width: 4px;
    border-radius: 26px;
  }

  .status-dot {
    bottom: 4px;
    width: 18px;
    height: 18px;
  }

  h1 {
    font-size: clamp(23px, 8vw, 30px);
  }

  .handle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bio {
    font-size: 12.5px;
    line-height: 1.55;
  }

  .social-row {
    margin: 17px 0 20px;
  }

  .link-card,
  .link-card.has-download {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 82px;
    padding: 10px 11px 10px 10px;
    border-radius: 21px;
  }

  .link-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
  }

  .link-copy strong {
    font-size: 13.5px;
  }

  .link-copy small {
    font-size: 10.5px;
  }

  .preview-hint {
    font-size: 10px !important;
  }

  .download-button {
    min-width: 64px;
    height: 35px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: 11.5px;
  }
}

@media (max-width: 390px) {
  .profile-header {
    padding-right: 78px;
  }

  .avatar-wrap {
    width: 72px;
    flex-basis: 72px;
  }

  .avatar {
    width: 72px;
    height: 72px;
    border-radius: 23px;
  }

  .link-card,
  .link-card.has-download {
    grid-template-columns: 44px minmax(0, 1fr) auto;
  }

  .link-icon {
    width: 44px;
    height: 44px;
    border-radius: 15px;
  }

  .download-button {
    min-width: 58px;
    padding: 0 8px;
  }
}

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