/* ==========================================================================
   朋友圈 · 视觉还原
   目标：与微信朋友圈移动端保持一致的比例、间距、层级与颜色
   ========================================================================== */

:root {
  --app-w: 640px;
  --bg: #ffffff;
  --bg-page: #ededed;
  --text: #191919;
  --text-2: #7f7f7f;
  --text-3: #b2b2b2;
  --link: #576b95;
  --line: #e6e6e6;
  --drawer: #f7f7f7;
  --nav-solid: rgba(237, 237, 237, 0.94);
  --nav-icon: #ffffff;
  --avatar-bg: #e2e2e2;
  --skeleton: #f0f0f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #191919;
  --bg-page: #000000;
  --text: #d5d5d5;
  --text-2: #888888;
  --text-3: #6a6a6a;
  --link: #7d90a9;
  --line: #2a2a2a;
  --drawer: #252525;
  --nav-solid: rgba(25, 25, 25, 0.94);
  --nav-icon: #ededed;
  --avatar-bg: #2c2c2c;
  --skeleton: #242424;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--bg-page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-page);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a {
  color: var(--link);
  text-decoration: none;
}

/* ------------------------------------------------------------------ 外壳 */

.app {
  position: relative;
  width: 100%;
  max-width: var(--app-w);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 520px) {
  .app {
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.08);
  }
}

/* iOS 26+ 独立窗口（添加到主屏幕）下，系统会在顶/底边缘自动绘制 Liquid Glass
   毛玻璃带。WebKit 的规则：只要顶缘检测到一个覆盖边缘的纯色 fixed 元素，就不再
   绘制。这两个空 div 只在 PWA 环境显示，浏览器里 display:none 完全无感 */
.edge-fix {
  display: none;
}

@media (display-mode: standalone) {
  .edge-fix {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    background: var(--bg-page);
  }

  .edge-fix-top {
    top: 0;
    height: calc(env(safe-area-inset-top, 0px) + 1px);
    z-index: 31; /* 盖过导航(30)，低于查看器(100) */
  }

  .edge-fix-bottom {
    bottom: 0;
    height: calc(env(safe-area-inset-bottom, 0px) + 1px);
    z-index: 31;
  }
}

/* ------------------------------------------------------------------ 导航 */
.nav {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-w);
  z-index: 30;
  color: var(--nav-icon);
  padding-top: env(safe-area-inset-top, 0px);
  transition: background-color 0.18s ease, color 0.18s ease;
}

.nav-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 6px;
}

.nav-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

