@font-face {
  font-family: "Avatar";
  src:
    url("./res/avatar400.woff2") format("woff2"),
    url("./res/avatar400.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Avatar";
  src:
    url("./res/avatar600.woff2") format("woff2"),
    url("./res/avatar600.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --page-bg: linear-gradient(181.41deg, #e0ebf1 54.82%, #b9c8dd 96.97%);
  --overlay-bg: rgba(188, 202, 222, 0.95);
  --fg-strong: #171717;
  --fg-soft: rgba(23, 23, 23, 0.3);
  --fg-muted: rgba(23, 23, 23, 0.46);
  --font-family-base: "Avatar", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --ease: 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
  --page-max-width: 1760px;
  --avatar-card-width: 208px;
  --avatar-card-padding: 8px;
  --avatar-image-width: 192px;
  --custom-card-size: 200px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--page-bg);
  background-color: #d7e4ef;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  background-color: #d7e4ef;
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  color: #111;
  cursor: default;
  font-family: var(--font-family-base);
  font-weight: 400;
}

body[data-mode="custom"] {
  min-height: 100vh;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

img {
  user-select: none;
  -webkit-user-drag: none;
}

.page {
  width: min(var(--page-max-width), calc(100vw - 48px));
  margin: 0 auto;
  padding: 0 0 56px;
}

body[data-mode="custom"] .page {
  width: 100%;
  padding-bottom: 0;
}

body[data-mode="custom"] .custom-panel {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 24px 0 12px;
  background: linear-gradient(
    180deg,
    rgba(224, 235, 241, 0.94) 0%,
    rgba(224, 235, 241, 0.62) 56%,
    rgba(224, 235, 241, 0.14) 82%,
    rgba(224, 235, 241, 0) 100%
  );
  transition: padding var(--ease);
}

.page-header::after {
  content: "";
  position: absolute;
  inset: auto 0 -18px;
  height: 18px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(224, 235, 241, 0.16) 0%, rgba(224, 235, 241, 0) 100%);
}

.page-header-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 0;
}

.page-title-btn {
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  width: clamp(172px, 22vw, 240px);
  max-width: calc(100vw - 32px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
  transform-origin: center center;
  transition: width var(--ease), transform var(--ease), opacity var(--ease);
}

.page-title-image {
  display: block;
  width: 100%;
  height: auto;
}

.page-title-btn:hover {
  transform: scale(1.03);
}

.page-title-btn:focus-visible {
  outline: 2px solid rgba(29, 88, 182, 0.6);
  outline-offset: 4px;
}

.page-tabs {
  display: flex;
  align-items: center;
  gap: 31px;
  padding: 8px;
  transition: transform var(--ease), opacity var(--ease);
}

.page-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 4px 0 0;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  cursor: default;
  transition: transform var(--ease), color var(--ease), opacity var(--ease);
}

.page-tab:hover,
.page-tab:focus-visible {
  color: var(--fg-strong);
  transform: translateY(-1px);
}

.page-tab:focus-visible {
  outline: none;
}

.page-tab:disabled {
  opacity: 0.44;
  transform: none;
  pointer-events: none;
}

.page-tab-label {
  font-size: 16px;
  line-height: 1.43;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.page-tab-indicator {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--fg-strong);
  opacity: 0;
  transform: scaleX(0.3);
  transform-origin: left center;
  transition: transform var(--ease), opacity var(--ease);
}

.page-tab.is-active {
  color: var(--fg-strong);
}

.page-tab.is-active .page-tab-indicator {
  opacity: 1;
  transform: scaleX(1);
}

.page-tab.is-active:disabled {
  opacity: 1;
}

.page-header.is-compact {
  padding-top: 12px;
  padding-bottom: 12px;
}

.page-header.is-compact .page-title-btn {
  width: clamp(112px, 30vw, 144px);
}

.gallery-panel {
  width: 100%;
}

.gallery-panel[hidden] {
  display: none;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--avatar-card-width), 1fr));
  gap: 24px 20px;
}

.page-loading {
  width: 100%;
  min-height: min(56vh, 420px);
  display: grid;
  place-items: center;
  padding: 0;
}

.loading-image {
  display: block;
  width: 80px;
  height: 80px;
  object-fit: cover;
  opacity: 0.86;
  filter: saturate(0.9) contrast(1.04);
}

@supports (mix-blend-mode: color-burn) {
  .loading-image {
    mix-blend-mode: color-burn;
    opacity: 0.74;
    filter: saturate(0.82) contrast(1.08);
  }
}

