/* 顶部会员入口：外壳 div + 主链接 + 关闭；收起后为皇冠 FAB（登录左侧） */

html body .document-member-top-cta {
  --dm-cta-surface: rgba(255, 255, 255, 0.82);
  --dm-cta-surface-2: rgba(255, 255, 255, 0.94);
  --dm-cta-border: rgba(15, 23, 42, 0.08);
  --dm-cta-border-strong: rgba(15, 23, 42, 0.12);
  --dm-cta-text: #0f172a;
  --dm-cta-muted: rgba(15, 23, 42, 0.52);
  --dm-cta-accent: var(--theme-color, #3eaf7c);
  --dm-cta-badge-bg: color-mix(in srgb, var(--theme-color, #3eaf7c) 14%, rgba(255, 255, 255, 0.96));
  --dm-cta-badge-fg: color-mix(in srgb, var(--theme-color, #3eaf7c) 85%, #0f172a 15%);
  --dm-cta-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 12px 28px -8px rgba(15, 23, 42, 0.12);
  --dm-cta-blur: 14px;

  position: fixed;
  z-index: 480;
  top: max(3.65rem, calc(env(safe-area-inset-top, 0px) + 2.95rem));
  right: max(0.6rem, env(safe-area-inset-right, 0px));
  left: auto;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  max-width: min(17.5rem, calc(100vw - 1rem));
  padding: 0.42rem 2.15rem 0.42rem 0.45rem;
  border-radius: 12px;
  color: var(--dm-cta-text);
  background: linear-gradient(135deg, var(--dm-cta-surface) 0%, var(--dm-cta-surface-2) 100%);
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--dm-cta-border);
  box-shadow: var(--dm-cta-shadow);
  box-sizing: border-box;
  backdrop-filter: blur(var(--dm-cta-blur));
  -webkit-backdrop-filter: blur(var(--dm-cta-blur));
  transition: box-shadow 0.28s ease, border-color 0.22s ease;
  animation: dm-cta-float 3.6s ease-in-out infinite;
  will-change: transform;
  isolation: isolate;
}

html body .document-member-top-cta.is-flying,
html body .document-member-top-cta.is-collapsed,
html body .document-member-top-cta--vip-only {
  animation: none;
  will-change: auto;
}

html body .document-member-top-cta.is-collapsed:not(.document-member-top-cta--vip-only),
html body .document-member-top-cta--vip-only {
  padding: 0;
}

html body .document-member-top-cta.is-flying {
  z-index: 560;
  pointer-events: none;
}

html body .document-member-top-cta::before {
  content: "";
  z-index: 0;
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    125deg,
    color-mix(in srgb, var(--theme-color, #3eaf7c) 45%, transparent),
    transparent 40%,
    transparent 60%,
    color-mix(in srgb, var(--theme-color, #3eaf7c) 35%, transparent)
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.55;
  pointer-events: none;
  animation: dm-cta-shimmer 4.5s ease-in-out infinite;
}

html body .document-member-top-cta.is-flying::before {
  animation: none;
  opacity: 0.4;
}

html body .document-member-top-cta.is-collapsed::before,
html body .document-member-top-cta--vip-only::before {
  display: none;
}

@keyframes dm-cta-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
    box-shadow: var(--dm-cta-shadow);
  }
  50% {
    transform: translate3d(0, -5px, 0);
    box-shadow:
      0 8px 14px -3px rgba(15, 23, 42, 0.1),
      0 20px 40px -14px color-mix(in srgb, var(--theme-color, #3eaf7c) 16%, rgba(15, 23, 42, 0.1));
  }
}

@keyframes dm-cta-shimmer {
  0%,
  100% {
    opacity: 0.35;
    filter: hue-rotate(0deg);
  }
  50% {
    opacity: 0.75;
    filter: hue-rotate(12deg);
  }
}

@keyframes dm-cta-badge-glow {
  0%,
  100% {
    transform: scale(1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  }
  50% {
    transform: scale(1.05);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.45),
      0 0 0 1px color-mix(in srgb, var(--theme-color, #3eaf7c) 25%, transparent);
  }
}

@supports not (backdrop-filter: blur(4px)) {
  html body .document-member-top-cta {
    background: rgba(255, 255, 255, 0.97);
  }
}

html.dark body .document-member-top-cta,
html body.dark .document-member-top-cta {
  --dm-cta-surface: rgba(30, 41, 59, 0.72);
  --dm-cta-surface-2: rgba(15, 23, 42, 0.88);
  --dm-cta-border: rgba(148, 163, 184, 0.14);
  --dm-cta-border-strong: rgba(148, 163, 184, 0.22);
  --dm-cta-text: rgba(248, 250, 252, 0.96);
  --dm-cta-muted: rgba(203, 213, 225, 0.55);
  --dm-cta-badge-bg: color-mix(in srgb, var(--theme-color, #3eaf7c) 22%, rgba(15, 23, 42, 0.95));
  --dm-cta-badge-fg: color-mix(in srgb, var(--theme-color, #3eaf7c) 55%, #f8fafc 45%);
  --dm-cta-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.35), 0 16px 36px -12px rgba(0, 0, 0, 0.55);
}

html body .document-member-top-cta:hover:not(.is-flying):not(.is-collapsed):not(.document-member-top-cta--vip-only) {
  animation-play-state: paused;
  transform: translate3d(0, -8px, 0);
  border-color: var(--dm-cta-border-strong);
  box-shadow:
    0 10px 18px -4px rgba(15, 23, 42, 0.12),
    0 22px 44px -12px color-mix(in srgb, var(--theme-color, #3eaf7c) 22%, rgba(15, 23, 42, 0.14));
}

html.dark body .document-member-top-cta:hover:not(.is-flying):not(.is-collapsed):not(.document-member-top-cta--vip-only),
html body.dark .document-member-top-cta:hover:not(.is-flying):not(.is-collapsed):not(.document-member-top-cta--vip-only) {
  box-shadow:
    0 12px 22px -6px rgba(0, 0, 0, 0.5),
    0 26px 48px -14px color-mix(in srgb, var(--theme-color, #3eaf7c) 28%, rgba(0, 0, 0, 0.45));
}

html body .document-member-top-cta__main {
  z-index: 1;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: inherit;
  border-radius: 8px;
  outline: none;
}

html body .document-member-top-cta__main:focus-visible {
  outline: 2px solid var(--dm-cta-accent);
  outline-offset: 2px;
}

html body .document-member-top-cta__badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 10px;
  background: var(--dm-cta-badge-bg);
  color: var(--dm-cta-badge-fg);
  border: 1px solid color-mix(in srgb, var(--theme-color, #3eaf7c) 22%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  animation: dm-cta-badge-glow 2.8s ease-in-out infinite;
}

html.dark body .document-member-top-cta__badge,
html body.dark .document-member-top-cta__badge {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html body .document-member-top-cta__crown-svg {
  display: block;
  width: 18px;
  height: 18px;
}

html body .document-member-top-cta__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.22;
  gap: 0.08rem;
}

html body .document-member-top-cta__title {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--dm-cta-text);
}

html body .document-member-top-cta__sub {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--dm-cta-muted);
}

/* 关闭：展开态右上角 */
html body .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) .document-member-top-cta__close {
  z-index: 4;
  position: absolute;
  top: 0.32rem;
  right: 0.32rem;
  width: 1.75rem;
  height: 1.75rem;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--dm-cta-border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--dm-cta-muted) 10%, rgba(255, 255, 255, 0.65));
  color: var(--dm-cta-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

html.dark body .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) .document-member-top-cta__close,
html body.dark .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) .document-member-top-cta__close {
  background: color-mix(in srgb, var(--dm-cta-muted) 15%, rgba(15, 23, 42, 0.5));
}

html body .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) .document-member-top-cta__close:hover {
  color: var(--dm-cta-text);
  border-color: var(--dm-cta-border-strong);
  background: color-mix(in srgb, var(--theme-color, #3eaf7c) 12%, transparent);
}

html body .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) .document-member-top-cta__close:focus-visible {
  outline: 2px solid var(--dm-cta-accent);
  outline-offset: 2px;
}

html body .document-member-top-cta__close-x {
  position: relative;
  display: block;
  width: 12px;
  height: 12px;
}

html body .document-member-top-cta__close-x::before,
html body .document-member-top-cta__close-x::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
}

html body .document-member-top-cta__close-x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

html body .document-member-top-cta__close-x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* 收起后：皇冠 FAB，外边框 + 主题色细环 */
html body .document-member-top-cta__fab {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  text-decoration: none;
  color: var(--dm-cta-badge-fg);
  background: linear-gradient(145deg, var(--dm-cta-surface) 0%, var(--dm-cta-surface-2) 100%);
  border: 1px solid var(--dm-cta-border-strong);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--theme-color, #3eaf7c) 40%, transparent),
    0 4px 12px rgba(15, 23, 42, 0.1);
  box-sizing: border-box;
}

html body .document-member-top-cta__fab[hidden] {
  display: none !important;
}

html body .document-member-top-cta--vip-only .document-member-top-cta__fab {
  position: relative;
  left: auto;
  top: auto;
  display: flex !important;
  width: 100%;
  height: 100%;
}

html body .document-member-top-cta.is-collapsed .document-member-top-cta__fab {
  display: flex !important;
  position: relative;
  left: auto;
  top: auto;
  width: 100%;
  height: 100%;
}

html body .document-member-top-cta.is-collapsed .document-member-top-cta__fab .document-member-top-cta__crown-svg {
  width: 15px;
  height: 15px;
}

/* 收起 / VIP 小皇冠：不要主题色外环，仅轻微阴影 */
html body .document-member-top-cta.is-collapsed .document-member-top-cta__fab,
html body .document-member-top-cta--vip-only .document-member-top-cta__fab {
  border: none;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.1);
}

html.dark body .document-member-top-cta.is-collapsed .document-member-top-cta__fab,
html body.dark .document-member-top-cta.is-collapsed .document-member-top-cta__fab,
html.dark body .document-member-top-cta--vip-only .document-member-top-cta__fab,
html body.dark .document-member-top-cta--vip-only .document-member-top-cta__fab {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

html body .document-member-top-cta.is-collapsed,
html body .document-member-top-cta--vip-only {
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html body .document-member-top-cta.is-collapsed {
  z-index: 560;
  padding: 0;
  gap: 0;
  max-width: 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  transform: none !important;
}

html body .document-member-top-cta.is-collapsed .document-member-top-cta__main,
html body .document-member-top-cta.is-collapsed .document-member-top-cta__close {
  display: none !important;
}

html body .document-member-top-cta.is-collapsed:hover {
  box-shadow: none;
  transform: translate3d(0, -2px, 0) !important;
}

html body .document-member-top-cta.is-collapsed:hover .document-member-top-cta__fab {
  box-shadow: 0 3px 12px rgba(15, 23, 42, 0.12);
}

@media (max-width: 768px) {
  html body .document-member-top-cta {
    top: max(3.35rem, calc(env(safe-area-inset-top, 0px) + 2.65rem));
    right: max(0.45rem, env(safe-area-inset-right, 0px));
    max-width: min(15.5rem, calc(100vw - 5.25rem));
    border-radius: 11px;
  }

  html body .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) {
    padding: 0.32rem 1.95rem 0.32rem 0.38rem;
  }

  html body .document-member-top-cta:not(.is-collapsed):not(.document-member-top-cta--vip-only) .document-member-top-cta__close {
    top: 0.26rem;
    right: 0.28rem;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 7px;
  }

  html body .document-member-top-cta__badge {
    width: 1.95rem;
    height: 1.95rem;
    border-radius: 9px;
  }

  html body .document-member-top-cta__crown-svg {
    width: 16px;
    height: 16px;
  }

  html body .document-member-top-cta__title {
    font-size: 0.78rem;
  }

  html body .document-member-top-cta__sub {
    font-size: 0.625rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .document-member-top-cta {
    animation: none;
  }

  html body .document-member-top-cta::before {
    animation: none;
    opacity: 0.45;
  }

  html body .document-member-top-cta__badge {
    animation: none;
  }

  html body .document-member-top-cta:hover:not(.is-flying):not(.is-collapsed):not(.document-member-top-cta--vip-only) {
    transform: translate3d(0, -2px, 0);
  }
}
