/* =========================================================
   星环设计 - 公共样式
   包含：CSS 变量（明亮/暗色主题）、重置样式、页头、头像菜单、Toast 提示
   ========================================================= */

/* ---------- 主题变量：明亮模式（默认） ---------- */
:root {
  --bg: #f3f4f8;             /* 页面背景 */
  --bg-card: #ffffff;        /* 卡片背景 */
  --bg-input: #ffffff;       /* 输入框背景 */
  --bg-hover: #f0f1f6;       /* 悬停背景 */
  --text: #1f2430;           /* 主文字 */
  --text-1: #1f2430;         /* 主文字（历史别名，和 --text 同值） */
  --text-2: #6b7280;         /* 次要文字 */
  --text-3: #9aa3b2;         /* 第三级文字（计数、提示） */
  --border: #e3e5ec;         /* 边框 */
  --primary: #2563eb;        /* 主题色（星环蓝） */
  --primary-light: #dbeafe;  /* 主题色浅背景 */
  --primary-text: #ffffff;   /* 主题色上的文字 */
  --danger: #e5484d;         /* 危险/删除色 */
  --like-active: #e5484d;    /* 点亮点赞的颜色 */
  --shadow: 0 2px 12px rgba(30, 34, 60, 0.08);
  --shadow-lg: 0 8px 30px rgba(30, 34, 60, 0.14);
}

/* ---------- 主题变量：暗色模式 ---------- */
[data-theme="dark"] {
  --bg: #12141c;
  --bg-card: #1b1e2b;
  --bg-input: #222636;
  --bg-hover: #262b3d;
  --text: #e6e8f0;
  --text-1: #e6e8f0;
  --text-2: #9aa1b5;
  --text-3: #6f7789;
  --border: #2c3145;
  --primary: #60a5fa;
  --primary-light: #1e3a5f;
  --primary-text: #ffffff;
  --danger: #ff6369;
  --like-active: #ff6369;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* ---------- 重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.25s, color 0.25s;
  /* 全站换行兜底：用户输入的长串（长 URL、连续英文/数字）一律允许在任意位置断行，
     避免把卡片/侧栏撑宽导致横向滚动或文字压叠。需要横滚的容器（pre 等）自行覆盖。 */
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
}

/* =========================================================
   启动屏（首屏加载遮罩：logo + 进度条）
   由每页 body 最前的内联脚本插入，不等 external js 下载，
   所以能立刻盖住白屏；数据全部就绪后由 finishSplash() 撤掉。
   ========================================================= */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--bg);
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
/* 数据就绪后由 finishSplash() 加上 .is-hidden 淡出（避免"啪"一下消失） */
.app-splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.app-splash-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.app-splash-logo img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}
/* 呼吸一下，避免静止得像卡死 */
.app-splash-logo img { animation: splashPulse 1.6s ease-in-out infinite; }
@keyframes splashPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.62; transform: scale(0.94); }
}
.app-splash-bar {
  position: relative;
  width: 190px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.app-splash-bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.28s ease;
}
.app-splash-tip {
  font-size: 13px;
  color: var(--text-2);
  min-height: 18px;
}

/* 启动屏显示期间锁滚动，避免用户在遮罩下滚动露馅 */
body.splash-open { overflow: hidden; }

/* 首屏内容：就绪后整体淡入（配合 finishSplash） */
.splash-fade-in { animation: splashFadeIn 0.32s ease both; }
@keyframes splashFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* 用户系统设置里关了动效就别动 */
@media (prefers-reduced-motion: reduce) {
  .app-splash-logo img { animation: none; }
  .app-splash { transition: none; }
  .splash-fade-in { animation: none; }
}

/* =========================================================
   内容入场动效（克制细腻，由 common.js 的 runEntrance() 驱动）
   启动屏撤掉后：首屏元素依次淡入上浮（错峰 40ms）；视口外的元素
   滚到可见时再进。只动 opacity / transform，不动布局。
   .enter = 等待入场（先藏起来，交给 IntersectionObserver）
   .enter-in = 正在入场（一次性动画，both 填充）
   ========================================================= */