.dress {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: var(--avatar-card-width);
  margin: 0 auto;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.dress.is-entering {
  opacity: 0;
  transform: translateY(14px) scale(0.94);
  animation: card-enter 460ms cubic-bezier(0.18, 0.84, 0.22, 1) forwards;
  animation-delay: var(--enter-delay, 0ms);
}

.dress-btn {
  width: var(--avatar-card-width);
  border: 0;
  border-radius: 0;
  padding: var(--avatar-card-padding);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  transition: transform var(--ease), background-color var(--ease), filter var(--ease);
}

.dress-btn:focus-visible {
  transform: translateY(-2px) scale(1.024);
  background: transparent;
  filter: saturate(1.06);
  outline: 2px solid rgba(29, 88, 182, 0.6);
  outline-offset: 2px;
}

.dress-image-stage {
  position: relative;
  display: block;
  width: var(--avatar-image-width);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
}

.dress-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  transition: transform var(--ease);
}

.dress-btn:focus-visible .dress-image {
  transform: scale(1.034);
}

@media (hover: hover) and (pointer: fine) {
  .dress-btn:hover {
    transform: translateY(-2px) scale(1.024);
    background: transparent;
    filter: saturate(1.06);
  }

  .dress-btn:hover .dress-image {
    transform: scale(1.034);
  }
}

.dress-hover-effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.dress-hover-effect-layer.is-active {
  opacity: 1;
}

.dress-hover-effect {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dress-user-name,
.dress-user-id {
  width: var(--avatar-image-width);
  margin: 0 auto;
  text-align: center;
  line-height: 1.43;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dress-user-name {
  margin-top: 8px;
  color: var(--fg-strong);
}

.dress-user-id {
  color: var(--fg-soft);
}

.gallery-empty {
  margin: 24px auto 0;
  text-align: center;
  color: rgba(23, 23, 23, 0.58);
  font-size: 16px;
}

.avatar-unavailable {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px 80px;
}

.avatar-unavailable[hidden] {
  display: none;
}

.avatar-unavailable-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
}

.avatar-unavailable-icon {
  display: block;
  width: 100px;
  height: 100px;
}

.avatar-unavailable-text {
  margin: 0;
  color: rgba(60, 72, 85, 0.4);
  font-size: 16px;
  line-height: 1.43;
  text-align: center;
}

.avatar-unavailable-action {
  min-width: 171px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 0 24px;
  background: var(--fg-strong);
  color: #fff;
  font-size: 16px;
  line-height: 1.43;
  cursor: pointer;
  transform: scale(1);
  transition: transform var(--ease), filter var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .avatar-unavailable-action:hover {
    transform: scale(1.024);
    filter: saturate(1.06);
  }
}

.avatar-unavailable-action:focus-visible {
  outline: 2px solid rgba(29, 88, 182, 0.6);
  outline-offset: 2px;
  transform: scale(1.024);
  filter: saturate(1.06);
}

.gallery-status {
  margin: 18px auto 0;
  min-height: 64px;
  display: grid;
  place-items: center;
  width: 100%;
  text-align: center;
}

.gallery-status[data-mode="hidden"] {
  display: none;
}

.gallery-status[data-mode="loading"] {
  margin-top: 32px;
}

.gallery-status-text {
  margin: 0;
  color: rgba(23, 23, 23, 0.42);
  font-size: 14px;
  line-height: 24px;
}

.gallery-status.is-error {
  min-height: 24px;
}

.gallery-status.is-error .gallery-status-text {
  color: rgba(143, 46, 46, 0.88);
}

#gallerySentinel {
  width: 100%;
  height: 1px;
}

.custom-panel {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.custom-panel[hidden] {
  display: none;
}

.custom-panel.is-loading .custom-track {
  opacity: 0;
}

.custom-panel.is-transitioning .custom-track {
  opacity: 0;
}

.custom-panel.is-ready .custom-track {
  opacity: 1;
}

.custom-panel.is-empty .custom-track {
  opacity: 0.12;
}

.custom-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: default;
  touch-action: none;
}

.custom-viewport.is-dragging {
  cursor: default;
}

.custom-track {
  position: absolute;
  inset: 0 auto auto 0;
  width: 0;
  height: 0;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  opacity: 0;
  transition: opacity 320ms ease;
}

.custom-tile {
  position: absolute;
  inset: 0 auto auto 0;
}

