/* ============================================================================
   y524 v2 设计系统
   分层原则：
     Tailwind  → 只负责「布局 / 间距 / 自适应」
     本文件    → 负责「设计令牌 + 组件外观 + 动效 + 明暗主题」
   之所以这样做：主题化（暗色模式）用 CSS 变量最干净，而 Tailwind 工具类是静态的。
   ========================================================================== */

/* ---------------------------------------------------------------- 令牌 */
:root {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f5f9;
  --surface-3: #e9eef5;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #8494a8;
  --border: #e3e9f2;
  --border-strong: #cfd8e3;

  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: rgba(79, 70, 229, 0.10);
  --brand-ring: rgba(79, 70, 229, 0.35);
  --violet: #7c3aed;

  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px -4px rgba(15, 23, 42, 0.10), 0 2px 6px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 40px -18px rgba(15, 23, 42, 0.28);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;

  --header-h: 64px;
  --header-h-sm: 56px;
  --tabbar-h: 56px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.28s;
}

html.dark {
  --bg: #070b16;
  --bg-elev: #0d1425;
  --surface: #0f1729;
  --surface-2: #16203a;
  --surface-3: #1e2a49;
  --text: #e8edf7;
  --text-2: #a9b8cf;
  --muted: #7e8ea8;
  --border: #1d2942;
  --border-strong: #2b3a58;

  --brand: #6366f1;
  --brand-hover: #7c7ff2;
  --brand-soft: rgba(99, 102, 241, 0.16);
  --brand-ring: rgba(99, 102, 241, 0.45);

  --accent-soft: rgba(245, 158, 11, 0.16);
  --success-soft: rgba(16, 185, 129, 0.16);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 18px -4px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 22px 50px -20px rgba(0, 0, 0, 0.75);
}

/* ---------------------------------------------------------------- 基础 */
/* 注：Tailwind 的 preflight 已在 CDN 配置里关闭（避免与组件样式互相打架），
   这里给出等价的最小基础层，保证 border-* 等工具类仍然可用。 */
*, *::before, *::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: var(--border);
}
* { -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--brand-soft); color: var(--brand); }

/* 自定义滚动条（只在中间滚动区出现） */
.scroll-area { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.scroll-area::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll-area::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--bg);
  border-radius: 999px;
}
.scroll-area::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.scroll-area::-webkit-scrollbar-track { background: transparent; }

/* 可访问性：跳过导航 */
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 999;
  background: var(--brand); color: #fff; padding: 8px 14px;
  border-radius: var(--radius-sm); transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 2px solid var(--brand-ring);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- App Shell
   header 贴顶、footer 贴底、只有 main 滚动；内容不足时中间留白。
   ---------------------------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  flex: 0 0 auto;
  position: relative;
  z-index: 60;
  transition: height var(--dur) var(--ease), background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.app-main {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  position: relative;
  scroll-behavior: smooth;
}

.notice-bar {
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--brand-soft);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.7;
}
.notice-bar .bi { margin-top: 2px; }

.app-footer {
  flex: 0 0 auto;
  position: relative;
  z-index: 50;
  /* 页脚是"底栏"而非内容的一部分，必须给独立底色 + 上边界，
     否则它会和 .app-main 的 --bg 融成一片，看不出是页脚。
     底色沿用 --bg-elev（与 header / drawer / modal 同一表面色）：
       浅色 → #ffffff（页面底色是 #f5f7fb，白底栏自然浮出来）
       深色 → #0d1425（页面底色是 #070b16，略亮一档，同样能区分） */
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  /* 向上投影，让底栏从滚动内容中"抬"起来；深色下页脚已足够暗，收敛一点 */
  box-shadow: 0 -10px 20px -18px rgba(15, 23, 42, 0.45);
}
html.dark .app-footer {
  box-shadow: 0 -10px 20px -18px rgba(0, 0, 0, 0.85);
}
/* PC：footer 右侧无需让位——FAB 已改为右侧纵向居中，永不与页脚重叠 */