.enter {
  opacity: 0;
  transform: translateY(10px);
}
.enter-in {
  animation: enterUp 0.28s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes enterUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
/* 同上：用户关了动效就让元素直接显示，绝不藏内容 */
@media (prefers-reduced-motion: reduce) {
  .enter { opacity: 1; transform: none; }
  .enter-in { animation: none; }
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; color: var(--text); }
a { color: var(--primary); text-decoration: none; }

/* ---------- 正文里的网页链接（由 renderRichText 生成） ---------- */
.rich-link {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  word-break: break-all;      /* 超长链接不撑破卡片 */
  overflow-wrap: anywhere;
  transition: opacity 0.15s;
}
.rich-link:hover { text-decoration-style: solid; opacity: 0.85; }

/* ---------- @提及（由 renderRichText 生成） ---------- */
.mention-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  background: var(--primary-light);
  border-radius: 4px;
  padding: 0 3px;
  white-space: nowrap;
}
.mention-link:hover { text-decoration: underline; }

/* ---------- @提及自动补全弹层（common.js 的 attachMentionAutocomplete） ---------- */
.mention-pop {
  position: absolute;
  z-index: 70;
  max-height: 244px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
}
.mention-pop[hidden] { display: none; }
.mention-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.mention-item.active,
.mention-item:hover { background: var(--bg-hover); }
.mention-ava {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.mention-ava-txt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}
.mention-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mention-uid {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-2);
}

/* ---------- 页头 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* 毛玻璃：半透明底 + 背景模糊 —— 帖子/图片滚到页头下面时透出来是糊的，不会抢视线。
     注意别改回不透明色，否则 blur 等于白做（后面透不出东西）。 */
  background: rgba(255, 255, 255, 0.75);
  /* ① 单纯模糊：Safari（-webkit-）与不支持 SVG 滤镜的浏览器走这条 */
  -webkit-backdrop-filter: blur(14px) saturate(1.6);
  backdrop-filter: blur(14px) saturate(1.6);
  /* ② 模糊 + 玻璃折射扭曲：Chromium 支持 backdrop-filter 引用 SVG 滤镜，
     会覆盖掉上面那条；不支持的浏览器解析不了 url()，自动保留①（仍然有模糊）。
     顺序是「先扭曲后模糊」—— 扭曲要作用在清晰的背景上才看得见。
     #xhGlassWarp 定义由 common.js initGlassWarp() 注入（全站一份）。 */
  backdrop-filter: url(#xhGlassWarp) blur(10px) saturate(1.6);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
[data-theme="dark"] .site-header { background: rgba(27, 30, 43, 0.75); }

/* 老浏览器不支持 backdrop-filter：回退成不透明底，保证页头文字清晰可读 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-header { background: var(--bg-card); }
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* 页头 logo 图 */
.logo-img { width: 28px; height: 28px; }

/* logo 两行 lockup：中文名在上面，英文品牌名 Astrring 缩在下面一行（2026-10-08 加） */
.logo-txt {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
}
.logo-en {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.9px;
  color: var(--text-2);
}
/* 启动屏 logo 更大，英文名同步放大一点，别显得太小气 */
.app-splash-logo .logo-en {
  margin-top: 4px;
  font-size: 12px;
  letter-spacing: 1.8px;
}
@media (max-width: 640px) {
  .logo-en { letter-spacing: 0.6px; }
}

/* 顶部 Tab */
.tabs { display: flex; gap: 6px; flex: 1; }
.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 15px;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text); }
/* 签到等入口用 <a> 实现，去掉链接默认样式使其与按钮一致 */
a.tab-btn { text-decoration: none; cursor: pointer; }
.tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ---------- 右上角用户区域 ---------- */
.user-area { position: relative; display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--primary-light);
  cursor: pointer;
  transition: border-color 0.2s;
}
.avatar:hover { border-color: var(--primary); }

/* 没有头像图片时，用昵称首字渲染的圆形头像 */
.avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

/* 主题切换小按钮 */
.icon-btn {
  border: none;
  background: transparent;
  font-size: 20px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.2s;
}
.icon-btn:hover { background: var(--bg-hover); }

