:root {
  --bg: #fcfcfc;
  --surface: #ffffff;
  --surface-hover: #f8f9fa;
  --card-bg: #f7f8fa;
  --bg-secondary: #ecedf1;
  --primary: #07c160;
  --primary-light: #e6f7ed;
  --link: #295c9d;
  --link-light: #175bb1;
  --link-soft: #4966b9;
  --link-desc: #7d97e1;
  --text: #333;
  --text-secondary: #999;
  --text-muted: #bbb;
  --border: #eee;
  --shadow: 0 0 5px rgba(60, 60, 60, 0.22);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --header-height: 64px;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select {
  font-family: inherit;
}

img {
  max-width: 100%;
  vertical-align: middle;
}

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

a:hover {
  text-decoration: underline;
}

/* ===================== 应用骨架 ===================== */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 50;
  gap: 16px;
}

.header-left,
.header-center,
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-center {
  flex: 1;
  max-width: 420px;
}

.header-right {
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.menu-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.chat-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-name {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.chat-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding: 0 36px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--bg);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.12);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.tab-nav {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius);
}

.tab-btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ===================== 侧边栏 ===================== */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 10%;
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-title-sidebar {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-close {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.sidebar-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.section-title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.timeline-section {
  flex: 1;
}

.timeline-year {
  margin-bottom: 8px;
}

.timeline-year-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.timeline-year-btn:hover {
  background: var(--bg);
}

.timeline-year .arrow {
  transition: transform 0.2s;
  color: var(--text-secondary);
}

.timeline-year.expanded .arrow {
  transform: rotate(180deg);
}

.timeline-months {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 0 0 14px;
}

.timeline-months li {
  margin: 2px 0;
}

.timeline-month-row {
  position: relative;
}

.timeline-month-btn {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.timeline-month-btn:hover {
  background: var(--bg);
  color: var(--primary);
}

.timeline-month-btn .arrow {
  margin-left: auto;
  transition: color 0.2s;
  color: var(--text-secondary);
}

.timeline-month-btn.expanded .arrow {
  color: var(--primary);
}

.timeline-month-btn .month-count {
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  opacity: 0.7;
}

.timeline-month-btn.loaded {
  color: var(--primary);
  font-weight: 500;
}

.timeline-month-btn.loaded .month-count::before {
  content: "✓ ";
  color: var(--primary);
}

.timeline-month-btn.loading {
  opacity: 0.6;
  pointer-events: none;
}

.timeline-month-btn.loading::after {
  content: " 加载中…";
  font-size: 11px;
  color: var(--text-secondary);
}

/* 当前滚动可见月份的高亮样式 */
.timeline-month-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

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

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}

/* ===================== 主内容区 ===================== */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* 全局加载遮罩：所有 loading 场景统一展示，悬浮在整个页面上方 */
.global-loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  z-index: 9999;
}

.global-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 36px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.global-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.global-loading-text {
  font-size: 14px;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ===================== 朋友圈动态列表 ===================== */

.post-list {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
}

.feed-list {
  background: var(--surface);
  max-width: 800px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}

.share-list {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===================== 单条朋友圈动态（卡片） ===================== */

.post-item {
  display: flex;
  align-items: flex-start;
  gap: 2%;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.25s ease;
}

.post-item.highlight {
  animation: pulse 1.2s ease;
}

/* 链接 tab 的卡片模式 */
.post-item.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-bottom: none;
}

.post-avatar {
  width: 10%;
  min-width: 40px;
  max-width: 56px;
  aspect-ratio: 1;
  border-radius: 10%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg);
}

.post-body {
  flex: 1;
  min-width: 0;
}

/* 用户名 */
.post-user {
  color: var(--link);
  font-weight: 500;
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* 正文 */
.post-content {
  font-size: 1rem;
  margin-bottom: 1rem;
  word-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* 正文中的内联表情图片（[微笑] 等标签转换而来） */
.post-content .text-emoji {
  width: 1.2em;
  height: 1.2em;
  margin: 0 1px;
  vertical-align: middle;
  display: inline-block;
}

/* ===================== 媒体网格（图片/实况/视频） ===================== */

.post-pic-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.post-pic-grid-1 {
  grid-template-columns: repeat(1, 1fr);
}

.post-pic-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.post-pic-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.post-pic-item {
  position: relative;
  align-items: center;
  aspect-ratio: 1;
  background-color: #f5f5f5;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  overflow: hidden;
  max-height: 600px;
  cursor: pointer;
}

/* 1 张和 2 张图片不强制正方形比例（与参考一致） */
.post-pic-grid-1 .post-pic-item,
.post-pic-grid-2 .post-pic-item {
  aspect-ratio: 0;
}

.post-pic-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.2s ease;
  display: block;
}

.post-pic-item img:hover {
  cursor: pointer;
  transform: scale(1.02);
}

/* 实况照片角标（点击播放 mp4） */
.post-livephoto-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(60, 60, 60, 0.5);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  z-index: 2;
}

/* 视频播放按钮 */
.post-play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  pointer-events: none;
}