/* 标题可点击回顶（预留足够点击区域） */
.nav-title-link {
  display: block;
  padding: 8px 10px;
  margin: -8px -10px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.nav-title-link:active {
  opacity: 0.55;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: inherit;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.nav-btn svg {
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

.nav.is-solid .nav-btn svg {
  filter: none;
}

@media (hover: hover) {
  .nav-btn:hover {
    background: rgba(127, 127, 127, 0.16);
  }
}

.nav-btn:active {
  background: rgba(127, 127, 127, 0.22);
  transform: scale(0.93);
}

.nav.is-solid {
  background: var(--nav-solid);
  color: var(--text);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 0.5px solid var(--line);
}

.nav.is-solid .nav-title {
  text-shadow: none;
}

.nav-btn .icon-moon {
  display: none;
}

:root[data-theme="dark"] .nav-btn .icon-sun {
  display: none;
}

:root[data-theme="dark"] .nav-btn .icon-moon {
  display: block;
}

/* ------------------------------------------------------------------ 封面 */

.cover {
  position: relative;
  height: clamp(240px, 46vh, 380px);
  min-height: 232px;
  overflow: hidden;
  background: linear-gradient(160deg, #3a3a3a 0%, #1f1f1f 100%);
  touch-action: pan-y;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.cover-img.is-ready {
  opacity: 1;
}

.cover-mask {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.35) 0%,
    rgba(0, 0, 0, 0) 32%,
    rgba(0, 0, 0, 0) 62%,
    rgba(0, 0, 0, 0.4) 100%
  );
  pointer-events: none;
}

.cover-user {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.cover-name {
  color: #fff;
  font-size: 17px;
  font-weight: 500;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  padding-bottom: 6px;
}

.cover-avatar {
  width: 62px;
  height: 62px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--avatar-bg);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* 可点击的头像（进资料页） */
.is-link {
  cursor: pointer;
}

@media (max-width: 360px) {
  .cover-avatar {
    width: 54px;
    height: 54px;
  }
}

/* ------------------------------------------------------------------ 信息流 */

.feed {
  padding-top: 26px; /* 手机端：封面到第一条动态的间距再加一点 */
}

.moment {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 12px;
  padding: 0 16px 18px;
}

.moment + .moment {
  border-top: 0.5px solid var(--line);
  padding-top: 18px;
}

.moment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--avatar-bg);
}

.moment-body {
  min-width: 0;
}

.moment-name {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 500;
  color: var(--link);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* 可点区域严格收窄到昵称文字本身（进详情页），右侧大片空白不可点 */
  width: fit-content;
  max-width: 100%;
}

.moment-text {
  font-size: 16px;
  line-height: 1.47;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.moment-text a {
  color: var(--link);
  word-break: break-all;
}

.moment-text strong {
  font-weight: 600;
}

.moment-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  background: var(--drawer);
  padding: 1px 4px;
  border-radius: 3px;
}

/* 代码块：朋友圈没有代码样式，这里给一个浅底块，避免挤成一行 */
.moment-text .md-code {
  display: block;
  margin: 6px 0;
  padding: 8px 10px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* 分割线：Memos 里用 ---- / —- / *** 单独成行，渲染成一条细线 */
.moment-text .md-hr {
  height: 1px;
  margin: 12px 0;
  border: 0;
  background: var(--line);
}

.moment-text del {
  color: var(--text-2);
}

.moment-text.is-folded {
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fold-btn {
  display: block;
  margin-top: 4px;
  font-size: 16px;
  color: var(--link);
}

/* ------------------------------------------------------------------ 九宫格 */

.grid {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  width: 100%;
}

.grid[data-count="1"] {
  width: auto;
  max-width: min(66%, 208px);
}

.grid[data-count="1"] .cell {
  aspect-ratio: auto;
  width: fit-content;
  background: transparent;
}

.grid[data-count="2"],
.grid[data-count="4"] {
  width: 66.6%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid[data-count="3"],
.grid[data-count="5"],
.grid[data-count="6"],
.grid[data-count="7"],
.grid[data-count="8"],
.grid[data-count="9"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cell {
  position: relative;
  overflow: hidden;
  border-radius: 2px;
  background: var(--skeleton);
  aspect-ratio: 1 / 1;
}

.grid[data-count="1"] .cell img {
  width: auto;
  max-width: 100%;
  max-height: 240px;
  object-fit: cover;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.35s ease;
  opacity: 0;
}

.cell img.is-ready {
  opacity: 1;
}

.cell:active img {
  opacity: 0.85;
}

.cell-more::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
}

.cell-more span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  font-weight: 500;
  z-index: 1;
}

/* ------------------------------------------------------------------ 视频 / 音频 / 附件 */

.media {
  margin-top: 8px;
}

.media-video video {
  display: block;
  max-width: min(100%, 250px);
  max-height: 62vh;
  border-radius: 4px;
  background: #000;
  /* 只给看不给下：长按不出「存储/下载」菜单，也不能拖拽保存 */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.media-caption {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: min(100%, 320px);
  margin-top: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
}

.media-caption svg {
  flex: 0 0 auto;
  opacity: 0.75;
}

.media-caption-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-caption-size {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: 12px;
}

.media-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 320px);
  padding: 8px 12px 8px 8px;
  margin-top: 8px;
  background: var(--drawer);
  border-radius: 6px;
}

.audio-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audio-name {
  font-size: 13px;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-play {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--link);
  color: #fff;
  transition: transform 0.12s ease;
}

.audio-play:active {
  transform: scale(0.92);
}

.audio-play .ic-pause {
  display: none;
}

.media-audio.is-playing .audio-play .ic-play {
  display: none;
}

.media-audio.is-playing .audio-play .ic-pause {
  display: block;
}

.audio-bars {
  display: block;
  width: 100%;
  padding: 5px 0; /* 扩大点击热区，进度条可点按跳转 */
  cursor: pointer;
}

.audio-track {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.audio-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: var(--link);
}

.audio-time {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.media-file {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--drawer);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.media-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-file-size {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: 12px;
}

/* ------------------------------------------------------------------ 时间与操作 */

.meta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
  min-height: 20px;
}

.meta time {
  font-size: 13px;
  color: var(--text-3);
}

.more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 20px;
  border-radius: 4px;
  background: var(--drawer);
  color: var(--text-3);
}

.more-btn i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  font-style: normal;
}

.more-btn:active {
  background: var(--line);
}

/* ------------------------------------------------------------------ 赞/评论浮层
   微信：点「…」在按钮下方弹出深色圆角块，赞 | 评论 两个动作，右上小三角指向按钮 */

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 6;
  display: flex;
  align-items: stretch;
  background: rgba(42, 42, 42, 0.96);
  border-radius: 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  animation: popover-in 0.14s ease-out;
}