/* ---------- 页头搜索（搜索图标挨着私信图标，点开在页头下沿浮出） ---------- */
/* ---------- 页头搜索框（内联，排在右上角图标左边） ---------- */
.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 200px;
  min-width: 92px;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.2s, background 0.2s;
}
.header-search:focus-within { background: var(--bg-card); border-color: var(--primary); }
.hs-icon { color: var(--text-2); font-size: 13px; cursor: pointer; }
.hs-icon:hover { color: var(--primary); }
.hs-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.hs-input::placeholder { color: var(--text-2); }
.hs-clear {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1;
  padding: 2px;
  cursor: pointer;
}
.hs-clear:hover { color: var(--text); }
.hs-clear[hidden] { display: none; }
/* 中宽屏收紧一点，给 tab 留位置 */
@media (max-width: 1080px) {
  .header-search { flex: 0 1 150px; }
}
/* 手机（≤640px）的搜索入口要收成一个图标，规则统一写在文件末尾的「移动端适配」块里，
   这里只保留桌面与中屏的内联输入框形态 */
/* 页头图标未读红点（私信图标 / 通知铃铛共用） */
.icon-btn { position: relative; }
.icon-badge,
.bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  padding: 0 4px;
  text-align: center;
}
.icon-badge[hidden],
.bell-badge[hidden] { display: none; }

/* 头像下拉菜单 */
.avatar-menu {
  position: absolute;
  top: 52px;
  right: 0;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  /* 默认隐藏，加 .show 后弹出 */
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: all 0.18s ease;
}
.avatar-menu.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.avatar-menu .menu-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.avatar-menu .menu-header .nickname { font-weight: 600; font-size: 14px; }
.avatar-menu .menu-header .username { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.avatar-menu .menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 16px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}
.avatar-menu .menu-item:hover { background: var(--bg-hover); }
.avatar-menu .menu-item.danger { color: var(--danger); }