/* 移动端：底部标签栏是 fixed 且 z-index(80) 高于页脚(50)，
   会把整个页脚盖住（连带备案号也看不见）。给 shell 让出等高空间，
   让页脚正常露在标签栏上方。 */
@media (max-width: 767px) {
  /* footer 移动端隐藏：app-shell 是 100dvh flex，footer 会永远吸在视口底
     （紧贴 tabbar）。备案号/版权挪进抽屉（drawer），投诉由 FAB 承接。
     注意：app-main 自身已有 padding-bottom:tabbar（625 行附近），
     这里**不再**给 app-shell 叠加同值 padding —— 之前两处叠加，
     内容底部会空出约两倍 tabbar 高度的留白。 */
  .app-footer { display: none; }
}

/* ---------------------------------------------------------------- 容器
   1536px 是 Tailwind 2xl 断点，作为内容上限，超宽屏留白而不是继续拉长。
   ---------------------------------------------------------------------- */
.shell { width: 100%; max-width: 1536px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 640px)  { .shell { padding-inline: 24px; } }
@media (min-width: 1024px) { .shell { padding-inline: 32px; } }

/* ---------------------------------------------------------------- 文字工具 */
.h1 { font-size: clamp(1.35rem, 1.1rem + 1.1vw, 2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; margin-top: 0; }
.h2 { font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem); font-weight: 700; letter-spacing: -0.01em; }
.h3 { font-size: 1rem; font-weight: 600; }
.text-2 { color: var(--text-2); }
.muted { color: var(--muted); }

