:root {
  --fg-green: #2E6B4E;
  --fg-green-light: #A8D5B5;
  --fg-bg: rgba(255,255,255,.72);
  --fg-border: rgba(255,255,255,.45);
  --fg-shadow: 0 8px 28px rgba(0,0,0,.16);
}

#fg-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--fg-green);
  cursor: pointer;
  z-index: 999999;
  transition: transform .25s ease, filter .25s ease;
  padding: 0;
  overflow: hidden;
}

#fg-fab:hover {
  transform: translateY(-4px);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.2));
}

#fg-fab.active {
  transform: rotate(45deg);
}

#fg-fab:active {
  transform: scale(.93);
}

#fg-fab svg,
.fg-fab-icon {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.fg-fab-icon {
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

#fg-menu {
  position: fixed;
  right: 20px;
  bottom: 88px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  z-index: 999998;
  pointer-events: none;
}

.fg-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--fg-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--fg-border);
  box-shadow: var(--fg-shadow);
  color: #1f2937;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  min-width: 140px;
  justify-content: flex-start;
  opacity: 0;
  transform: translateY(10px) scale(.95);
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}

.fg-item svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

#fg-menu.open {
  pointer-events: auto;
}

#fg-menu.open .fg-item {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#fg-menu.open .fg-item:nth-child(1) { transition-delay: 0ms; }
#fg-menu.open .fg-item:nth-child(2) { transition-delay: 40ms; }
#fg-menu.open .fg-item:nth-child(3) { transition-delay: 80ms; }
#fg-menu.open .fg-item:nth-child(4) { transition-delay: 120ms; }
#fg-menu.open .fg-item:nth-child(5) { transition-delay: 160ms; }
#fg-menu.open .fg-item:nth-child(6) { transition-delay: 200ms; }

.fg-item:hover {
  transform: translateX(-4px);
  background: rgba(255,255,255,.9);
}

.fg-item.active {
  background: rgba(46,107,78,.12);
  color: var(--fg-green);
  border-color: rgba(46,107,78,.25);
}

/* 回顶部按钮默认隐藏 */
.fg-item[href="#top"] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(.95);
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}

/* 回顶部按钮显示状态 */
.fg-item[href="#top"].visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* 菜单打开时强制显示回顶部 */
#fg-menu.open .fg-item[href="#top"] {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* FAB 滚动阴影 */
#fg-fab.scrolled {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.25));
}

#fg-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 999997;
  display: none;
}

#fg-backdrop.show {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg-bg: rgba(35,40,36,.78);
    --fg-border: rgba(255,255,255,.08);
    --fg-shadow: 0 8px 30px rgba(0,0,0,.45);
  }

  #fg-fab {
    color: var(--fg-green-light);
    background: transparent;
  }

  .fg-item {
    color: #e5e7eb;
  }

  .fg-item.active {
    background: rgba(168,213,181,.14);
    color: var(--fg-green-light);
    border-color: rgba(168,213,181,.25);
  }
}

@media (max-width: 768px) {
  #fg-fab {
    right: 18px;
    bottom: 20px;
    width: 56px;
    height: 56px;
  }

  #fg-menu {
    right: 18px;
    bottom: 84px;
  }

  .fg-item {
    min-width: 128px;
    padding: 11px 14px;
    font-size: 13px;
  }
}