.custom-dress {
  position: absolute;
  inset: 0 auto auto 0;
  width: var(--custom-card-size);
  height: var(--custom-card-size);
}

.custom-dress-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
  transition: transform var(--ease), opacity var(--ease), filter var(--ease);
}

.custom-panel.is-entering .custom-dress-btn {
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  filter: saturate(0.94);
  animation: custom-card-enter 620ms cubic-bezier(0.18, 0.84, 0.22, 1) forwards;
  animation-delay: var(--custom-enter-delay, 0ms);
}

.custom-panel.is-refreshing .custom-viewport {
  pointer-events: none;
}

.custom-panel.is-refreshing .custom-dress-btn {
  animation: custom-card-exit 520ms cubic-bezier(0.22, 0.78, 0.24, 1) forwards;
}

.custom-dress-btn:hover,
.custom-dress-btn:focus-visible {
  transform: scale(1.035);
  filter: saturate(1.05);
}

.custom-dress-btn:focus-visible {
  outline: 2px solid rgba(29, 88, 182, 0.6);
  outline-offset: 6px;
}

.custom-dress-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.custom-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: var(--page-bg);
  background-attachment: fixed;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 1;
  visibility: visible;
  transition: opacity 360ms ease, visibility 0s linear 360ms;
}

.custom-loading .loading-image {
  transform: translateY(0) scale(1);
  transition:
    opacity 320ms ease,
    filter 360ms ease,
    transform 380ms cubic-bezier(0.22, 0.84, 0.24, 1);
}

@supports (mix-blend-mode: color-burn) {
  .custom-loading .loading-image {
    mix-blend-mode: color-burn;
  }
}

.custom-panel.is-ready .custom-loading,
.custom-panel.is-empty .custom-loading {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.custom-panel.is-ready .custom-loading .loading-image,
.custom-panel.is-empty .custom-loading .loading-image {
  opacity: 0;
  transform: translateY(-10px) scale(0.9);
}

.custom-bottom-overlay {
  position: absolute;
  inset: auto 0 0;
  height: 144px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(204, 217, 231, 0) 0%,
    rgba(204, 217, 231, 0.9) 62%,
    #ccd9e7 100%
  );
}

body[data-mode="custom"] .custom-bottom-overlay {
  display: none;
}

.detail-modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--ease), visibility var(--ease);
}

.detail-modal.open {
  opacity: 1;
  visibility: visible;
}

.detail-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
}

.detail-card {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(390.55px, calc(100vw - 32px));
  padding: 24px;
}

.detail-image-stage {
  position: relative;
  width: 100%;
  max-height: min(54vh, 390px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  transform: scale(1);
}

.detail-image-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#detailImagePreview {
  opacity: 1;
  filter: saturate(0.94) contrast(0.98);
  transform: scale(1);
  transition: opacity 280ms ease 40ms, filter 320ms ease;
}

#detailImageFull {
  opacity: 0;
  transform: scale(1.01);
  will-change: opacity, transform;
  transition: opacity 300ms cubic-bezier(0.22, 0.82, 0.24, 1), transform 340ms ease;
}

.detail-image-stage.is-opening {
  animation: detail-pop-in 560ms cubic-bezier(0.2, 0.88, 0.24, 1.12) both;
}

.detail-image-stage.is-full-buffered #detailImageFull {
  opacity: 0.01;
}

.detail-image-stage.is-full-ready #detailImageFull {
  opacity: 1;
  transform: scale(1);
}

.detail-image-stage.is-full-ready #detailImagePreview {
  opacity: 0;
  transition: opacity 320ms ease 80ms;
}

.detail-user-name,
.detail-user-id {
  width: 100%;
  min-height: 1.43em;
  margin: 0;
  text-align: center;
  font-size: clamp(22px, 5.5vw, 32px);
  line-height: 1.43;
  opacity: 0;
  transform: translateY(10px);
}

.detail-user-name {
  margin-top: 16px;
  color: var(--fg-strong);
  font-weight: 600;
}

.detail-user-id {
  color: var(--fg-soft);
}

.detail-user-id.is-pending,
.detail-card.is-content-ready .detail-user-id.is-pending {
  opacity: 0;
  transform: translateY(10px);
  animation: none;
}

.detail-user-id.is-late-reveal {
  animation: detail-content-rise 320ms cubic-bezier(0.22, 0.84, 0.24, 1) both;
}