/* 移动端排版整体收紧：标题字号降档（长标题少占一行）、正文字号微降 */
@media (max-width: 640px) {
  .h1 { font-size: 1.2rem; line-height: 1.3; }
  .h2 { font-size: 1.02rem; }
  .h3 { font-size: 0.95rem; }
  .article { font-size: 14.5px; line-height: 1.85; }
  .article h2 { font-size: 1.08rem; }
  .article h3 { font-size: 1rem; }
}
.tiny { font-size: 12px; }
.gradient-text {
  background: linear-gradient(120deg, var(--brand), var(--violet) 60%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-hoverable { transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.card-hoverable:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

/* 入口磁贴（首页分类） */
.tile {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand); }
.tile .tile-ico {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  font-size: 20px;
}
.tile:hover .tile-ico { background: var(--brand); color: #fff; transition: background .2s var(--ease), color .2s var(--ease); }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: transform .12s var(--ease), background .2s var(--ease),
    box-shadow .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px -8px var(--brand-ring); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-accent { background: var(--accent); color: #1f2937; box-shadow: 0 6px 18px -10px rgba(245,158,11,.8); }
.btn-accent:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- 表单 */
.input {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-lg { height: 44px; }

/* 带前置图标的输入框（全站搜索框 + 登录表单）。
   ⚠ 不要用 Tailwind 的 pl-9 / pl-11 来让位：.input 的 `padding: 0 12px` 简写与工具类同为
   单类权重（0,0,1,0），而 site.css 在 app.css 之后加载 —— 工具类会被覆盖回 12px，
   图标正好压在输入文字上（这正是"搜索图标与内容重叠"的根因）。
   这里改用站点自己的类：权重相同但顺序在后，稳定生效，也不受 Tailwind 重建影响。 */
.input-icon { padding-left: 28px; }      /* 配 left-3（12px）+ 13px 图标，留 11px 间距 */
.input-icon-lg { padding-left: 44px; }   /* 配 left-4（16px）+ 16px 图标，留 12px 间距 */

/* ---------------------------------------------------------------- 徽标 / 标签 */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 10px;
  background: var(--surface-2); color: var(--text-2);
  border-radius: var(--radius-full); font-size: 12px;
}
.chip-brand { background: var(--brand-soft); color: var(--brand); }
.chip-accent { background: var(--accent-soft); color: #b45309; }
html.dark .chip-accent { color: var(--accent); }
.chip-success { background: var(--success-soft); color: #047857; }
html.dark .chip-success { color: var(--success); }
.chip-danger { background: rgba(239,68,68,.12); color: #b91c1c; }
html.dark .chip-danger { color: #fca5a5; }

/* 可点击的标签（Tailwind 无法给自定义类加 hover:，所以在这里定义）。
   选择器刻意带 a 前缀：.chip-link 的"可点"反馈只给真正的 <a>。
   曾出现 <span class="chip-link">APNG图片</span> —— 看着能点却点不动，
   限定 a 前缀后这种误用在视觉层就不成立了（结构性防回归，比改模板更可靠）。 */
a.chip-link { transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease); }
a.chip-link:hover { background: var(--brand-soft); color: var(--brand); transform: translateY(-1px); }

/* 标签（tag）：无可跳转目标时只做展示，绝不给点击反馈。
   加 # 前缀是为了和"栏目 chip"（可点）在视觉上区分开。 */
.chip-tag::before { content: "#"; opacity: .55; margin-right: 1px; }

/* ---------------------------------------------------------------- 导航 */
.nav-link {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px;
  border-radius: var(--radius); font-size: 14px; font-weight: 500;
  color: var(--text-2);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--brand); background: var(--brand-soft); }
.nav-link.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--brand);
}

/* 带子菜单的导航项：标签负责跳转，右侧箭头负责展开（触屏也点得到） */
.nav-group {
  display: inline-flex; align-items: center; position: relative;
  border-radius: var(--radius); color: var(--text-2);
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-group:hover { background: var(--surface-2); color: var(--text); }
.nav-group.is-active { background: var(--brand-soft); color: var(--brand); }
.nav-group.is-active::after {
  content: ""; position: absolute; left: 12px; right: 26px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--brand);
}
.nav-group > a {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 2px 0 12px;
  font-size: 14px; font-weight: 500; color: inherit;
}
/* 导航菜单永不允许文字竖排换行：右侧（后台按钮/用户徽标）再宽，
   也宁可整体收紧而不是把「应用」挤成两行（登录后头部拥挤的根因之一） */
.nav-group, .nav-group > a, .nav-link, .nav-caret { white-space: nowrap; }
.nav-caret {
  width: 26px; height: 38px; display: inline-grid; place-items: center;
  color: inherit; opacity: .6; cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0;
  /* 必须重置 <button> 的 UA 默认样式：浅色下默认灰底恰好与浅 header 融合看不出来，
     深色下则变成突兀的灰色方块（配色"冲突"的根因） */
  background: transparent; border: none; padding: 0;
  transition: opacity .18s var(--ease);
}
.nav-caret:hover { opacity: 1; }
.nav-caret i { font-size: 10px; transition: transform .22s var(--ease); }
.mega-wrap.is-open .nav-group { background: var(--surface-2); color: var(--text); }
.mega-wrap.is-open .nav-caret { opacity: 1; }
.mega-wrap.is-open .nav-caret i { transform: rotate(180deg); }

.app-header {
  /* 92%（原 86%）：浅色页面下 header 与内容"中和"的主因是底色太透；
     再叠双层 bottom 阴影（贴地线 + 柔和投影）保证任何背景下都有边界 */
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), 0 4px 14px -8px rgba(15, 23, 42, 0.18);
}
html.dark .app-header {
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05), 0 6px 16px -8px rgba(0, 0, 0, 0.65);
}
.app-header.is-scrolled { box-shadow: 0 1px 0 var(--border), var(--shadow-sm); }

/* Mega Menu
   注意：外层 .mega 从 top:100% 紧贴触发器开始，用「透明 padding-top」形成桥接区，
   面板外观交给内层 .mega-inner。
   这样鼠标从导航滑到面板的整个路径都在 .mega-wrap 内部，不会触发 pointerleave ——
   早期版本在中间留了 10px 空隙，导致每次移动都 leave/enter，是「菜单提前消失」的直接诱因。 */
.mega-wrap { position: relative; }
.mega {
  /* 水平位置怎么定：早期用 left:50% + translate(-50%) 让面板以菜单项自身为中心居中，
     于是靠边的栏目会把面板顶出屏幕——实测 1440 视口下首个菜单左溢 192px、末项右溢 70px，
     用户看到的就是"下拉内容被截断"。
     现在 left 固定为 0，由 JS 把「夹进视口后的偏移量」写进 --mega-x
     （见 site.js initMega 的 place()）：面板依旧跟随对应菜单项，但永不越界。 */
  position: absolute; top: 100%; left: 0;
  /* 宽度交给内容：2 列时约 724px，比原来固定的 1100px 省掉近一半横向空间。
     这里必须用 max-content 而不是 fit-content —— 绝对定位元素的 fit-content 会把
     「包含块 = 导航项自身宽度」当作可用空间，直接塌成 min-content（面板变成一个窄条）。 */
  width: max-content;
  max-width: min(1100px, calc(100vw - 32px));
  padding-top: 10px;                 /* ← 桥接区，不要改成 margin/gap */
  transform: translate(var(--mega-x, 0px), -6px) scale(.985);
  opacity: 0; visibility: hidden; pointer-events: none;
  background: transparent; border: none; box-shadow: none;
  transition: opacity .2s var(--ease), transform .24s var(--ease), visibility .2s;
  z-index: 5;
}
.mega.is-open { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(var(--mega-x, 0px), 0) scale(1); }
.mega-inner {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  /* 矮窗口（如 1440×700）下面板自身会顶出屏幕底部，这里给内容留到 -84px 并允许滚动 */
  max-height: calc(100vh - 84px); overflow-y: auto;
}
/* 子栏目网格：列数由模板写进 --mega-cols（≤4 个子项 → 2 列），
   列宽上限 244px，viewpoint 变窄时靠 minmax 的 0 下限自动收缩。 */
.mega-grid {
  flex: 1 1 auto; min-width: 0;
  display: grid;
  gap: 2px 4px;
  grid-template-columns: repeat(var(--mega-cols, 2), minmax(0, 244px));
}

.mega-item {
  display: flex; gap: 10px; padding: 9px 10px; border-radius: var(--radius);
  transition: background .16s var(--ease), transform .16s var(--ease);
}
.mega-item:hover { background: var(--surface-2); transform: translateX(2px); }
.mega-item .mi-ico {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-size: 16px;
}

/* --------------------------------------------------- header 密度（防溢出）
   ⚠ 曾踩过的测量陷阱：别用 shell.scrollWidth 判断溢出。滚动宽度包含绝对定位的
   Mega 面板（宽 1100px 属布局盒），量出来的"1502px / 溢出 62~417px"全是面板撑的假象。
   正确量法是只看 .shell 的直接子元素（Logo / 导航 / 搜索 / 右侧按钮）的盒子。

   真实数据：header 内容约 1141px 固定，可用宽度视视口而定（视口减 shell 左右 padding），
   因此只有 1024 溢出 181px、1152 溢出 53px，**1280 及以上本来就是零溢出**
   （搜索框是唯一能收缩的元素，会被压成 125/211/256px 自适应）。

   所以这里只对真正溢出的 1024–1279 这一档做减法：去掉导航项前的小图标（省约 176px）
   + 搜索框收窄到 176px（再省 80px），合计 1141 → 约 885px，1024 也放得下。
   ≥1280 保持完整形态不变。 */
@media (min-width: 1024px) and (max-width: 1439px) {
  /* 去图标：省约 220px */
  .app-header nav[aria-label="主导航"] i { display: none; }
  /* 收紧导航项左右内边距与箭头区，再省约 80px */
  .app-header .nav-link { padding: 0 6px; }
  .app-header .nav-link.is-active::after { left: 6px; right: 6px; }
  .app-header .nav-group > a { padding: 0 2px 0 6px; }
  .app-header .nav-group.is-active::after { left: 6px; right: 20px; }
  .app-header .nav-caret { width: 20px; }
  /* 搜索框必须给一个固定宽度并禁止收缩：否则它是 flex 里唯一能压的元素，
     一挤就变成 57px 的一条，placeholder 都放不下 */
  .app-header [data-suggest] { flex-shrink: 0; width: 9.5rem; }
}
/* 1024–1151 是最窄的桌面档，上面那一套还差约 69px。这里再隐去 Logo 后面的站名
   （只留图标，省约 152px，视觉上 Logo 仍在），≥1152 自动恢复显示站名。 */
@media (min-width: 1024px) and (max-width: 1151px) {
  .app-header [data-logo-text] { display: none; }
}

/* 移动端抽屉 */
.drawer-mask {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 8, 20, 0.5); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity .24s var(--ease), visibility .24s;
}
.drawer-mask.is-open { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 91;
  width: min(86vw, 380px);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform .3s var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer.is-open { transform: translateX(0); }
.drawer-body { flex: 1; overflow-y: auto; }
.acc-panel { overflow: hidden; max-height: 0; transition: max-height .3s var(--ease); }
.acc-panel.is-open { max-height: 900px; }

/* 移动端底部标签栏 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  display: none;
}
@media (max-width: 767px) { .tabbar { display: flex; } }
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted);
}
.tabbar a.is-active { color: var(--brand); }

/* ---------------------------------------------------------------- 顶部导航进度条 */
#progress {
  position: fixed; top: 0; left: 0; z-index: 200;
  height: 2px; width: 0;
  background: linear-gradient(90deg, var(--brand), var(--violet), var(--accent));
  box-shadow: 0 0 10px var(--brand-ring);
  opacity: 0; transition: width .2s var(--ease), opacity .3s var(--ease);
}
#progress.is-on { opacity: 1; }
/* 详情页阅读进度 */
#readbar {
  position: absolute; left: 0; bottom: -1px; height: 2px; width: 0;
  background: var(--brand); border-radius: 2px; transition: width .1s linear;
}