/* ---------- Toast 全局提示 ---------- */
#toastBox {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--text);
  color: var(--bg-card);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: #16a34a; color: #fff; } /* 成功但需要用户注意的提示（如内容被打码） */
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 返回顶部（全站，common.js 注入） ---------- */
.back-top {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: 900;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  color: var(--text-2);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.back-top:hover { color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.back-top:active { transform: scale(0.94); }
.back-top[hidden] { display: none; }

/* ---------- 搜索关键词高亮（common.js highlightInElement） ---------- */
.hl {
  background: #fde68a;
  color: #7c2d12;
  border-radius: 3px;
  padding: 0 1px;
}
[data-theme="dark"] .hl { background: rgba(250, 204, 21, 0.3); color: #fde68a; }
a .hl { color: inherit; }

/* =========================================================
   图片放大查看（全站通用灯箱，见 common.js）
   ========================================================= */
.post-images img,
.ci-images img,
.contest-img,
img.zoomable { cursor: zoom-in; }

.img-viewer {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: rgba(8, 10, 18, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.img-viewer.show { opacity: 1; pointer-events: auto; }
.img-viewer img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  background: #fff;
  animation: ivIn 0.22s ease;
}
@keyframes ivIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
/* 打开灯箱时锁住页面滚动 */
body.iv-open { overflow: hidden; }

.img-viewer .iv-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
}
.img-viewer .iv-close:hover { background: rgba(255, 255, 255, 0.3); }

.img-viewer .iv-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
.img-viewer .iv-nav:hover { background: rgba(255, 255, 255, 0.3); }
.img-viewer .iv-prev { left: 18px; }
.img-viewer .iv-next { right: 18px; }
.img-viewer .iv-nav[hidden] { display: none; }

.img-viewer .iv-counter {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.5px;
}
.img-viewer .iv-counter[hidden] { display: none; }

@media (max-width: 640px) {
  .img-viewer { padding: 14px; }
  .img-viewer .iv-nav { width: 38px; height: 38px; font-size: 15px; }
  .img-viewer .iv-prev { left: 8px; }
  .img-viewer .iv-next { right: 8px; }
  .img-viewer .iv-close { top: 12px; right: 12px; width: 36px; height: 36px; }
}

/* ---------- 蓝V认证徽章（全站通用：圆形蓝底 + 白色 V） ---------- */
.v-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #1d9bf0;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
  cursor: default;
  user-select: none;
}

/* ---------- 已封禁徽章（全站通用：红底白字药丸） ---------- */
.banned-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.6;
  color: #fff;
  background: var(--danger);
  vertical-align: middle;
  flex-shrink: 0;
  cursor: default;
  user-select: none;
}
.banned-badge i { font-size: 10.5px; }

/* ---------- 成就徽章（全站通用：作者名旁的小圆章，最多亮 2 枚） ---------- */
.ach-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 9px;
  line-height: 1;
  margin-left: 4px;
  vertical-align: -2px;
  flex-shrink: 0;
  cursor: default;
  user-select: none;
}
.ach-badge.tier-gold   { background: rgba(245, 158, 11, 0.20); color: #d97706; }
.ach-badge.tier-silver { background: rgba(100, 116, 139, 0.18); color: #64748b; }
.ach-badge.tier-bronze { background: rgba(180, 120, 70, 0.18);  color: #b0693b; }
/* 保险：万一 fa-solid 与 ach-badge 混写在同一元素上（FA 的 CSS 在本文件之后加载，
   同权重会被覆盖成 inline-block 导致图标偏到左上角），用更高优先级压回来 */
i.ach-badge,
.ach-badge.fa-solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
[data-theme="dark"] .ach-badge.tier-gold   { background: rgba(245, 158, 11, 0.26); color: #fbbf24; }
[data-theme="dark"] .ach-badge.tier-silver { background: rgba(148, 163, 184, 0.22); color: #cbd5e1; }
[data-theme="dark"] .ach-badge.tier-bronze { background: rgba(200, 140, 90, 0.26);  color: #e0a878; }

/* ---------- 通用表单控件 ---------- */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: var(--primary-text);
  transition: opacity 0.2s, transform 0.1s;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn.block { width: 100%; }

/* ---------- 上传进度条 ---------- */
.upload-progress {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.upload-progress[hidden] { display: none; }
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-hover);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--primary);
  transition: width 0.2s ease;
}
.progress-text {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

/* =========================================================
   移动端适配：≤640px 手机
   ========================================================= */
@media (max-width: 640px) {
  /* --- 页头改两行：第一行 logo + 用户区，第二行 Tab 均分铺满 --- */
  .header-inner {
    position: relative; /* 手机展开的整行搜索条以它定位 */
    height: auto;
    flex-wrap: wrap;
    column-gap: 12px;
    row-gap: 0;
    padding: 10px 12px 8px;
  }
  .logo { font-size: 18px; }
  .logo-img { width: 24px; height: 24px; }
  /* 搜索入口：手机不常驻输入框，只留一个图标，和私信/铃铛/主题/头像排同一行；
     点它才展开整行搜索条（展开/收起由 common.js 的 initHeaderSearch 管） */
  .header-search {
    order: 2;
    margin-left: auto;
    flex: 0 0 36px;
    width: 36px;
    min-width: 0;
    height: 36px;
    padding: 0;
    justify-content: center;
    background: transparent;
    border-color: transparent;
  }
  .header-search .hs-input,
  .header-search .hs-clear { display: none; }
  .header-search .hs-icon { font-size: 18px; }
  .user-area { order: 3; gap: 8px; }
  .tabs {
    order: 4;
    width: 100%;
    margin-top: 8px;
    gap: 4px;
  }
  /* 展开态：一条搜索框浮在页头第一行（logo + 图标那行）上，整行可输入 */
  .header-search.expanded {
    position: absolute;
    left: 12px;
    right: 12px;
    top: 10px;
    width: auto;
    height: 36px;
    flex: 0 0 auto;
    justify-content: flex-start;
    padding: 0 12px;
    background: var(--bg-card);
    border-color: var(--primary);
    box-shadow: var(--shadow);
    z-index: 30;
  }
  .header-search.expanded .hs-input { display: block; }
  .header-search.expanded .hs-clear:not([hidden]) { display: block; }
  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 7px 4px;
    font-size: 14px;
    white-space: nowrap;
  }

  /* 输入类字号提到 16px：避免 iOS Safari 聚焦输入框时页面自动放大 */
  .input, .textarea, .select { font-size: 16px; }

  /* 内容区与卡片边距收紧 */
  .page-main { padding: 14px 12px 40px; }
  .card { padding: 14px; }

  /* 两行页头更高，Toast 下移避免被遮住 */
  #toastBox { top: 108px; }

  /* 小按钮加大触摸面积 */
  .action-btn { padding: 6px 10px; }
  .admin-del, .admin-act, .c-del { padding: 6px 10px; font-size: 13px; }
  .icon-btn { width: 40px; height: 40px; }

  /* 返回顶部：手机上往角落里收一点，别压住内容 */
  .back-top { right: 14px; bottom: 16px; width: 40px; height: 40px; }

  /* 页头：手机上只保留模糊，去掉折射扭曲（滚动时少一层滤镜，省电、保帧率） */
  .site-header { backdrop-filter: blur(14px) saturate(1.6); }

  /* 文件库上传行改纵向：输入框在上，按钮占满一行 */
  .upload-row { flex-direction: column; }
  .upload-row .btn { width: 100%; }
}

/* ---------- 小屏手机进一步收紧 ---------- */
@media (max-width: 400px) {
  .tab-btn { font-size: 13px; }
  .post-images img:only-child { max-height: 300px; }
  /* 窄屏（≤400px）放不下全部 Tab（发现页有 5 个）：允许换行，避免横向溢出裁切。
     🔴 三个坑（都是实测踩出来的）：
     ① 别给 .tab-btn 设 min-width:0 —— 会让 .tabs 的 min-content 变 0；
     ② .tabs 的 flex-basis 必须显式回到 100%（基础样式 .tabs{flex:1} 的 basis 是 0%，
        width:100% 形同虚设，之前全靠 tab-btn 不可换行撑出大 min-content 才独占一行；
        内部一允许换行 min-content 骤减，tabs 就被压到与 logo 同一行）；
     ③ flex-shrink:0 双保险，防止再被压缩。 */
  .tabs { flex: 1 1 100%; flex-wrap: wrap; row-gap: 4px; flex-shrink: 0; }
  .tab-btn { flex: 1 1 auto; }
}

/* ---------- 菜单项红点（私信未读数） ---------- */
.menu-badge {
  float: right;
  min-width: 18px;
  text-align: center;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 8px;
}

/* ---------- Font Awesome 图标微调 ---------- */
.icon-btn i { font-size: 16px; }
.menu-item i { width: 16px; text-align: center; margin-right: 2px; }
.tab-btn i { margin-right: 2px; }
.cat-filter i, .cat-chip i { margin-right: 2px; }
.btn i { margin-right: 2px; }
.post-tools i, .pick-file-btn i { margin-right: 0; }

/* ---------- 全站页脚（common.js 动态注入） ---------- */
.site-footer {
  margin-top: 56px;
  padding: 20px 16px 30px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}
.site-footer .footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}
.site-footer .footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text);
}
.site-footer .footer-logo { width: 16px; height: 16px; vertical-align: middle; }
.site-footer .footer-sep { opacity: 0.55; margin: 0 6px; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--primary); }
[data-theme="dark"] .site-footer { border-top-color: var(--border); }