.detail-download {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 24px;
  margin-top: 104px;
  width: 152px;
  height: 53px;
  border: 0;
  border-radius: 100px;
  background: #000;
  color: #fff;
  font-size: 20px;
  line-height: 1.43;
  cursor: pointer;
  transform: translateY(10px) scale(1);
  transform-origin: center center;
  filter: saturate(1);
  opacity: 0;
  will-change: transform;
  transition: transform var(--ease), opacity var(--ease), filter var(--ease);
}

.detail-download:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

.detail-download:disabled {
  opacity: 0.6;
  cursor: default;
}

.detail-close {
  position: fixed;
  top: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 24px;
  font-size: 34px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.08);
  cursor: default;
  transform: scale(1);
  transition: transform var(--ease), opacity var(--ease);
}

.detail-close:hover {
  transform: scale(1.06);
}

.detail-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 3px;
}

.detail-card.is-content-ready .detail-user-name,
.detail-card.is-content-ready .detail-user-id {
  animation: detail-content-rise 420ms cubic-bezier(0.22, 0.84, 0.24, 1) both;
}

.detail-card.is-content-ready .detail-user-name {
  animation-delay: 40ms;
}

.detail-card.is-content-ready .detail-user-id {
  animation-delay: 110ms;
}

.detail-card.is-content-ready .detail-download {
  opacity: 1;
  transform: translateY(0) scale(1);
  transition-delay: 190ms, 190ms, 0ms;
}

@media (hover: hover) and (pointer: fine) {
  .detail-card.is-content-ready .detail-download:hover:not(:disabled) {
    transform: scale(1.024);
    filter: saturate(1.06);
    transition-delay: 0s, 0s, 0s;
  }
}

.detail-card.is-content-ready .detail-download:focus-visible:not(:disabled) {
  transform: scale(1.024);
  filter: saturate(1.06);
  transition-delay: 0s, 0s, 0s;
}

@keyframes detail-pop-in {
  0% {
    opacity: 0;
    transform: scale(0.78);
  }
  58% {
    opacity: 1;
    transform: scale(1.085);
  }
  78% {
    opacity: 1;
    transform: scale(0.985);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes detail-content-rise {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-enter {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes custom-card-enter {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
    filter: saturate(0.94);
  }
  58% {
    opacity: 1;
    transform: translateY(-2px) scale(1.016);
    filter: saturate(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
}

@keyframes custom-card-exit {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-72px) scale(0.92);
    filter: saturate(0.9);
  }
}

@media (max-width: 768px) {
  :root {
    --avatar-card-width: 100%;
    --avatar-card-padding: 6px;
    --avatar-image-width: 100%;
    --custom-card-size: 148px;
  }

  .page {
    width: calc(100vw - 24px);
    padding-bottom: 40px;
  }

  body[data-mode="custom"] .page {
    width: 100%;
    padding-bottom: 0;
  }

  .page-header {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .page-header.is-compact {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .page-header::after {
    bottom: -12px;
    height: 12px;
  }

  .page-title-btn {
    width: clamp(148px, 44vw, 210px);
    max-width: calc(100vw - 24px);
  }

  .page-header.is-compact .page-title-btn {
    width: clamp(112px, 34vw, 132px);
  }

  .page-tabs {
    gap: 20px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .page-tab-label {
    font-size: 14px;
  }

  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 10px;
  }

  .page-loading {
    min-height: min(46vh, 320px);
    padding: 48px 0 28px;
  }

  .avatar-unavailable {
    padding: 0 24px 64px;
  }

  .dress {
    width: 100%;
    min-width: 0;
  }

  .dress-btn {
    width: 100%;
    min-width: 0;
  }

  .dress-image-stage {
    width: 100%;
    height: auto;
    aspect-ratio: 184 / 200;
  }

  .dress-image {
    width: 100%;
    height: 100%;
  }

  .dress-user-name,
  .dress-user-id {
    width: 100%;
  }

  .custom-bottom-overlay {
    height: 108px;
  }

  .detail-close {
    top: 18px;
    right: 18px;
  }

  .detail-download {
    margin-top: 72px;
    width: 140px;
    height: 48px;
    font-size: 18px;
  }

  .detail-user-name,
  .detail-user-id {
    font-size: clamp(18px, 6vw, 28px);
  }

  .gallery-status[data-mode="loading"] {
    margin-top: 24px;
  }

  .page-title-btn:focus-visible,
  .dress-btn:focus-visible,
  .custom-dress-btn:focus-visible,
  .detail-download:focus-visible,
  .detail-close:focus-visible {
    outline: none;
  }
}