.popover[hidden] {
  display: none;
}

.popover::before {
  content: "";
  position: absolute;
  top: -5px;
  right: 11px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-top: 0;
  border-bottom-color: rgba(42, 42, 42, 0.96);
}

.pop-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 15px;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.pop-btn:first-child {
  border-radius: 5px 0 0 5px;
}

.pop-btn:last-child {
  border-radius: 0 5px 5px 0;
}

.pop-btn:active {
  background: rgba(255, 255, 255, 0.14);
}

.pop-btn svg {
  flex: 0 0 auto;
  opacity: 0.92;
}

.pop-sep {
  width: 0.5px;
  margin: 8px 0;
  background: rgba(255, 255, 255, 0.22);
}

@keyframes popover-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

:root[data-theme="dark"] .popover {
  background: rgba(62, 62, 62, 0.97);
}

:root[data-theme="dark"] .popover::before {
  border-bottom-color: rgba(62, 62, 62, 0.97);
}

/* ------------------------------------------------------------------ 赞与评论 */

.drawer {
  margin-top: 8px;
  background: var(--drawer);
  border-radius: 3px;
  overflow: hidden;
}

.drawer:empty {
  display: none;
}

.drawer-likes {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 7px 10px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--link);
}

.drawer-likes svg {
  flex: 0 0 auto;
  margin-top: 3px;
  color: var(--link);
}

.drawer-likes .names {
  overflow-wrap: anywhere;
}

/* 点赞昵称带主页链接：颜色同昵称蓝，新窗口打开 */
.drawer-likes .names a {
  color: var(--link);
  -webkit-touch-callout: none;
}

.drawer-sep {
  height: 0.5px;
  margin: 0 10px;
  background: var(--line);
}

/* 「查看全部 N 条评论 / 收起」 */
.drawer-fold-wrap {
  padding: 4px 10px 7px;
}