/* ---------------------------------------------------------------- 缩略图 / 骨架 */
.thumb {
  position: relative;
  /* 4/3 替代 1/1：软件站的图多为横版（截图/banner），方框 + contain 会产生
     大量上下留白；4/3 让横图留白减少约 1/3，方 logo 则完全不受影响 */
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  isolation: isolate;
}
.thumb img {
  width: 100%; height: 100%; object-fit: contain; padding: 0;
  /* 不加内边距：4:3 缩略图满铺容器（圆角由容器裁切）；
     宽截图的 contain 留白由容器底色承担，避免"圆角内再垫一圈边"的双重边框 */
  opacity: 0; transform: scale(1.04);
  transition: opacity .45s var(--ease), transform .6s var(--ease);
}
.thumb img.is-loaded { opacity: 1; transform: scale(1); }
.thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
  pointer-events: none;
}
html.dark .thumb::after { background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.06) 50%, transparent 80%); }
.thumb.is-ready::after { display: none; }

.card-hoverable:hover .thumb img { transform: scale(1.07); }

.skeleton {
  background: var(--surface-2);
  border-radius: var(--radius);
  position: relative; overflow: hidden;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.5) 50%, transparent 80%);
  transform: translateX(-100%); animation: shimmer 1.4s infinite;
}
html.dark .skeleton::after { background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.06) 50%, transparent 80%); }