/* ===================== 视频号 / 链接分享卡片 ===================== */

.sns-card-finders {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sns-finder-card {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  background: #f7f7f7;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.sns-finder-card:hover {
  text-decoration: none;
  background: #f0f0f0;
}

.finder-cover {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
}

.finder-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.finder-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  background: #eaeaea;
}

.finder-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2px 0;
}

.finder-desc {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.finder-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-light);
}

.finder-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-light);
}

.finder-nickname {
  color: var(--text-light);
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-url {
  color: var(--link-soft);
  text-decoration: none;
}

.link-url:hover {
  text-decoration: underline;
}

.link-title {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.link-desc-text {
  font-size: 0.78rem;
  color: var(--text-light);
  line-height: 1.3;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* ===================== 位置 / 时间 / 互动信息 ===================== */

.post-location {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--link-light);
}

.post-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  line-height: 19px;
  margin: 12px 0;
  font-size: 0.8rem;
}

.post-time {
  color: var(--text-muted);
}

/* ===================== 点赞 ===================== */

.post-likes {
  background: #fdfdfd;
  line-height: 1.5;
  margin: 5px 0;
  padding: 5px 8px;
  color: var(--link-light);
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.post-like-icon {
  color: var(--link-light);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding-top: 2px;
}

.post-like-names {
  flex: 1;
  word-break: break-all;
}

/* ===================== 评论 ===================== */

.post-comments {
  background: #fdfdfd;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  word-break: break-all;
  line-height: 1.5;
  margin: 5px 0;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.post-comment {
  padding: 2px 0;
}

.post-comment-author {
  color: var(--link-light);
  font-weight: 600;
}

.post-comment-ref {
  color: var(--text-muted);
  margin: 0 4px;
}

.post-comment-content {
  color: var(--text);
}

.post-comment-content .text-emoji {
  width: 1rem;
  height: 1rem;
  margin: 0 1px;
  vertical-align: middle;
  display: inline-block;
}

/* ===================== 媒体网格（图片/视频 tab） ===================== */

.media-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.media-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  /* 性能优化：跳过屏幕外卡片的渲染（layout/paint） */
  content-visibility: auto;
  contain-intrinsic-size: 200px 220px;
}

.media-card:hover {
  box-shadow: var(--shadow-lg);
}

.media-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg);
  overflow: hidden;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 懒加载占位骨架屏：未加载 src 时显示 shimmer 动画 */
.lazy-img:not([src]),
.lazy-video:not([src]) {
  background: linear-gradient(110deg, #ececec 8%, #f5f5f5 18%, #ececec 33%);
  background-size: 200% 100%;
  animation: shimmer 1.5s linear infinite;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

.media-livephoto-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  background: rgba(60, 60, 60, 0.5);
  color: #fff;
  font-size: 11px;
}

.media-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.media-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

/* ===================== 灯箱 ===================== */

.lightbox,
.video-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.95);
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.lightbox-img {
  max-width: 92vw;
  max-height: 100vh;
  object-fit: contain;
  width: 90%;
}

.lightbox-close,
.video-close {
  position: absolute;
  top: 2rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  transition: background 0.2s;
}

.lightbox-close:hover,
.video-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  justify-content: center;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }

.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 12px;
}

.video-player {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius-sm);
}

/* ===================== 动画 ===================== */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(7, 193, 96, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(7, 193, 96, 0); }
  100% { box-shadow: 0 0 0 0 rgba(7, 193, 96, 0); }
}

/* ===================== 响应式 ===================== */

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .app-header {
    padding: 0 12px;
    gap: 10px;
  }

  .menu-toggle {
    display: flex;
  }

  .header-center {
    display: none;
  }

  .header-right {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-btn {
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

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

  .chat-meta {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: 80%;
    max-width: 300px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 60;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-backdrop {
    display: block;
  }

  .post-list {
    padding: 12px;
  }

  .post-avatar {
    width: 15%;
    min-width: 36px;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }

  .media-meta {
    padding: 8px;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .lightbox-nav {
    display: none;
  }
}

@media (max-width: 400px) {
  .post-avatar {
    width: 15%;
    margin-right: 3%;
  }

  .post-pic-grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .header-center {
    max-width: 300px;
  }
}
/*隐藏整个tab按钮栏（动态/视频/图片/链接全部消失）*/
.tab-nav {
    display: none !important;
}
/*隐藏顶部旧的残缺搜索框*/
.header-center .search-box {
    display:none !important;
}


/*彻底隐藏左上角菜单按钮，侧边栏完全无法打开*/
.menu-toggle {
    display: none !important;
}
/*隐藏tab标签栏*/
.tab-nav {
    display: none !important;
}
/*隐藏原生顶部搜索*/
.header-center .search-box {
    display:none !important;
}
/*隐藏时间线模块（备用，就算代码残留也看不见）*/
.timeline-section {
    display: none !important;
}
