/* 页头已登录用户标识（与运营后台一致：头像 + 账号 + 下拉） */
.header .ub-user {
  position: relative;
  display: none;
  align-items: center;
  flex: 0 0 auto;
}
.header.ub-has-user .ub-user {
  display: flex;
}
.header.ub-has-user .ub-login,
.header.ub-has-user .ub-register,
.header.ub-has-user .login-btn,
.header.ub-has-user .user-btn {
  display: none !important;
}
.header .ub-user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 3px 10px 3px 3px;
  border: 1px solid #e4e9f2;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: #1b2c50;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.header .ub-user-trigger:hover {
  border-color: #c9d6f5;
  box-shadow: 0 2px 10px rgba(45, 90, 255, 0.1);
}
.header .ub-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2d5aff;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.header .ub-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.header .ub-user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: #1f2937;
  line-height: 20px;
}
.header .ub-user-caret {
  color: #8a94a6;
  flex: 0 0 auto;
  transition: transform 0.2s ease;
}
.header .ub-user.is-open .ub-user-caret {
  transform: rotate(180deg);
}
.header .ub-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 172px;
  padding: 6px;
  background: #fff;
  border: 1px solid #e8ecf4;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(27, 44, 80, 0.12);
  z-index: 1200;
}
.header .ub-user-menu[hidden] {
  display: none;
}
.header .ub-user-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  background: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 14px;
  color: #1b2c50;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.header .ub-user-item:hover {
  background: #f5f8ff;
  color: #2d5aff;
}
@media (max-width: 1023px) {
  .header .ub-user-name {
    max-width: 104px;
    font-size: 13px;
  }
  .header .ub-user-trigger {
    height: 30px;
    gap: 6px;
    padding: 3px 8px 3px 3px;
  }
  .header .ub-user-avatar {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  .header .ub-user-menu {
    min-width: 156px;
  }
}
/* 用户头像权益外环 + 账号胶囊（unb18）：环图覆盖头像上层；胶囊按套餐取图标主色的浅底 */
.header .ub-avatar-ring {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
}
.header .ub-avatar-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  /* 环图整体覆盖在头像之上：内沿压住头像边缘，徽章/皇冠不被头像遮挡 */
  z-index: 2;
  background-image: var(--ub-ring, url('https://browser-cdn.unb.ink/images/avatar-ring/free-unb1.webp'));
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  pointer-events: none;
}
.header .ub-avatar-ring[data-plan='base'] { --ub-ring: url('https://browser-cdn.unb.ink/images/avatar-ring/base-unb1.webp'); }
.header .ub-avatar-ring[data-plan='pro'] { --ub-ring: url('https://browser-cdn.unb.ink/images/avatar-ring/pro-unb1.webp'); }
.header .ub-avatar-ring[data-plan='team'] { --ub-ring: url('https://browser-cdn.unb.ink/images/avatar-ring/team-unb1.webp'); }
.header .ub-avatar-ring .ub-user-avatar {
  /* 内孔直径 / 环图宽 = 320 / 543；压在环图下层，边缘由环内沿覆盖 */
  position: relative;
  z-index: 1;
  width: 58.93%;
  height: 58.93%;
  font-size: 11px;
}

/* 胶囊底色：取各档环图标的主色与白色混合，默认就有淡底色，悬停加深一档 */
.header .ub-user {
  --ub-chip-bg: #e4ecf7;
  --ub-chip-bg-hover: #dae5f4;
}
.header .ub-user[data-plan='base'] {
  --ub-chip-bg: #d6e6f9;
  --ub-chip-bg-hover: #c7dcf7;
}
.header .ub-user[data-plan='pro'] {
  --ub-chip-bg: #ddd9f4;
  --ub-chip-bg-hover: #d0cbf0;
}
.header .ub-user[data-plan='team'] {
  --ub-chip-bg: #f8ecdb;
  --ub-chip-bg-hover: #f6e5ce;
}
.header .ub-user-trigger {
  height: 44px;
  padding: 0 12px 0 0;
  gap: 8px;
  border: 0;
  background: var(--ub-chip-bg);
  box-shadow: none;
  transition: background-color 0.18s ease;
}
.header .ub-user-trigger:hover,
.header .ub-user.is-open .ub-user-trigger {
  border: 0;
  background: var(--ub-chip-bg-hover);
  box-shadow: none;
}
.header .ub-user-trigger:focus-visible {
  outline: 2px solid rgba(45, 90, 255, 0.45);
  outline-offset: 2px;
}
@media (max-width: 1023px) {
  .header .ub-avatar-ring {
    width: 38px;
    height: 38px;
  }
  .header .ub-avatar-ring .ub-user-avatar {
    font-size: 10px;
  }
  .header .ub-user-trigger {
    height: 38px;
    padding: 0 10px 0 0;
    gap: 6px;
  }
}
/* 手机端：胶囊只保留头像环与箭头，避免账号名把页头挤出屏幕 */
@media (max-width: 767px) {
  .header .ub-user-name {
    display: none;
  }
  .header .ub-user-trigger {
    padding: 0 4px 0 0;
  }
}