/* 页脚友情链接行 */
.site-footer .footer-friends {
  margin-bottom: 10px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
}
.site-footer .footer-friends-label { color: var(--text-2); opacity: 0.85; }
.site-footer .footer-friends a { color: var(--text-2); text-decoration: none; }
.site-footer .footer-friends a:hover { color: var(--primary); text-decoration: underline; }

/* ---------- 赞助支持（页脚入口 + 弹窗，common.js 注入） ---------- */
.site-footer .footer-sponsor { display: inline-flex; align-items: center; gap: 4px; }
.site-footer .footer-sponsor i { font-size: 11px; color: var(--primary); }
.site-footer .footer-sponsor:hover { color: var(--primary); }

.sponsor-mask {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 18, 26, 0.45);
}
/* 🔴 必须显式写：.sponsor-mask 的 display:flex 会盖掉 hidden 的默认 display:none */
.sponsor-mask[hidden] { display: none; }
.sponsor-box {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px 22px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 18, 26, 0.22);
  text-align: left;
}
.sponsor-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
}
.sponsor-close:hover { background: var(--bg-hover); color: var(--text); }
.sponsor-title { margin: 0 0 8px; font-size: 17px; font-weight: 700; color: var(--text); }
.sponsor-desc { margin: 0 0 14px; font-size: 13px; line-height: 1.85; color: var(--text-2); }
.sponsor-qrs { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 0 0 12px; }
.sponsor-qrs[hidden] { display: none; }
.sponsor-qr { width: 148px; margin: 0; text-align: center; }
.sponsor-qr[hidden] { display: none; }
.sponsor-qr img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.sponsor-qr figcaption { margin-top: 6px; font-size: 12px; color: var(--text-2); }
.sponsor-note { margin: 0 0 6px; font-size: 12px; line-height: 1.7; color: var(--text-3); }
.sponsor-contact { margin: 0; font-size: 12.5px; color: var(--text-2); }
.sponsor-contact a { color: var(--primary); text-decoration: none; }
.sponsor-contact a:hover { text-decoration: underline; }
@media (max-width: 400px) {
  .sponsor-box { padding: 18px 16px 16px; }
  .sponsor-qr { width: 124px; }
}