/* ---------------------------------------------------------------- 动效 */
@keyframes shimmer { 100% { transform: translateX(100%); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes popIn { from { opacity: 0; transform: scale(.94) translateY(6px); } to { opacity: 1; transform: none; } }

.fade-up { animation: fadeUp .5s var(--ease) both; }
.floaty { animation: floaty 5s ease-in-out infinite; }

/* 滚动揭示：只在 JS 就绪（html.js）后启用隐藏——
   JS 失败/被拦截时内容直接可见，绝不出现"空白占位"（移动端弱网尤其明显） */
.js .reveal { opacity: 0; transform: translateY(16px); }
.js .reveal.is-in { opacity: 1; transform: none; transition: opacity .55s var(--ease), transform .55s var(--ease); }

/* 弹层 */
dialog.modal {
  border: none; padding: 0; max-width: min(92vw, 480px); width: 100%;
  background: var(--bg-elev); color: var(--text);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(4, 8, 20, 0.5); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: popIn .26s var(--ease); }
/* 退出过渡：与 popIn 对称，消除"关闭卡顿"感（is-closing 由 JS 在 close() 前加上，
   此刻 dialog 仍 open、仍在 top layer，动画能正常播放） */
dialog.modal.is-closing { animation: popOut .16s var(--ease) forwards; }
dialog.modal.is-closing::backdrop { animation: backdropOut .16s ease forwards; }
@keyframes popOut { to { opacity: 0; transform: scale(.96) translateY(6px); } }
@keyframes backdropOut { to { opacity: 0; } }
dialog.modal.is-wide { max-width: min(94vw, 720px); }

.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* toast */
#toast-wrap { position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
/* popover 模式的 UA 默认样式覆盖：白底/边框/居中 margin/inset 全部去掉，
   只保留我们自己的 fixed 定位——wrap 仅作 top-layer 载体，视觉全靠内部 .toast */
#toast-wrap:popover-open {
  margin: 0; border: none; padding: 0; background: none;
  width: auto; height: auto; max-width: none; max-height: none;
  overflow: visible; color: initial;
  /* inset 需要显式重写：UA 的 inset:0 要清掉，但 top/left 必须保留定位值 */
  left: 50%; top: 76px; right: auto; bottom: auto;
}
.toast {
  pointer-events: auto;
  padding: 10px 16px; border-radius: var(--radius);
  background: var(--bg-elev); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); font-size: 14px;
  animation: popIn .24s var(--ease); max-width: 80vw;
}
.toast.is-ok { border-color: var(--success); }
.toast.is-err { border-color: var(--danger); }