.drawer-fold {
  border: none;
  background: none;
  padding: 0;
  color: var(--link);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.drawer-fold:active {
  opacity: 0.55;
}

.drawer-comments {
  padding: 2px 0;
}

.comment {
  padding: 3px 10px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  /* 点评论 = 回复它（同微信），昵称/链接除外 */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.comment:active {
  background: rgba(0, 0, 0, 0.04);
}

:root[data-theme="dark"] .comment:active {
  background: rgba(255, 255, 255, 0.06);
}

.comment .who {
  color: var(--link);
  -webkit-touch-callout: none;
}

.comment a.who {
  text-decoration: none;
}

.comment .who::after {
  content: "：";
  color: var(--text);
}

/* 二级回复：「昵称 回复@某某：内容」 */
.comment.is-reply .who::after {
  content: " ";
}

.comment .reply-to {
  color: var(--text-3);
}

.comment .reply-to::after {
  content: "：";
  color: var(--text);
}

/* 二级回复缩进（层级最多 2 级） */
.comment-replies {
  margin-left: 10px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

/* 审核中：仅评论者本人本地可见，灰色 + 徽标 */
.comment.is-pending {
  cursor: default;
  color: var(--text-3);
}

.comment.is-pending .who,
.comment.is-pending .reply-to {
  color: var(--text-3);
}

.comment.is-pending .c-text a {
  color: var(--text-3);
  pointer-events: none;
}

.comment .pending-badge {
  margin-left: 6px;
  font-size: 12px;
  color: var(--text-3);
  border: 0.5px solid var(--line);
  border-radius: 3px;
  padding: 0 4px;
  white-space: nowrap;
}

/* ------------------------------------------------------------------ 内联评论输入
   微信同款：点「评论」后在动态下方就地展开（非底部弹条） */

.comment-inline {
  margin-top: 8px;
}

/* 回复条：「回复 某某 ×」，点 × 退回普通评论 */
.comment-reply-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding: 0 2px;
  font-size: 13px;
  color: var(--text-3);
}

.comment-reply-txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-reply-x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  background: var(--drawer);
  color: var(--text-3);
}

.comment-reply-x:active {
  opacity: 0.6;
}

/* 昵称行：已填过也会显示，随时可改（带小铅笔） */
.comment-nick-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--text-3);
}

.comment-nick-label {
  font-size: 13px;
  flex: 0 0 auto;
}

.comment-nick {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: var(--drawer);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.comment-nick::placeholder {
  color: var(--text-3);
}

.comment-nick-pen {
  flex: 0 0 auto;
  opacity: 0.6;
}

/* 主页链接行：与昵称行同款，选填 */
.comment-link-row {
  margin-top: -2px;
}

.comment-link {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: var(--drawer);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

.comment-link::placeholder {
  color: var(--text-3);
}

/* 大输入框（同微信评论框） */
.comment-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--drawer);
  padding: 10px 12px 8px;
}

.comment-input {
  display: block;
  width: 100%;
  min-height: 46px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px; /* ≥16px 防 iOS 聚焦自动放大 */
  line-height: 1.45;
  resize: none;
  outline: none;
}

.comment-input::placeholder {
  color: var(--text-3);
}

.comment-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.comment-emos {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-3);
}

.comment-emos button {
  display: flex;
  padding: 2px;
  border: none;
  background: none;
  color: inherit;
}

.comment-emos button:active {
  opacity: 0.6;
}

/* 表情面板：点表情图标弹出，网格排布，点选即插入 */
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: var(--shadow);
  max-height: 148px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.emoji-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.emoji-item:active {
  background: var(--drawer);
  transform: scale(0.92);
}

:root[data-theme="dark"] .emoji-panel {
  background: #2a2a2a;
  border-color: #3a3a3a;
}

:root[data-theme="dark"] .emoji-item:active {
  background: #383838;
}

.comment-send {
  height: 30px;
  padding: 0 14px;
  border: none;
  border-radius: 6px;
  background: #07c160;
  color: #ffffff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s ease;
}

/* 取消：发送旁边，收起输入框（草稿保留） */
.comment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-cancel {
  height: 30px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 14px;
}

.comment-cancel:active {
  opacity: 0.6;
}

.comment-send:disabled {
  opacity: 0.45;
}

.comment-send:not(:disabled):active {
  opacity: 0.8;
}

.comment-send:disabled {
  opacity: 0.55;
}

:root[data-theme="dark"] .comment-nick,
:root[data-theme="dark"] .comment-link,
:root[data-theme="dark"] .comment-input {
  background: #333333;
}

:root[data-theme="dark"] .comment-reply-x {
  background: #333333;
}

/* ------------------------------------------------------------------ 骨架屏 */

.skeleton {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 12px;
  padding: 0 16px 18px;
}

.skeleton + .skeleton {
  border-top: 0.5px solid var(--line);
  padding-top: 18px;
}