/* 友链管理列表（站长后台） */
.fl-list { margin-top: 14px; }
.fl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
}
.fl-item > a { color: var(--primary); text-decoration: none; font-weight: 600; flex-shrink: 0; }
.fl-item .fl-url { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.fl-item .fl-del { margin-left: auto; border: none; background: none; color: var(--danger); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.fl-item .fl-del:hover { background: var(--bg-hover); }
.fl-empty { color: var(--text-2); font-size: 13px; }

/* ---------- PWA 底部导航（只在「添加到主屏幕」的 App 窗口 + 窄屏显示） ---------- */
#appTabBar { display: none; }
@media ((display-mode: standalone) or (display-mode: fullscreen)) and (max-width: 860px) {
  #appTabBar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 900;
    height: 56px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  body:has(#appTabBar) { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0)); }
}
#appTabBar .app-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 11px;
  -webkit-tap-highlight-color: transparent;
}
#appTabBar .app-tab i { font-size: 19px; line-height: 1; }
#appTabBar .app-tab.active { color: var(--primary); }
#appTabBar .tab-publish i {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: var(--primary-text);
  border-radius: 12px;
  margin-top: -12px;
  box-shadow: var(--shadow);
}
#appTabBar .app-tab:active { opacity: 0.7; }

/* =========================================================
   话题标签（#tag）—— 卡片/详情页可点标签、发布页标签输入、筛选条
   全站共用，所以放 common.css（forum.css 不是每个页面都引）
   ========================================================= */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-row:empty { display: none; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-2);
  font-size: 12px;
  line-height: 18px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
a.tag-chip:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.tag-chip i { font-size: 10px; opacity: 0.75; }

/* 卡片上的标签：与正文/图片拉开一点距离 */
.post-tags { margin-top: 8px; }
.draft-tags { margin-top: 8px; }
/* 详情页标签稍大一点 */
.detail-tags { margin-top: 12px; }
.detail-tags .tag-chip { font-size: 13px; padding: 3px 11px; line-height: 20px; }

/* ---------- 发布页：标签输入（chip 编辑框） ---------- */
.tag-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-input);
  cursor: text;
}
.tag-edit:focus-within { border-color: var(--primary); }
.tag-edit .tag-chip { padding-right: 4px; background: var(--primary-light); border-color: transparent; color: var(--primary); }
.tag-edit .tag-x {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  opacity: 0.65;
}
.tag-edit .tag-x:hover { opacity: 1; }
.tag-edit input {
  flex: 1;
  min-width: 110px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  padding: 3px 0;
}
.tag-edit input::placeholder { color: var(--text-2); }

/* ---------- 首页：当前标签筛选条 ---------- */
.tag-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-card);
}
.tag-filter-bar .tf-label { font-size: 13px; color: var(--text-2); }
.tag-filter-bar .tf-clear {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
}
.tag-filter-bar .tf-clear:hover { background: var(--bg-hover); color: var(--danger); }

/* ---------- 右栏「热门标签」卡 ---------- */
.tag-card { padding: 14px 14px 12px; }
.tag-card .tag-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.tag-card .tag-card-head i { color: var(--primary); }
.tag-card .a-empty { font-size: 13px; color: var(--text-2); }
/* 标签云里的帖子数 */
.tag-card .tag-chip .tag-num { font-weight: 600; font-size: 11px; opacity: 0.6; margin-left: 1px; }