/* 返回顶部：并入移动端悬浮工具列（.fab-item），PC 不显示 */

/* 搜索联想 */
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 70;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: all .18s var(--ease);
}
.suggest.is-open { opacity: 1; visibility: visible; transform: none; }
.suggest-item { display: flex; gap: 10px; align-items: center; padding: 9px 12px; transition: background .14s var(--ease); }
.suggest-item:hover, .suggest-item.is-active { background: var(--surface-2); }

/* ---------------------------------------------------------------- 正文排版 */
.article { font-size: 15px; line-height: 1.9; color: var(--text-2); overflow-wrap: anywhere; }
.article > *:first-child { margin-top: 0; }
.article p { margin: 0.95em 0; }
.article h1, .article h2, .article h3, .article h4 { color: var(--text); font-weight: 650; margin: 1.5em 0 0.6em; line-height: 1.4; }
.article h2 { font-size: 1.22rem; padding-left: 10px; border-left: 3px solid var(--brand); }
.article h3 { font-size: 1.06rem; }
.article ul, .article ol { padding-left: 1.35em; margin: 0.8em 0; }
.article li { margin: 0.35em 0; }
/* 旧站迁移的正文 img 常带内联 width/height/style，会压过这里的规则导致变形；
   !important 收口：宽度撑满、高度按比例自适应 */
.article img { max-width: 100% !important; height: auto !important; border-radius: var(--radius); margin: 1.1em auto; box-shadow: var(--shadow-sm); }
.article a { color: var(--brand); text-decoration: underline; text-underline-offset: 3px; }
.article blockquote {
  margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--border-strong);
  background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-2);
}
.article code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }
.article pre { background: var(--surface-2); padding: 14px; border-radius: var(--radius); overflow-x: auto; }
.article table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; }
.article th, .article td { border: 1px solid var(--border); padding: 7px 11px; }
.article th { background: var(--surface-2); font-weight: 600; color: var(--text); }

/* ---------------------------------------------------------------- 杂项 */
.divider { height: 1px; background: var(--border); }

.side-sticky { position: sticky; top: 16px; }