.sk {
  background: var(--skeleton);
  border-radius: 3px;
  animation: sk-pulse 1.4s ease-in-out infinite;
}

.sk-avatar {
  width: 40px;
  height: 40px;
  border-radius: 4px;
}

.sk-line {
  height: 12px;
  margin-bottom: 9px;
}

.sk-block {
  height: 96px;
  margin-top: 10px;
  border-radius: 2px;
}

@keyframes sk-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sk {
    animation: none;
  }
}

/* ------------------------------------------------------------------ 底部分页 */

.pager {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

.pager-btn {
  font-size: 14px;
  color: var(--link);
  background: var(--drawer);
  border-radius: 18px;
  padding: 9px 24px;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}

.pager-btn:active {
  background: var(--line);
}

.pager-btn:disabled {
  opacity: 0.5;
}

.feed-end {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}

.retry {
  font-size: 14px;
  color: var(--link);
  padding: 6px 12px;
}

/* 首屏弱网提示：骨架下方的一行说明 + 重新加载 */
.feed-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 24px 26px;
  color: var(--text-2);
  font-size: 14px;
  text-align: center;
}

.feed-note p {
  margin: 0;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--line);
  border-top-color: var(--text-3);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------------ 回到顶部 */

.top-btn {
  position: fixed;
  /* 桌面端贴在内容列右侧的留白里（按钮宽 40 + 间距 60）；手机端无留白，回到 18px */
  right: max(18px, calc(50% - var(--app-w) / 2 - 100px));
  bottom: 28px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-2);
  border: 0.5px solid var(--line);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.22s ease, transform 0.22s ease, box-shadow 0.2s ease, color 0.2s ease;
  z-index: 25;
  -webkit-appearance: none;
}

.top-btn svg {
  transition: transform 0.2s ease;
}

.top-btn:hover {
  color: var(--link);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.14);
}

.top-btn:hover svg {
  transform: translateY(-1.5px);
}

.top-btn:active {
  transform: scale(0.93);
}

@media (hover: none) {
  .top-btn:hover {
    color: var(--text-2);
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.1);
  }
  .top-btn:hover svg {
    transform: none;
  }
}

.top-btn.is-show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.top-btn.is-show:active {
  transform: scale(0.93);
}

/* ------------------------------------------------------------------ 大图查看 */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: none;
  touch-action: none;
}

.viewer.is-open {
  display: block;
  animation: viewer-fade 0.18s ease;
}

/* 收回缩略图时背景一起淡出，别出现「黑屏一闪」 */
.viewer.is-closing {
  background: transparent;
  transition: background-color 0.22s ease;
}

.viewer.is-closing .viewer-close,
.viewer.is-closing .viewer-count,
.viewer.is-closing .viewer-arrow {
  opacity: 0;
  transition: opacity 0.12s ease;
}

@keyframes viewer-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.viewer-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px 12px;
}

/* 图片与左右箭头同排：箭头永远在图片外侧，不遮挡画面 */
.viewer-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.viewer-img {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: auto;
  transform-origin: center center;
  transition: opacity 0.2s ease, transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
  -webkit-user-select: none;
}

/* 放大态：保持适配后的显示尺寸，只用 transform 放大，避免变成原始像素尺寸撑破屏幕 */
.viewer-img.is-zoom {
  cursor: grab;
}

.viewer-img.is-panning {
  transition: none;
  cursor: grabbing;
}

.viewer-close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
}

.viewer-count {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  letter-spacing: 1px;
}

.viewer-count:empty {
  display: none;
}

/* 微信 PC 版式左右切换箭头（触屏设备隐藏，走滑动手势） */
.viewer-arrow {
  flex: 0 0 auto;
  pointer-events: auto;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.1);
  opacity: 0.55;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  z-index: 2;
}

.viewer-arrow:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.18);
}

.viewer-arrow:active {
  background: rgba(255, 255, 255, 0.26);
}

