/* 环境动画背景：漂浮的社区界面骨架，参考桌面端登录页；仅改 transform / opacity */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  overflow: hidden;
  pointer-events: none;
}

.ambient::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: var(--amb-glow, none);
  animation: amb-glow 28s ease-in-out infinite alternate;
}

.amb {
  position: absolute;
  padding: 16px;
  border: 1px solid var(--amb-line);
  border-radius: 18px;
  background: var(--amb-bg);
  box-shadow: var(--amb-shadow, none);
  animation: amb-float var(--float-dur, 9s) ease-in-out var(--float-delay, 0s) infinite alternate;
  will-change: transform;
}

.amb i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--amb-skel);
}

.amb i + i {
  margin-top: 8px;
}

.amb .w70 { width: 70%; }
.amb .w60 { width: 60%; }
.amb .w40 { width: 40%; }

.amb-avatar,
.amb-stack span {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.a-violet { background: #8b5cf6; }
.a-blue { background: #6e84f7; }
.a-green { background: #10b981; }
.a-pink { background: #fb6f84; }
.a-gold { background: #f5b301; }

.amb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.amb-head > span:last-child {
  flex: 1;
}

.amb-head i {
  background: var(--amb-skel-strong);
}

.amb-head i + i {
  margin-top: 6px;
  height: 5px;
}

/* 帖子卡 */
.amb-post {
  top: 13%;
  left: 3%;
  width: 250px;
  --float-dur: 11s;
}

.amb-tags {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.amb-tags b {
  width: 52px;
  height: 18px;
  border: 1px solid color-mix(in srgb, #6e84f7 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, #6e84f7 22%, transparent);
}

.amb-tags b + b {
  border-color: color-mix(in srgb, #8b5cf6 45%, transparent);
  background: color-mix(in srgb, #8b5cf6 22%, transparent);
}

.amb-reacts {
  display: flex;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--amb-line);
}

.amb-reacts span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.amb-reacts span::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--react, #fb6f84);
}

.amb-reacts span::after {
  content: "";
  width: 18px;
  height: 4px;
  border-radius: 999px;
  background: var(--amb-skel);
}

.amb-reacts span:nth-child(2) { --react: #6e84f7; }
.amb-reacts span:nth-child(3) { --react: #10b981; }

/* 便签卡 */
.amb-note {
  bottom: 9%;
  left: 2%;
  width: 200px;
  --float-dur: 13s;
  --float-delay: -4s;
}

.amb-note .amb-bar {
  width: 30%;
  height: 5px;
  margin-top: 14px;
  background: color-mix(in srgb, #f5b301 70%, transparent);
}

/* 聊天：三条消息依次出现，最后一条为“正在输入” */
.amb-chat {
  top: 24%;
  right: 3%;
  width: 230px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  --float-dur: 10s;
  --float-delay: -2s;
}

.amb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: amb-msg 9s ease-out infinite both;
}

.amb-msg + .amb-msg {
  margin-top: 12px;
}

.amb-msg:nth-child(2) { animation-delay: 1.2s; }
.amb-msg:nth-child(3) { animation-delay: 2.4s; }

.amb-msg.is-me {
  justify-content: flex-end;
}

.amb-bubble {
  width: 140px;
  padding: 10px 12px;
  border: 1px solid var(--amb-line);
  border-radius: 14px 14px 14px 4px;
  background: var(--amb-bg);
}

.amb-bubble i {
  height: 6px;
}

.amb-bubble i + i {
  margin-top: 6px;
}

.is-me .amb-bubble {
  width: 160px;
  border-color: transparent;
  border-radius: 14px 14px 4px 14px;
  background: linear-gradient(135deg, #5566ee, #4453d6);
}

.is-me .amb-bubble i {
  background: rgba(255, 255, 255, .55);
}

.amb-bubble.is-typing {
  display: flex;
  gap: 5px;
  width: auto;
}

.amb-bubble.is-typing b {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amb-skel-strong);
  animation: amb-typing 1.2s ease-in-out infinite;
}

.amb-bubble.is-typing b:nth-child(2) { animation-delay: .15s; }
.amb-bubble.is-typing b:nth-child(3) { animation-delay: .3s; }

/* 在线头像组 */
.amb-online {
  right: 6%;
  bottom: 14%;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  text-align: center;
  --float-dur: 12s;
  --float-delay: -6s;
}

.amb-stack {
  display: flex;
}

.amb-stack span {
  width: 34px;
  height: 34px;
  border: 2px solid var(--amb-ring);
}

.amb-stack span + span {
  margin-left: -9px;
}

.amb-stack .more {
  color: var(--amb-more-ink);
  background: var(--amb-more-bg);
  font-size: 10px;
}

.amb-online p {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 0;
  color: var(--amb-text);
  font-size: 11px;
  font-weight: 700;
}

.amb-online p::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: live-pulse 2.4s ease-in-out infinite;
  --live: #10b981;
}

@keyframes amb-float {
  to { transform: translate3d(0, -16px, 0); }
}

@keyframes amb-glow {
  to { transform: translate3d(4%, -3%, 0) rotate(4deg); }
}

@keyframes amb-msg {
  0% { opacity: 0; transform: translateY(10px); }
  8%, 82% { opacity: 1; transform: none; }
  92%, 100% { opacity: 0; transform: none; }
}

@keyframes amb-typing {
  0%, 60%, 100% { opacity: .35; transform: none; }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* 手机端：背景卡片缩小、淡化并贴边，不与入口内容抢注意力 */
@media (max-width: 560px) {
  .ambient {
    opacity: .55;
  }

  .amb {
    scale: .78;
  }

  .amb-post {
    top: 7%;
    left: -56px;
  }

  .amb-chat {
    top: 40%;
    right: -48px;
  }

  .amb-note {
    bottom: 5%;
    left: -44px;
  }

  .amb-online {
    right: 2%;
    bottom: 24%;
  }
}