/* ---------------------------------------------------------------- 头部用户 hover 信息卡
   点击徽标仍进会员中心；悬停展示账号全名 / 会员权益 / 已购数量 / 退出。
   数据由 /member/brief 惰性加载（hover 才请求，页面渲染零额外开销）。 */
.user-wrap { padding-bottom: 10px; margin-bottom: -10px; }   /* 消除 hover 断层 */
.user-pop {
  position: absolute;
  top: 100%; right: 0;
  width: 248px;
  z-index: 75;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility .18s;
}
.user-wrap:hover .user-pop,
.user-wrap:focus-within .user-pop { opacity: 1; visibility: visible; transform: none; }
.user-pop .vip-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-pop .vip-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: linear-gradient(135deg, rgba(245,158,11,.16), rgba(224,75,75,.14));
  color: #b45309;
}
html.dark .user-pop .vip-badge { color: #fbbf24; }

/* ---------------------------------------------------------------- 悬浮工具列（FAB · 按钮列形态，PC + 移动端常显）
   一列常驻的圆角方形按钮（联系·投诉 / [详情页注入下载] / 回顶部），
   无主球无展开、一步直达。PC 48px、移动端 40px；白底 + 双层阴影的层级语言。
   PC：右侧纵向居中（永不与 footer 重叠）；移动端：右下角（tabbar 上方）。 */
.fab-stack {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fab-item {
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 13px;
  color: #4338ca;                       /* 图标加深一档，白天不发虚 */
  font-size: 20px;
  background: var(--bg-elev);
  /* 双层阴影（Material elevation 2~3）：近处贴地 + 远处柔和投影，
     无边框靠阴影撑边界——悬浮元素"浮在内容之上"的层级语言 */
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 6px 16px -6px rgba(15, 23, 42, .22);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .15s var(--ease), box-shadow .15s;
}
/* 暗色：bg-elev 与页面背景几乎同色会"贴"住 → 用 surface-2 提亮一档，
   图标切亮紫（indigo-300），阴影加强补偿暗色下投影不可见 */
html.dark .fab-item {
  color: #a5b4fc;
  background: var(--surface-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 20px -8px rgba(0, 0, 0, .7);
}
.fab-item:hover { color: var(--brand-hover); }
html.dark .fab-item:hover { color: #c7d2fe; }
.fab-item:active { transform: scale(.92); }
/* 主操作（下载）：紫渐变实心 + 白图标 + 品牌色投影，与「立即下载」主 CTA 视觉统一 */
.fab-item.fab-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--violet));
  box-shadow: 0 4px 14px -4px rgba(79, 70, 229, .55);
}
.fab-item.fab-primary:hover { color: #fff; }
/* 返回顶部：滚动超过阈值才出现（site.js 控制 is-show），不占列位 */
#to-top.fab-item { display: none; }
#to-top.fab-item.is-show { display: grid; animation: fab-in .22s var(--ease); }
@keyframes fab-in {
  from { opacity: 0; transform: translateY(8px); }
}
/* 移动端：更小一号，右下角（重置 PC 的纵向居中），为底部标签栏让位 */
@media (max-width: 767.98px) {
  .fab-stack {
    right: 12px;
    top: auto;
    transform: none;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
    gap: 5px;
  }
  .fab-item {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    font-size: 18px;
  }
}

.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* 移动端为底部标签栏留出空间 */
@media (max-width: 767px) {
  .app-main { padding-bottom: var(--tabbar-h); }
  /* 改为 document（window）滚动：Chrome/Firefox 移动版只在整页滚动时才
     自动收起地址栏/底部工具栏，100dvh + 内部容器滚动永远不收起。
     header 改 sticky 贴顶；tabbar 本就是 fixed；footer 移动端已隐藏。
     site.js 的 initScroll 会按 overflowY 自动切到监听 window，无需改。 */
  .app-shell { height: auto; overflow: visible; display: block; }
  .app-main { overflow-y: visible; }
  .app-header { position: sticky; top: 0; }
}

/* ---------------------------------------------------------------- 动效降级 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
}