/* 第一张没有上一张、最后一张没有下一张（同微信，不循环） */
.viewer-arrow.is-off,
.viewer-arrow.is-off:hover {
  opacity: 0.14;
  background: rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.viewer-arrow[hidden] {
  display: none;
}

/* 放大查看时隐藏箭头，避免挡住细节 */
.viewer.is-zoom .viewer-arrow {
  opacity: 0;
  pointer-events: none;
}

@media (hover: none) {
  .viewer-arrow {
    display: none;
  }
}

/* ------------------------------------------------------------------ Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translate(-50%, 8px);
  max-width: 76vw;
  padding: 9px 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 120;
}

.toast.is-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ 空态 */

.empty {
  padding: 80px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 15px;
}

/* ------------------------------------------------------------------ 资料页 */

.profile-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 24px 48px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 14px;
  object-fit: cover;
  background: var(--avatar-bg);
  box-shadow: var(--shadow);
}

.profile-name {
  margin: 14px 0 0;
  font-size: 20px;
  font-weight: 600;
}

.profile-bio {
  margin: 6px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 26px;
}

.profile-btn {
  display: inline-block;
  padding: 9px 22px;
  border-radius: 20px;
  background: var(--drawer);
  color: var(--link);
  font-size: 14px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.profile-btn:hover {
  background: var(--line);
}

.profile-btn.ghost {
  color: var(--text-2);
}

/* 详情页正文铺满不折叠，顶部给固定导航让位 */
.is-sub .feed {
  padding-top: 64px;
}

.is-sub .moment {
  padding-top: 0;
}

/* ------------------------------------------------------------------ 桌面 / 平板自适应
   与微信 iPad 版朋友圈一致：单列流式、比例放大、内容居中 */

@media (min-width: 768px) {
  body {
    font-size: 17px;
  }

  .app {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
  }

  .cover {
    height: clamp(320px, 52vh, 480px);
  }

  .cover-avatar {
    width: 72px;
    height: 72px;
    border-radius: 6px;
  }

  .cover-name {
    font-size: 19px;
    padding-bottom: 8px;
  }

  .cover-user {
    right: 20px;
    bottom: 18px;
  }

  .nav-inner {
    height: 48px;
  }

  /* 对标微信电脑版：内容两侧留白约 11%、封面到首条动态约 40px */
  .feed {
    padding-top: 40px;
  }

  .moment {
    grid-template-columns: 42px minmax(0, 1fr);
    column-gap: 14px;
    padding: 0 70px 24px;
  }

  .moment + .moment {
    border-top: 0;
    padding-top: 24px;
    position: relative;
  }

  /* 桌面分隔线两端内缩（同微信电脑版），手机端保持通栏 */
  .moment + .moment::before {
    content: "";
    position: absolute;
    top: 0;
    left: 70px;
    right: 70px;
    height: 0.5px;
    background: var(--line);
  }

  .skeleton {
    grid-template-columns: 42px minmax(0, 1fr);
    column-gap: 14px;
    padding: 0 70px 22px;
  }

  .moment-avatar {
    width: 42px;
    height: 42px;
    border-radius: 5px;
  }

  .moment-name {
    font-size: 15px;
  }

  .moment-text {
    font-size: 16px;
  }

  .fold-btn {
    font-size: 16px;
  }

  .grid {
    gap: 5px;
  }

  /* 对标微信电脑版：6 图总宽约面板 52%、2 图约 44%，格子明显小于手机端 */
  .grid[data-count="3"],
  .grid[data-count="5"],
  .grid[data-count="6"],
  .grid[data-count="7"],
  .grid[data-count="8"],
  .grid[data-count="9"] {
    max-width: 336px;
  }

  .grid[data-count="2"],
  .grid[data-count="4"] {
    max-width: 282px;
  }

  .media-video video {
    max-width: 320px;
  }

  .grid[data-count="1"] {
    max-width: 280px;
  }

  .grid[data-count="1"] .cell img {
    max-height: 280px;
  }

  .meta time {
    font-size: 14px;
  }

  .more-btn {
    width: 36px;
    height: 22px;
  }

  .drawer-likes,
  .comment {
    font-size: 15px;
  }

  .moment-text code {
    font-size: 15px;
  }
}
