/* ============================================================================
   十八中维基 (wiki.forum18.cn) — 前端样式
   维基百科式的信息结构与排版（门户 / 条目 / 目录 / 信息框 / 衬线标题），
   套上论坛的视觉语言（暖调青绿主色、圆角卡片、轻阴影、中文黑体字族、夜间模式）。

   本文件**故意不 @import style.css**：那份 2000+ 行的论坛专属样式会带进来打架。
   字体与设计令牌在下面自成一份，值必须与 assets/css/style.css 完全一致。
   ========================================================================== */

/* ============================================================================
   ⚠️ 同步提示：下面这一段（@font-face + :root + .night-mode + font-mode 映射）
   与 assets/css/style.css 的 @font-face / :root / .night-mode 是「同一份数据」。
   任何一边改了字重映射、令牌色值或夜间模式配色，必须两边同步改；
   tests/wiki_theme_test.php 会盯着这份一致性。
   为什么抄而不引：维基是面向公网的独立外观，不该被论坛的功能性样式污染，
   但用户从论坛点进维基时不该感觉换了一个站 —— 一致性靠「同数据」而不是「同文件」。
   ========================================================================== */

/* 站内自带字体：显示模式互相独立，且不依赖设备字体，离线也能渲染出正确字面。 */
@font-face { font-family: ForumWenHei; src: url('/assets/fonts/HYWenHei-35W-6.woff2') format('woff2'); font-weight: 300; font-display: block; }
@font-face { font-family: ForumWenHei; src: url('/assets/fonts/HYWenHei-45W-5.woff2') format('woff2'); font-weight: 400; font-display: block; }
@font-face { font-family: ForumWenHei; src: url('/assets/fonts/HYWenHei-55W-4.woff2') format('woff2'); font-weight: 500; font-display: block; }
@font-face { font-family: ForumWenHei; src: url('/assets/fonts/HYWenHei-65W-3.woff2') format('woff2'); font-weight: 600; font-display: block; }
@font-face { font-family: ForumWenHei; src: url('/assets/fonts/HYWenHei-75W-2.woff2') format('woff2'); font-weight: 700; font-display: block; }
@font-face { font-family: ForumWenHei; src: url('/assets/fonts/HYWenHei-85W-1.woff2') format('woff2'); font-weight: 800; font-display: block; }
@font-face { font-family: ForumQiHei; src: url('/assets/fonts/HanYiQiHei-65Jian-Regular-2.woff2') format('woff2'); font-weight: 400; font-display: block; }
@font-face { font-family: ForumWenHei35; src: url('/assets/fonts/HYWenHei-35W-6.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumWenHei45; src: url('/assets/fonts/HYWenHei-45W-5.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumWenHei55; src: url('/assets/fonts/HYWenHei-55W-4.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumWenHei65; src: url('/assets/fonts/HYWenHei-65W-3.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumWenHei75; src: url('/assets/fonts/HYWenHei-75W-2.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumWenHei85; src: url('/assets/fonts/HYWenHei-85W-1.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumQiHei65; src: url('/assets/fonts/HanYiQiHei-65Jian-Regular-2.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumYPHM; src: url('/assets/fonts/YinPinHongMengTi-1.woff2') format('woff2'); font-display: block; }
@font-face { font-family: ForumMsyh; src: local('Microsoft YaHei'), local('微软雅黑'), url('/assets/fonts/msyh.common.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: ForumMincho; src: url('/assets/fonts/RiBenHuaYuanMingChaoTi-2.common.woff2') format('woff2'); font-display: block; }
/* 衬线族：维基的「条目感」全靠它 —— 大标题、章节标题走思源宋体，正文仍走黑体。 */
@font-face { font-family: ForumSerifFallback; src: url('/assets/fonts/SourceHanSerifCN-Regular-1.common.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: ForumSerifFallback; src: url('/assets/fonts/SourceHanSerifCN-Bold-2.common.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: ForumSerifExtralight; src: url('/assets/fonts/SourceHanSerifCN-ExtraLight-3.common.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: ForumSerifLight; src: url('/assets/fonts/SourceHanSerifCN-Light-5.common.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: ForumSerifMedium; src: url('/assets/fonts/SourceHanSerifCN-Medium-6.common.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: ForumSerifSemibold; src: url('/assets/fonts/SourceHanSerifCN-SemiBold-7.common.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: ForumSerifHeavy; src: url('/assets/fonts/SourceHanSerifCN-Heavy-4.common.woff2') format('woff2'); font-display: swap; }

:root {
  /* —— 色彩：暖调青绿（与论坛 :root 同源） —— */
  --primary:            #0d9488;
  --primary-hover:      #0f766e;
  --primary-light:      rgba(13, 148, 136, 0.08);
  --primary-ring:       rgba(13, 148, 136, 0.22);

  --bg:                 #f8f6f4;
  --card-bg:            #ffffff;
  --card-border:        #e7e3de;

  --text:               #1c1917;
  --text-secondary:     #57534e;
  --text-muted:         #a8a29e;

  --link:               #0d9488;
  --link-hover:         #0f766e;

  --danger:             #dc2626;
  --danger-light:       rgba(220, 38, 38, 0.06);
  --warning:            #d97706;
  --warning-light:      rgba(217, 119, 6, 0.08);
  --success:            #16a34a;
  --success-light:      rgba(22, 163, 74, 0.06);

  /* —— 表单 —— */
  --input-bg:           #fafaf9;
  --input-border:       #d6d3d1;
  --input-focus:        #0d9488;

  /* —— 阴影（2 级，维基偏轻，不用重投影） —— */
  --shadow-sm:          0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:          0 4px 16px rgba(0,0,0,0.08);

  /* —— 圆角（统一尺度） —— */
  --radius-sm:          6px;
  --radius-md:          8px;
  --radius-lg:          12px;
  --radius-full:        9999px;

  /* —— 布局 —— */
  --nav-height:         48px;

  /* —— 表面 —— */
  --nav-surface:        #ffffff;
  --topbar-border:      rgba(0,0,0,0.06);
  --footer-bg:          #f0eeec;
  --divider:            #e7e3de;
  --code-bg:            #f0eeec;

  /* —— 徽章 —— */
  --badge-admin-bg:     #fef3c7;
  --badge-admin-color:  #92400e;
  --badge-precept-bg:   #d1fae5;
  --badge-precept-color:#065f46;

  /* —— 过渡 —— */
  --ease:               cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out:           cubic-bezier(0, 0, 0.2, 1);

  /* —— 字体：默认字族 + 衬线字族 —— */
  --forum-font:   "汉仪文黑 85W", "汉仪文黑-85W", "HYWenHei 85W", "HYWenHei-85W", "汉仪文黑",
                  "汉仪旗黑 65W", "汉仪旗黑-65W", "HYQiHei 65W", "HYQiHei-65W",
                  "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --wiki-serif:   ForumSerifFallback, "Songti SC", "SimSun", "Noto Serif SC", "Source Han Serif SC", serif;

  /* —— 维基专属令牌（论坛没有的概念，值仍从既有令牌推导） —— */
  --wiki-topbar-h:      48px;                            /* 顶栏高度，与 --nav-height 保持一致 */
  --wiki-maxw:          1360px;                          /* 三栏时的最大宽度 */
  --wiki-width:         1240px;                          /* 非 grid 页面（列表 / 搜索 / 编辑 / 历史 / 差异）的内容宽度 */
  --wiki-content-maxw:  860px;                           /* 正文最大测量宽度：超过这个数中文就难读 */
  --wiki-rail-w:        180px;                           /* 左目录栏 */
  --wiki-aside-w:       300px;                           /* 右信息框栏 */
  --wiki-gap:           28px;
  --wiki-content-font:  15.5px;                          /* 正文基准字号 */
  --wiki-content-lh:    1.75;                            /* 中文正文行高，比论坛的 1.65 松一档 */

  --wiki-surface-soft:  var(--primary-light);            /* 浅色块（表头、信息框标题、目录栏） */
  --wiki-surface-tint:  var(--footer-bg);                /* 中性浅块（代码块、引用块、图注） */
  --wiki-border-soft:   var(--divider);
  --wiki-hover-bg:      rgba(0,0,0,0.03);
  --wiki-shadow:        var(--shadow-sm);

  --wiki-redlink:       #b32424;                         /* 红链：维基约定俗成，红 = 条目还没写 */
  --wiki-add-bg:        var(--success-light);
  --wiki-add-text:      #166534;
  --wiki-del-bg:        var(--danger-light);
  --wiki-del-text:      #991b1b;
  --wiki-gap-bg:        var(--code-bg);
  --wiki-hl-bg:         #fef08a;                         /* 搜索命中的浅黄高亮 */
  --wiki-hl-text:       var(--text);
  --wiki-danger-link:   #b91c1c;                         /* 「回退」这类红线操作链接：比 --danger 深一档，白底上才够对比 */
}

/* ==================== 中性炭灰夜间模式（与论坛同值） ==================== */
.night-mode {
  --bg:                 #111214;
  --card-bg:            #1b1d20;
  --card-border:        #303238;

  --text:               #f0f1f2;
  --text-secondary:     #b0b2b7;
  --text-muted:         #858890;

  --link:               #2dd4bf;
  --link-hover:         #5eead4;
  --primary:            #2dd4bf;
  --primary-hover:      #5eead4;
  --primary-light:      rgba(45, 212, 191, 0.1);
  --primary-ring:       rgba(45, 212, 191, 0.2);

  --input-bg:           #15171a;
  --input-border:       #3a3d43;
  --input-focus:        #2dd4bf;

  --shadow-sm:          0 1px 2px rgba(0,0,0,0.32);
  --shadow-md:          0 6px 20px rgba(0,0,0,0.38);

  --nav-surface:        #1b1d20;
  --topbar-border:      rgba(255,255,255,0.12);
  --footer-bg:          #0c0d0f;
  --divider:            #292b30;
  --code-bg:            #23262a;

  --badge-admin-bg:     #332200;
  --badge-admin-color:  #fcd34d;
  --badge-precept-bg:   #002211;
  --badge-precept-color:#34d399;

  /* 派生令牌在夜间要改成「浅色叠加」而不是「深色叠加」，必须显式覆盖，
     否则 --wiki-hover-bg 这类 rgba(0,0,0,...) 会黑上加黑，等于没有 hover 反馈。 */
  --wiki-hover-bg:      rgba(255,255,255,0.05);
  --wiki-redlink:       #f87171;
  --wiki-add-bg:        rgba(22, 163, 74, 0.16);
  --wiki-add-text:      #86efac;
  --wiki-del-bg:        rgba(220, 38, 38, 0.16);
  --wiki-del-text:      #fca5a5;
  --wiki-hl-bg:         #a16207;
  --wiki-hl-text:       #fff7ed;
  /* 红线操作链接在深底上必须提亮：直接用 --danger 只有 3.5:1，达不到正文可读性 */
  --wiki-danger-link:   var(--wiki-del-text);
}

/* ==================== 字体模式（与 style.css 同一映射） ==================== */
body.font-mode-brand, body.font-mode-wenhei { --forum-font: ForumWenHei, ForumSerifFallback, sans-serif; }
body.font-mode-qihei { --forum-font: ForumQiHei, ForumWenHei, ForumSerifFallback, sans-serif; }
body.font-mode-system { --forum-font: ForumSystem, ForumSerifFallback, sans-serif; }
body.font-mode-serif { --forum-font: ForumSerifFallback, ForumWenHei, serif; }
body.font-mode-wenhei35 { --forum-font: ForumWenHei35; } body.font-mode-wenhei45 { --forum-font: ForumWenHei45; }
body.font-mode-wenhei55 { --forum-font: ForumWenHei55; } body.font-mode-wenhei65 { --forum-font: ForumWenHei65; }
body.font-mode-wenhei75 { --forum-font: ForumWenHei75; } body.font-mode-wenhei85 { --forum-font: ForumWenHei85; }
body.font-mode-qihei65 { --forum-font: ForumQiHei65; } body.font-mode-msyh { --forum-font: ForumMsyh; }
body.font-mode-device { --forum-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", sans-serif; }
body.font-mode-mincho { --forum-font: ForumMincho, ForumSerifFallback, serif; }
body.font-mode-yphm { --forum-font: ForumYPHM, ForumSerifFallback, sans-serif; }
/* 印品鸿蒙体：信息与装饰文字改灰色；按钮/主色等功能色保留青绿，靠 --text-secondary 自动适配日夜 */
body.font-mode-yphm { --link: var(--text-secondary); --link-hover: var(--text); }
body.font-mode-yphm .wiki-stat-num,
body.font-mode-yphm .wiki-portal-tile-count,
body.font-mode-yphm .wiki-subtitle,
body.font-mode-yphm .wiki-footer-meta { color: var(--text-secondary); }
body.font-mode-serif_extralight { --forum-font: ForumSerifFallback; font-weight: 200; }
body.font-mode-serif_light { --forum-font: ForumSerifFallback; font-weight: 300; }
body.font-mode-serif_regular { --forum-font: ForumSerifFallback; font-weight: 400; }
body.font-mode-serif_medium { --forum-font: ForumSerifFallback; font-weight: 500; }
body.font-mode-serif_semibold { --forum-font: ForumSerifFallback; font-weight: 600; }
body.font-mode-serif_bold { --forum-font: ForumSerifFallback; font-weight: 700; }
body.font-mode-serif_heavy { --forum-font: ForumSerifFallback; font-weight: 900; }
body[class*="font-mode-"] { font-family: var(--forum-font); font-variant-numeric: lining-nums; text-rendering: optimizeLegibility; }
body[class*="font-mode-"] :where(input, textarea, button, select, code) { font-family: var(--forum-font); }
body[class*="font-mode-"] * { text-shadow: none !important; }
body[class*="font-mode-wenhei"], body.font-mode-qihei65, body.font-mode-yphm { font-synthesis: none; }


/* ============================================================================
   1. 基础重置与页面骨架
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* 跳转到正文（.wiki-skip-link / 模板里的 .wiki-skip）：规则合并在文件末尾的「模板外壳」一节，
   这里不再重复一份 —— 同一个语义写两处，迟早只改一处 */

html { -webkit-text-size-adjust: 100%; }

/* body 上的 wiki-page-* 是「这份样式只作用于维基页」的开关，
   防止 wiki.css 万一被别的页面引时污染论坛。 */
body[class*="wiki-page-"] {
  margin: 0;
  font-family: var(--forum-font);
  font-size: 15px;
  font-weight: 300;
  line-height: var(--wiki-content-lh);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  padding-top: var(--wiki-topbar-h);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: 0;
}

/* 表单控件的字体随页面走。但 color: inherit 只给 input/textarea/select ——
   按钮有自己的一套配色（.wiki-btn / .wiki-btn-primary / .wiki-portal-btn …），
   这条规则的特指度是 (0,1,1)，比那些类的 (0,1,0) 高，写在一起会把按钮的字色
   强制成「继承页面的 --text」：浅色下深字压在青绿底上勉强能看，夜间模式下
   浅字压在浅青绿底上只剩 1.65 对比度（同一个原因的另一半）。 */
/* ↓↓↓ 下面这一组是「归一化」规则（把浏览器默认值抹平），它们的特指度必须是 0。
   踩过两次（2026-09-26）：写成 body[class*="wiki-page-"] :where(x) 时，:where() 是 0 但外层是 (0,1,1)，
   比组件类自己的 (0,1,0) 高，于是归一化反过来盖住了组件：
     · 链接色盖住按钮 → 青绿字压青绿底，按钮文字看不见，悬浮才恢复（用户报「绿色按钮要悬浮才看到字」）
     · font: inherit 盖住 .wiki-btn 的字号/行高 → <button> 保存键 44px、旁边 <a> 取消键 39px，同一行高矮不一
   把整个选择器（含 body 那一段）都包进 :where()，特指度就是 (0,0,0)：归一化只兜底，永远不会压过组件。 */
:where(body[class*="wiki-page-"]) :where(input, textarea, button, select) { font: inherit; }
:where(body[class*="wiki-page-"]) :where(input, textarea, select) { color: inherit; }
:where(body[class*="wiki-page-"]) :where(a) { color: var(--link); text-decoration: none; transition: color .15s var(--ease); }
:where(body[class*="wiki-page-"]) :where(h1, h2, h3, h4, h5, h6) { margin: 0; font-weight: 700; line-height: 1.35; }
:where(body[class*="wiki-page-"]) :where(p) { margin: 0; }
:where(body[class*="wiki-page-"]) :where(img) { max-width: 100%; height: auto; }
:where(body[class*="wiki-page-"]) :where(ul, ol) { margin: 0; padding: 0; }
body[class*="wiki-page-"] ::selection { background: var(--primary-ring); color: var(--primary); }
body[class*="wiki-page-"] :where(a, button, input, textarea, select):focus-visible {
  outline: 2px solid var(--primary-ring); outline-offset: 2px;
}

/* 通用内容容器：条目 / 列表 / 搜索 / 编辑 / 历史 / 差异 / 特殊页都用它 */
.wiki-shell {
  width: 100%; max-width: var(--wiki-maxw);
  margin: 0 auto; padding: 26px 20px 64px;
}
.wiki-page-list .wiki-shell,
.wiki-page-search .wiki-shell,
.wiki-page-edit .wiki-shell,
.wiki-page-history .wiki-shell,
.wiki-page-diff .wiki-shell,
.wiki-page-special .wiki-shell { max-width: var(--wiki-width); }


/* ============================================================================
   2. 顶栏
   ========================================================================== */

/* 这里原本是 .wiki-topbar / .wiki-topbar-inner 两份规则，2026-09-26 删掉：
   顶栏早在「把论坛那套导航搬过来」时就换成了 .topbar / .topbar-inner（见文件末尾第 26 节），
   这两个类名不再出现在 DOM 里，规则一条都不生效。留着它们只会让人以为顶栏是「上面那份」，
   而真正在跑的是下面那套 —— 手机上顶栏挤成一团，最初就是照错的那份去改的。 */

.wiki-logo {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  font-size: 15.5px; font-weight: 700; color: var(--text); letter-spacing: .01em;
}
.wiki-logo:hover { color: var(--text); text-decoration: none; }
.wiki-logo-img {
  width: 26px; height: 26px; margin-right: 8px; flex: 0 0 auto;
  object-fit: contain; display: block;
}
/* 维基图标是深色描边的黄底画（已抠掉白底），夜间模式整体提亮一档才看得清 */
.night-mode .wiki-logo-img { filter: brightness(1.2); }

/* 三个 .night-mode 叠在一起是抄写事故：选择器永远不成立，这条基础样式从来没生效过
   （.wiki-forum-link 自己声明了等价的一组值，所以画面看不出来，但基础样式是死的） */
.wiki-nav-link {
  flex: 0 0 auto;
  display: inline-block; padding: 6px 11px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-secondary); white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.wiki-nav-link:hover { background: var(--wiki-hover-bg); color: var(--text); text-decoration: none; }
.wiki-nav-link.is-active { color: var(--primary); background: var(--primary-light); font-weight: 500; }

/* —— 顶栏搜索：只剩一枚放大镜，输入框搬进下面的搜索面板（2026-09-26 用户要求）——
   原来是常驻输入框（.wiki-searchbox / .wiki-search-input / .wiki-search-go 三条已随之删除）：
   它在 320~414px 上要占掉顶栏第二行的一半，四个导航入口只能挤着横滑。
   现在缩成图标，点开的是与巨型菜单同形态的搜索面板（.search-panel，见下面论坛那一段）。 */
.wiki-search-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm);
  transition: background .15s var(--ease);
}
.wiki-search-btn svg { display: block; }
.wiki-search-btn:hover, .wiki-search-btn.is-open { background: var(--wiki-hover-bg); opacity: 1; }

/* 下拉建议：像一张浮起的卡片。
   2026-10：补了克制的入场动画 —— 只认「从隐藏变可见」这一下（wiki.js 的 show() 负责打
   .is-open），连续输入时列表内容被原地替换、不重播，所以不会抖动。 */
.wiki-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 110;
  margin: 0; padding: 4px; list-style: none;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  max-height: 60vh; overflow-y: auto;
}
.wiki-suggest[hidden] { display: none; }
.wiki-suggest.is-open { animation: wikiSuggestIn .2s cubic-bezier(.16, 1, .3, 1); }
@keyframes wikiSuggestIn {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .wiki-suggest.is-open { animation: none; } }
.wiki-suggest-item {
  display: block; padding: 7px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wiki-suggest-item:hover,
.wiki-suggest-item.is-selected { background: var(--primary-light); color: var(--primary); text-decoration: none; }

/* —— 顶栏右侧簇（搜索 + 用户区）——
   这条基础规则 2026-09-26 才补上：之前 .wiki-topbar-right 在 CSS 里只出现在一条窄屏媒体查询里，
   没有基础样式，于是它是个块级 div —— 里面的搜索框独占一行（桌面实测 508px 宽）、
   用户区被挤到第二行，整块 68px 高，而固定顶栏只有 48px，用户区从顶栏底下穿出去 20px。
   桌面和手机都受影响，不是只在窄屏。 */
.wiki-topbar-right {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex-shrink: 0;
}

/* —— 用户区 —— */
.wiki-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wiki-avatar {
  width: 26px; height: 26px; border-radius: var(--radius-full);
  display: block; overflow: hidden; flex: 0 0 26px;
  border: 1px solid var(--card-border); background: var(--code-bg);
}
/* 头像是 <span class="wiki-avatar"> 包着一个 <img>，真正显示的是里面那个 img，
   所以尺寸与裁切必须写在 img 身上。
   只给外层 span 写 width/height/object-fit 是不够的：span 不是替换元素，object-fit 对它无效，
   而里面的 img 不受任何约束、会按原图尺寸渲染，把顶栏撑歪 ——「登录后头像错位」就是这么来的。
   论坛主站那边是给 img 单独一个类（.nav-avatar-img）解决的，这里照同一套做法。 */
.wiki-avatar img {
  width: 100%; height: 100%; display: block; object-fit: cover;
}
.wiki-username {
  font-size: 13.5px; color: var(--text-secondary);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wiki-user-link {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 13.5px; padding: 5px 10px; border-radius: var(--radius-sm);
  line-height: 1.35; white-space: nowrap;
  border: 1px solid var(--card-border); color: var(--text-secondary);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-user-link:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* 夜间模式切换按钮由 JS 注入：没有 JS 就不出现，也不会在顶栏留个死按钮 */
.wiki-night-toggle {
  width: 30px; height: 30px; flex-shrink: 0; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; cursor: pointer;
  color: var(--text-secondary); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-full);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-night-toggle:hover { background: var(--wiki-hover-bg); color: var(--text); border-color: var(--card-border); }
.wiki-night-toggle svg { width: 16px; height: 16px; display: block; }


/* ============================================================================
   3. 门户首页（仿 wikipedia.org 门户）
   ========================================================================== */

.wiki-portal { width: 100%; max-width: var(--wiki-maxw); margin: 0 auto; padding: 20px 20px 64px; }

.wiki-portal-hero { text-align: center; padding: 34px 0 6px; }

/* 大徽标：圆形居中。源图可能是方的，用 object-fit 裁进圆里。 */
.wiki-portal-globe {
  width: 122px; height: 122px; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); overflow: hidden;
  background: radial-gradient(circle at 50% 35%, var(--primary-light), transparent 68%);
  border: 1px solid var(--card-border);
}
.wiki-portal-globe img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wiki-portal-globe svg { width: 62%; height: 62%; }

/* 站名：门户的门面，衬线 + 微负字距，中文大字号才不会散 */
.wiki-portal-wordmark {
  font-family: var(--wiki-serif);
  font-size: clamp(38px, 6.4vw, 58px);
  font-weight: 400; line-height: 1.15; letter-spacing: -0.01em;
  color: var(--text); margin: 0 0 8px;
}
.wiki-portal-tagline { font-size: 15px; color: var(--text-secondary); margin: 0; letter-spacing: .06em; }

.wiki-portal-search { max-width: 560px; margin: 26px auto 6px; }
.wiki-portal-search form { display: flex; gap: 8px; }
.wiki-portal-input {
  flex: 1 1 auto; min-width: 0; height: 46px; padding: 0 18px;
  font-size: 15px; color: var(--text); background: var(--card-bg);
  border: 1px solid var(--input-border); border-radius: var(--radius-full);
  box-shadow: var(--wiki-shadow);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.wiki-portal-input::placeholder { color: var(--text-muted); }
.wiki-portal-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.wiki-portal-btn {
  flex: 0 0 auto; height: 46px; padding: 0 26px;
  font-size: 15px; font-weight: 500; cursor: pointer;
  color: var(--card-bg); background: var(--primary); border: 0; border-radius: var(--radius-full);
  transition: background .15s var(--ease), transform .15s var(--ease);
}
.wiki-portal-btn:hover { background: var(--primary-hover); transform: translateY(-1px); }
.wiki-portal-btn:active { transform: translateY(0); }

.wiki-portal-stats {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 46px;
  margin: 30px auto 8px; padding: 20px 16px;
  max-width: 720px;
  border-top: 1px solid var(--wiki-border-soft);
  border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-stat { text-align: center; min-width: 88px; }
.wiki-stat-num {
  display: block; font-family: var(--wiki-serif);
  font-size: 27px; font-weight: 700; line-height: 1.2; color: var(--primary);
  font-variant-numeric: lining-nums;
}
.wiki-stat-label { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-secondary); letter-spacing: .04em; }

/* 分类入口：对应维基门户首页的「语言列表」，一格一个分类 */
.wiki-portal-grid {
  display: grid; gap: 14px; margin: 30px 0;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
}
.wiki-portal-tile {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); box-shadow: var(--wiki-shadow);
  transition: box-shadow .18s var(--ease), transform .18s var(--ease), border-color .18s var(--ease);
}
.wiki-portal-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--primary-ring); }
.wiki-portal-tile-link { display: block; padding: 15px 18px; color: var(--text); }
.wiki-portal-tile-link:hover { text-decoration: none; color: var(--text); }
.wiki-portal-tile-name { display: block; font-family: var(--wiki-serif); font-size: 17px; font-weight: 700; color: var(--primary); }
.wiki-portal-tile-count { display: block; margin-top: 3px; font-size: 12.5px; color: var(--text-secondary); }

/* 栏目容器本身只是个 grid 项：不加这句它在窄格里会被内容顶宽 */
.wiki-portal-col { display: block; min-width: 0; }

.wiki-portal-columns {
  display: grid; gap: 26px; margin: 34px 0 10px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}
.wiki-portal-col-title {
  font-family: var(--wiki-serif); font-size: 16px; font-weight: 700;
  color: var(--text); margin: 0 0 8px;
  padding-bottom: 7px; border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-portal-list { margin: 0; padding: 0; list-style: none; }
.wiki-portal-list li { padding: 3px 0; font-size: 14px; line-height: 1.65; }
.wiki-portal-list a:hover { text-decoration: underline; }

/* 空状态：门户、搜索结果、分类页共用一个 */
.wiki-empty {
  text-align: center; padding: 54px 20px;
  color: var(--text-secondary);
  background: var(--card-bg); border: 1px dashed var(--card-border);
  border-radius: var(--radius-lg);
}
.wiki-empty-title { font-family: var(--wiki-serif); font-size: 19px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.wiki-empty-text { font-size: 14px; margin: 0; }


/* ============================================================================
   4. 条目页骨架：工具栏 / 标题栏
   ========================================================================== */

.wiki-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-tabs {
  display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
  list-style: none;
}
.wiki-tabs > li { display: flex; flex: 0 0 auto; }
.wiki-tabs::-webkit-scrollbar { display: none; }
.wiki-tab {
  flex: 0 0 auto; padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text-secondary); white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.wiki-tab:hover { background: var(--wiki-hover-bg); color: var(--text); text-decoration: none; }
/* 当前页签只用淡底区分。下沿阴影会在按钮下方留下孤立绿线，尤其在深色模式很明显。 */
.wiki-tab.is-active {
  color: var(--primary); background: var(--primary-light);
  font-weight: 500; box-shadow: none;
}
.wiki-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wiki-action {
  padding: 5px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--card-border); background: var(--card-bg);
  font-size: 13px; color: var(--text-secondary); white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-action:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }

.wiki-titlebar { margin: 4px 0 20px; }
.wiki-title {
  font-family: var(--wiki-serif);
  font-size: clamp(27px, 3.6vw, 38px);
  font-weight: 700; line-height: 1.25; letter-spacing: -0.005em;
  color: var(--text); margin: 0;
  padding-bottom: 10px; border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-subtitle { margin: 9px 0 0; font-size: 14px; color: var(--text-secondary); line-height: 1.6; }


/* ============================================================================
   5. 三栏正文网格：目录栏 / 正文 / 信息框
   ========================================================================== */

.wiki-body-grid {
  display: grid;
  grid-template-columns: var(--wiki-rail-w) minmax(0, 1fr) var(--wiki-aside-w);
  grid-template-areas: "rail content aside";
  gap: var(--wiki-gap);
  align-items: start;
}
.wiki-rail    { grid-area: rail;    position: sticky; top: calc(var(--wiki-topbar-h) + 16px); }
.wiki-content { grid-area: content; min-width: 0; max-width: var(--wiki-content-maxw); }
.wiki-aside   { grid-area: aside;   min-width: 0; position: sticky; top: calc(var(--wiki-topbar-h) + 16px); }

/* 没有信息框 / 没有目录时，空栏不该占位塌出空隙。
   （:has 不支持的旧浏览器会退回上面的默认三栏，只是多留一块空白，不影响可读性） */
.wiki-body-grid:not(:has(.wiki-aside > *)) {
  grid-template-columns: var(--wiki-rail-w) minmax(0, 1fr);
  grid-template-areas: "rail content";
}
.wiki-body-grid:not(:has(.wiki-rail > *)) {
  grid-template-columns: minmax(0, 1fr) var(--wiki-aside-w);
  grid-template-areas: "content aside";
}

/* —— 左目录栏 —— */
.wiki-rail-box {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); padding: 12px 14px;
  box-shadow: var(--wiki-shadow);
}
.wiki-rail-box + .wiki-rail-box { margin-top: 14px; }

.wiki-toc-title {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  letter-spacing: .1em; margin: 0 0 8px;
}
.wiki-toc-list { margin: 0; padding: 0; list-style: none; }
.wiki-toc-item { margin: 0; padding: 0; }
.wiki-toc-item > a {
  display: block; padding: 4px 8px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-toc-item > a:hover { background: var(--wiki-hover-bg); color: var(--text); text-decoration: none; }
/* 正在读的小节：主色左边线 + 淡底；滚动时由 IntersectionObserver 切换 */
.wiki-toc-item.is-active > a,
.wiki-toc-item > a.is-active {
  color: var(--primary); font-weight: 500;
  background: var(--primary-light); border-left-color: var(--primary);
}
/* 层级缩进：级别越深越往里，字号微收 */
.wiki-toc-item.level-2 > a { padding-left: 8px; }
.wiki-toc-item.level-3 > a { padding-left: 20px; font-size: 12.5px; }
.wiki-toc-item.level-4 > a { padding-left: 32px; font-size: 12px; color: var(--text-secondary); }

/* 移动端目录展开按钮：只在 <768px 显示；按钮由 JS 注入，没有 JS 就不折叠 */
.wiki-toc-toggle {
  display: none; width: 100%; margin-bottom: 12px;
  padding: 9px 12px; text-align: left; cursor: pointer;
  font-size: 13.5px; color: var(--text-secondary);
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
}
.wiki-toc-toggle::after { content: " ▾"; color: var(--text-muted); }
.wiki-toc-toggle[aria-expanded="true"]::after { content: " ▴"; }


/* ============================================================================
   6. 信息框（维基的 infobox）
   ========================================================================== */

.wiki-infobox {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-lg); box-shadow: var(--wiki-shadow);
  overflow: hidden; font-size: 13.5px;
}
.wiki-infobox-title {
  margin: 0; padding: 11px 14px;
  font-family: var(--wiki-serif); font-size: 15.5px; font-weight: 700;
  text-align: center; color: var(--text);
  background: var(--wiki-surface-soft);
  border-bottom: 1px solid var(--card-border);
}
.wiki-infobox-image { margin: 0; padding: 12px 14px 0; text-align: center; }
.wiki-infobox-image figcaption {
  padding: 7px 0 0; text-align: center; font-size: 12.5px;
  color: var(--text-secondary); line-height: 1.55;
}
.wiki-infobox-image img {
  display: block; width: 100%; max-width: 100%; height: auto;
  border-radius: var(--radius-sm); background: var(--code-bg);
}
.wiki-infobox-caption { padding: 7px 14px 0; text-align: center; font-size: 12.5px; color: var(--text-secondary); line-height: 1.55; }
.wiki-infobox-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.wiki-infobox-table tr { border-top: 1px solid var(--wiki-border-soft); }
.wiki-infobox-table tr:first-child { border-top: 0; }
.wiki-infobox-table th,
.wiki-infobox-table td { padding: 8px 14px; text-align: left; vertical-align: top; line-height: 1.55; }
.wiki-infobox-table th {
  width: 38%; font-weight: 500; color: var(--text-secondary);
  background: var(--wiki-hover-bg); white-space: nowrap;
}
.wiki-infobox-table td { color: var(--text); word-break: break-word; }


/* ============================================================================
   7. 正文排版（正文黑体、标题衬线 —— 维基的味道来源）
   ========================================================================== */

.wiki-content {
  font-family: var(--forum-font);
  font-size: var(--wiki-content-font);
  line-height: var(--wiki-content-lh);
  color: var(--text);
  overflow-wrap: break-word;
}
.wiki-content > p { margin: 0 0 1.05em; }
/* 段落之间留空而不做首行缩进：屏幕阅读器与维基惯例都如此，中文在网页上更好读 */
.wiki-content > :last-child { margin-bottom: 0; }

/* 章节标题：衬线 + 下边框，制造维基式横线分隔 */
.wiki-heading {
  position: relative;
  font-family: var(--wiki-serif);
  font-weight: 700; line-height: 1.4; color: var(--text);
  margin: 1.85em 0 .7em;
  padding-bottom: .28em;
  border-bottom: 1px solid var(--wiki-border-soft);
  scroll-margin-top: calc(var(--wiki-topbar-h) + 14px);  /* 点目录跳转时别被 fixed 顶栏盖住 */
}
.wiki-heading-text { display: inline; }
/* 标题锚点默认不可见，hover / 键盘聚焦才显形，避免正文里到处是 # */
.wiki-heading-anchor {
  margin-left: .4em; font-size: .72em; font-weight: 400;
  color: var(--text-muted); opacity: 0; text-decoration: none;
  transition: opacity .15s var(--ease), color .15s var(--ease);
}
.wiki-heading:hover .wiki-heading-anchor,
.wiki-heading-anchor:focus-visible { opacity: 1; }
.wiki-heading-anchor:hover { color: var(--primary); text-decoration: none; }

h1.wiki-heading { font-size: 1.62em; }
h2.wiki-heading { font-size: 1.42em; }
h3.wiki-heading { font-size: 1.2em; border-bottom-style: dotted; }
h4.wiki-heading,
h5.wiki-heading,
h6.wiki-heading { font-size: 1.06em; border-bottom: 0; font-weight: 600; }

/* —— 链接 —— */
.wiki-link { color: var(--link); text-decoration: none; transition: color .15s var(--ease); }
.wiki-link:hover { color: var(--link-hover); text-decoration: underline; }
/* 红链：目标条目还没写。红色 + 虚线；hover 用主色提示「点了能建」 */
.wiki-link.is-missing { color: var(--wiki-redlink); text-decoration: underline dotted; text-underline-offset: 2px; }
.wiki-link.is-missing:hover { color: var(--primary); text-decoration: underline; }

.wiki-extlink { color: var(--link); }
.wiki-extlink:hover { color: var(--link-hover); }
.wiki-extlink::after { content: " ↗"; font-size: .82em; opacity: .72; }
.wiki-extlink-internal { color: var(--link); }
.wiki-extlink-internal:hover { color: var(--link-hover); }

/* —— 图片与图注 —— */
.wiki-figure {
  margin: 1.4em 0; padding: 0;
  background: var(--wiki-surface-tint);
  border: 1px solid var(--wiki-border-soft);
  border-radius: var(--radius-lg); overflow: hidden;
}
.wiki-figure img { display: block; width: 100%; height: auto; }
.wiki-figure figcaption {
  padding: 9px 14px; font-size: 12.5px; line-height: 1.6;
  color: var(--text-secondary); text-align: center;
  border-top: 1px solid var(--wiki-border-soft);
}

/* —— 行内代码与代码块 —— */
.wiki-code {
  padding: .14em .38em; margin: 0 .06em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .88em; line-height: 1.5;
  color: var(--text); background: var(--code-bg);
  border: 1px solid var(--wiki-border-soft); border-radius: var(--radius-sm);
  word-break: break-word;
}
.wiki-pre {
  margin: 1.3em 0; padding: 14px 16px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px; line-height: 1.65;
  color: var(--text); background: var(--code-bg);
  border: 1px solid var(--wiki-border-soft); border-radius: var(--radius-md);
  tab-size: 4;
}
.wiki-pre code { font: inherit; color: inherit; background: none; border: 0; padding: 0; }

/* —— 表格 —— */
.wiki-table-wrap {
  margin: 1.4em 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--card-border); border-radius: var(--radius-md);
  background: var(--card-bg);
}
.wiki-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wiki-table caption { padding: 10px 12px; font-size: 13px; color: var(--text-secondary); text-align: left; }
.wiki-table th,
.wiki-table td { padding: 9px 13px; text-align: left; vertical-align: top; line-height: 1.6; border-bottom: 1px solid var(--wiki-border-soft); }
.wiki-table thead th {
  font-weight: 600; color: var(--text); background: var(--wiki-surface-soft);
  white-space: nowrap; border-bottom: 1px solid var(--card-border);
}
.wiki-table tbody tr:last-child th,
.wiki-table tbody tr:last-child td { border-bottom: 0; }
.wiki-table tbody tr:hover { background: var(--wiki-hover-bg); }

/* —— 引用 —— */
.wiki-quote {
  margin: 1.3em 0; padding: 12px 18px;
  font-family: var(--wiki-serif);
  font-size: .98em; line-height: 1.8; color: var(--text-secondary);
  background: var(--wiki-surface-tint);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.wiki-quote > :last-child { margin-bottom: 0; }
.wiki-quote cite,
.wiki-quote footer { display: block; margin-top: .5em; font-size: .82em; font-style: normal; color: var(--text-muted); }

/* —— 列表 —— */
.wiki-list { margin: 1em 0; padding-left: 1.7em; }
.wiki-list li { margin: .28em 0; }
.wiki-list .wiki-list { margin: .28em 0; }
ol.wiki-list { list-style: decimal; }
ul.wiki-list { list-style: disc; }

.wiki-hr { margin: 1.8em 0; border: 0; border-top: 1px solid var(--wiki-border-soft); }

/* —— 引用角标与参考文献 —— */
.wiki-ref { font-size: .74em; line-height: 0; vertical-align: super; margin-left: 1px; }
.wiki-ref a { padding: 0 1px; }
.wiki-references { margin: 1.6em 0 0; }
.wiki-ref-list { margin: .6em 0 0; padding-left: 2em; font-size: 13.5px; line-height: 1.7; color: var(--text-secondary); }
.wiki-ref-list li { margin: .3em 0; scroll-margin-top: calc(var(--wiki-topbar-h) + 14px); }
/* 从正文 [1] 跳到参考文献时把被跳中的那条高亮一下，回来才不会迷路 */
.wiki-ref-list li:target { background: var(--wiki-hl-bg); border-radius: var(--radius-sm); }
.wiki-ref-back { margin-left: .4em; font-size: .92em; color: var(--text-muted); text-decoration: none; }
.wiki-ref-back:hover { color: var(--primary); text-decoration: none; }

/* —— 提示框 —— */
.wiki-callout {
  margin: 1.3em 0; padding: 12px 16px;
  background: var(--card-bg); border: 1px solid var(--wiki-border-soft);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius-md); font-size: 14px;
}
.wiki-callout-title { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.wiki-callout-body { color: var(--text-secondary); line-height: 1.7; }
.wiki-callout-body > :last-child { margin-bottom: 0; }
.wiki-callout-tip { border-left-color: var(--primary); background: var(--primary-light); }
.wiki-callout-tip .wiki-callout-title { color: var(--primary); }
/* 注意 / 警告不只靠颜色区分：标题自带「注意 / 警告」文案，色相只是加强 */
.wiki-callout-note { border-left-color: var(--warning); background: var(--warning-light); }
.wiki-callout-note .wiki-callout-title { color: var(--warning); }
.wiki-callout-warning { border-left-color: var(--danger); background: var(--danger-light); }
.wiki-callout-warning .wiki-callout-title { color: var(--danger); }

/* —— 底部分类条与页脚元信息 —— */
.wiki-cats {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin: 34px 0 0; padding: 12px 14px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); font-size: 13px;
}
/* 这里原本还有一条 .wiki-cats::before { content: "分类：" } —— 模板里已经渲染了
   <span class="wiki-cats-label">分类</span>，两边各写一份的结果是页面上出现「分类：分类」，
   并把分类药丸整体右推 60px、与上方的标签条对不齐。 */
.wiki-cats-label { font-size: 12.5px; letter-spacing: .04em; color: var(--text-secondary); }
.wiki-cats-label::after { content: "："; }
.wiki-cat-tag {
  padding: 3px 10px; border-radius: var(--radius-full);
  background: var(--primary-light); color: var(--primary);
  font-size: 12.5px; line-height: 1.6;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.wiki-cat-tag:hover { background: var(--primary-ring); color: var(--primary-hover); text-decoration: none; }

.wiki-footer-meta { margin: 14px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--text-secondary); }


/* ============================================================================
   8. 编辑页
   ========================================================================== */

.wiki-editor { margin-top: 4px; }
.wiki-editor-choice { max-width: 760px; margin: 8px auto 0; }
.wiki-editor-choice h2 { margin: 0 0 6px; font-family: var(--wiki-serif); font-size: 22px; }
.wiki-editor-choice > p { margin: 0 0 18px; color: var(--text-secondary); }
.wiki-editor-choice-list { display: grid; gap: 10px; }
.wiki-editor-choice-item {
  display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr); align-items: center; gap: 16px;
  min-height: 68px; padding: 12px 16px;
  color: var(--text); text-decoration: none;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-md);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.wiki-editor-choice-item:hover,
.wiki-editor-choice-item:focus-visible { background: var(--primary-light); border-color: var(--primary-ring); outline: none; }
.wiki-editor-choice-item strong { font-size: 15px; }
.wiki-editor-choice-item span { color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.wiki-editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px; margin-bottom: 0;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-bottom: 0; border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.wiki-editor-tool {
  padding: 5px 10px; font-size: 13px; line-height: 1.5; cursor: pointer;
  color: var(--text-secondary); background: var(--input-bg);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-editor-tool:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary-ring); }
.wiki-editor-tool:active { transform: translateY(1px); }

/* 编辑框和工具栏在视觉上是同一张卡片：上圆角已被工具栏吃掉 */
.wiki-editor-textarea {
  display: block; width: 100%; min-height: 420px; resize: vertical;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13.5px; line-height: 1.7; tab-size: 4;
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.wiki-editor-textarea:focus { outline: none; border-color: var(--input-focus); box-shadow: 0 0 0 3px var(--primary-ring); }

.wiki-editor-preview {
  margin-top: 18px; padding: 18px 20px;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-md); min-height: 80px;
}
/* 空预览不占位：编辑页刚打开时不该看到一块空白卡片 */
.wiki-editor-preview:empty { display: none; }
.wiki-editor-preview::before {
  content: "预览"; display: block; margin-bottom: 10px;
  font-size: 12px; letter-spacing: .1em; color: var(--text-muted);
}
.wiki-editor-preview .wiki-content { max-width: none; }

.wiki-editor-help {
  margin-top: 16px; padding: 14px 16px;
  font-size: 13px; line-height: 1.85; color: var(--text-secondary);
  background: var(--wiki-surface-tint);
  border: 1px solid var(--wiki-border-soft); border-radius: var(--radius-md);
}
.wiki-editor-help code {
  padding: 1px 5px; font-size: .92em; color: var(--text);
  background: var(--code-bg); border: 1px solid var(--wiki-border-soft);
  border-radius: var(--radius-sm);
}

.wiki-editor-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--wiki-border-soft);
}


/* ============================================================================
   9. 表单元素与按钮
   ========================================================================== */

.wiki-field { display: block; margin-bottom: 16px; }
.wiki-field > label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 500; color: var(--text); }
.wiki-input,
.wiki-textarea,
.wiki-select {
  display: block; width: 100%; max-width: 100%;
  padding: 9px 12px; font-size: 14px; line-height: 1.6;
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--input-border); border-radius: var(--radius-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.wiki-input:focus,
.wiki-textarea:focus,
.wiki-select:focus { outline: none; border-color: var(--input-focus); box-shadow: 0 0 0 3px var(--primary-ring); }
.wiki-input::placeholder,
.wiki-textarea::placeholder { color: var(--text-muted); }
.wiki-textarea { min-height: 130px; resize: vertical; }
/* 原生下拉箭头各平台长得都不一样，用两个渐变拼一个自绘箭头，视觉才统一 */
.wiki-select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.wiki-input:disabled,
.wiki-textarea:disabled,
.wiki-select:disabled { opacity: .6; cursor: not-allowed; }

.wiki-checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13.5px; color: var(--text-secondary); cursor: pointer; }
.wiki-checkbox input[type="checkbox"] { width: 15px; height: 15px; flex: 0 0 auto; accent-color: var(--primary); cursor: pointer; }

.wiki-form-error,
.wiki-form-notice {
  margin: 0 0 16px; padding: 10px 14px;
  font-size: 13.5px; line-height: 1.65;
  border: 1px solid transparent; border-radius: var(--radius-md);
}
.wiki-form-error { color: var(--danger); background: var(--danger-light); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.wiki-form-notice { color: var(--primary); background: var(--primary-light); border-color: var(--primary-ring); }

.wiki-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 18px; font-size: 14px; font-weight: 500; line-height: 1.5;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  color: var(--text-secondary); background: var(--card-bg);
  border: 1px solid var(--card-border); border-radius: var(--radius-md);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.wiki-btn:hover { color: var(--text); background: var(--wiki-hover-bg); text-decoration: none; }
.wiki-btn:disabled,
.wiki-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.wiki-btn-primary { color: var(--card-bg); background: var(--primary); border-color: var(--primary); box-shadow: var(--wiki-shadow); }
.wiki-btn-primary:hover { color: var(--card-bg); background: var(--primary-hover); border-color: var(--primary-hover); }
.wiki-btn-ghost { color: var(--text-secondary); background: transparent; border-color: transparent; }
.wiki-btn-ghost:hover { color: var(--primary); background: var(--primary-light); }
.wiki-btn-danger { color: var(--danger); background: var(--danger-light); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.wiki-btn-danger:hover { color: var(--card-bg); background: var(--danger); border-color: var(--danger); }
.wiki-btn-sm { padding: 5px 11px; font-size: 13px; border-radius: var(--radius-sm); }


/* ============================================================================
   10. 历史页 / 差异页
   ========================================================================== */

.wiki-history { margin-top: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* .wiki-history-row 是 <tr>，必须保留 table-row。曾误设为 flex，导致每行数据只占表格左半边，
   与仍按表格算法排布的表头完全错列。 */
.wiki-history-row { display: table-row; }
.wiki-history-meta { font-size: 12.5px; color: var(--text-secondary); }

.wiki-byte-diff { font-size: 12.5px; font-weight: 600; font-variant-numeric: lining-nums; white-space: nowrap; }
.wiki-byte-diff.is-plus { color: var(--wiki-add-text); }
.wiki-byte-diff.is-minus { color: var(--wiki-del-text); }

.wiki-diff { margin-top: 6px; }
.wiki-diff-table {
  width: 100%; border-collapse: collapse;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px; line-height: 1.65;
  background: var(--card-bg);
  border: 1px solid var(--card-border); border-radius: var(--radius-md);
  overflow: hidden;
}
.wiki-diff-line.is-add { background: var(--wiki-add-bg); }
.wiki-diff-line.is-del { background: var(--wiki-del-bg); }
.wiki-diff-line.is-gap { background: var(--wiki-gap-bg); color: var(--text-muted); }
/* 行号列：不可选中，复制差异内容时不会把行号带进去 */
.wiki-diff-num {
  width: 1%; min-width: 46px; padding: 1px 10px;
  text-align: right; vertical-align: top;
  color: var(--text-secondary); background: var(--wiki-hover-bg);
  font-variant-numeric: tabular-nums; user-select: none;
  border-right: 1px solid var(--wiki-border-soft);
  white-space: nowrap;
}
.wiki-diff-text {
  padding: 1px 12px; vertical-align: top;
  white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--text);
}
.wiki-diff-line.is-add .wiki-diff-text { color: var(--wiki-add-text); }
.wiki-diff-line.is-del .wiki-diff-text { color: var(--wiki-del-text); }


/* ============================================================================
   11. 列表页 / 搜索页
   ========================================================================== */

.wiki-listpage { margin-top: 6px; }

/* 条目列表按「报刊栏目」排：多列铺满，窄屏自动掉成一列 */
.wiki-pagelist {
  display: grid; gap: 0 22px;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  margin: 6px 0 0; padding: 0; list-style: none;
}
.wiki-pagelist-item { border-bottom: 1px solid var(--wiki-border-soft); }
.wiki-pagelist-item > a { display: block; padding: 7px 2px; font-size: 14px; line-height: 1.6; }
.wiki-pagelist-item > a:hover { text-decoration: underline; }

.wiki-search-results { margin-top: 8px; }
.wiki-search-hit { padding: 14px 0; border-bottom: 1px solid var(--wiki-border-soft); }
.wiki-search-hit:last-child { border-bottom: 0; }
.wiki-search-hit > a,
.wiki-search-hit .wiki-search-title {
  display: block; font-family: var(--wiki-serif);
  font-size: 16.5px; font-weight: 700; line-height: 1.4;
}
.wiki-search-snippet {
  margin: 5px 0 0; font-size: 13.5px; line-height: 1.75;
  color: var(--text-secondary); overflow-wrap: break-word;
}
.wiki-search-snippet mark,
.wiki-hl { padding: 0 2px; color: var(--wiki-hl-text); background: var(--wiki-hl-bg); border-radius: 2px; }

.wiki-pagination {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 26px 0 0; padding-top: 14px;
  border-top: 1px solid var(--wiki-border-soft);
}
.wiki-pagination a,
.wiki-pagination span {
  padding: 6px 12px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--card-border); border-radius: var(--radius-md);
  color: var(--text-secondary); background: var(--card-bg);
}
.wiki-pagination a:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); text-decoration: none; }
.wiki-pagination .is-active,
.wiki-pagination [aria-current="page"] { border-color: var(--primary); color: var(--card-bg); background: var(--primary); }


/* ============================================================================
   12. 页脚
   ========================================================================== */

.wiki-footer {
  margin-top: 34px; padding: 22px 20px 30px;
  border-top: 1px solid var(--wiki-border-soft);
  background: var(--footer-bg);
  font-size: 12.5px; line-height: 1.8; color: var(--text-secondary);
}
.wiki-footer-inner {
  max-width: var(--wiki-maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; justify-content: space-between;
}
.wiki-footer a { color: var(--text-secondary); }
.wiki-footer a:hover { color: var(--primary); }


/* ============================================================================
   13. 响应式
   三档：
     >=1080px  左 180 / 中自适应 / 右 300
     768-1080  两栏：目录栏通栏在上，正文与信息框并排
     <768      单栏，目录折叠成可展开块，顶栏导航横向滚动
   ========================================================================== */

@media (max-width: 1080px) {
  .wiki-body-grid,
  .wiki-body-grid:not(:has(.wiki-aside > *)),
  .wiki-body-grid:not(:has(.wiki-rail > *)) {
    grid-template-columns: minmax(0, 1fr) var(--wiki-aside-w);
    grid-template-areas:
      "rail    rail"
      "content aside";
    gap: 18px var(--wiki-gap);
  }
  /* 目录栏横过来变成两列清单：竖着占满整宽反而更省纵向空间 */
  .wiki-rail { position: static; display: flex; flex-wrap: wrap; gap: 14px; }
  .wiki-rail-box { flex: 1 1 260px; margin-top: 0; }
  .wiki-rail-box + .wiki-rail-box { margin-top: 0; }
  .wiki-toc-list { columns: 2; column-gap: 20px; }
  .wiki-toc-item { break-inside: avoid; }
  .wiki-body-grid:not(:has(.wiki-aside > *)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "rail" "content"; }
  .wiki-body-grid:not(:has(.wiki-rail > *)) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "content" "aside"; }
  .wiki-content { max-width: none; }
}

@media (max-width: 900px) {
  .wiki-username { display: none; }   /* 先把用户名收掉：头像是更强的身份信号 */
}

@media (max-width: 768px) {
  :root { --wiki-gap: 18px; }

  .wiki-shell, .wiki-portal { padding: 16px 14px 48px; }
  body[class*="wiki-page-"] { padding-top: 0; }

  /* 顶栏在窄屏的排布整段搬到了文件末尾的「26. 手机端」：
     这里原本写的是 .wiki-topbar / .wiki-nav / .wiki-topbar-inner ——
     顶栏换成论坛那套（.topbar / .nav-links）之后这些类名就不再出现在 DOM 里，
     规则全部落空，才会出现「手机上一整条顶栏挤成 48px、导航被压成 0 宽」。
     留这一段注释是为了下一个人不再往这里补导航规则。 */

  /* 单栏 */
  .wiki-body-grid,
  .wiki-body-grid:not(:has(.wiki-aside > *)),
  .wiki-body-grid:not(:has(.wiki-rail > *)) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "rail" "aside" "content";
    gap: 16px;
  }
  .wiki-aside { position: static; }

  /* 目录折叠：默认收起，点 .wiki-toc-toggle 展开（按钮由 JS 注入） */
  .wiki-toc-toggle { display: block; }
  .wiki-rail { display: block; }
  .wiki-rail .wiki-toc { display: none; }
  .wiki-rail.is-open .wiki-toc { display: block; }
  .wiki-rail-box { margin-top: 0; }
  .wiki-rail-box + .wiki-rail-box { margin-top: 12px; }
  .wiki-toc-list { columns: auto; }

  .wiki-toolbar { gap: 8px; }
  .wiki-tabs, .wiki-actions { width: 100%; }

  .wiki-title { font-size: 26px; }
  .wiki-titlebar { margin-bottom: 16px; }

  .wiki-editor-textarea { min-height: 320px; }
  .wiki-editor-preview { padding: 14px; }

  .wiki-pagelist { grid-template-columns: minmax(0, 1fr); }
  .wiki-portal-stats { gap: 12px 26px; }
  .wiki-stat-num { font-size: 23px; }
  .wiki-diff-table { font-size: 12px; }
  .wiki-diff-num { min-width: 34px; padding: 1px 6px; }
}

@media (max-width: 480px) {
  .wiki-portal-globe { width: 96px; height: 96px; }
  .wiki-portal-search form { flex-wrap: wrap; }
  .wiki-portal-input, .wiki-portal-btn { flex: 1 1 100%; }
  .wiki-portal-btn { height: 42px; }
}

/* 触屏没有 hover：锚点常显，否则永远看不到 */
@media (hover: none) {
  .wiki-heading-anchor { opacity: .5; }
}

@media print {
  /* .wiki-topbar 是旧外壳的类名，现在的顶栏是 .topbar（layout.php 输出）——
     写错名字的结果是打印时顶栏跟着一起打出来（与「桌面规则写的是新类名」同源） */
  .topbar, .wiki-rail, .wiki-aside, .wiki-toolbar, .wiki-footer, .wiki-night-toggle, .wiki-toc-toggle { display: none !important; }
  body[class*="wiki-page-"] { padding-top: 0; background: #fff; }
  .wiki-body-grid { display: block; }
  .wiki-content { max-width: none; }
  .wiki-extlink::after { content: ""; }
}

/* 动效克制：只用 0.15-0.2s 的位移 / 透明度；用户要求减少动效时全部关掉 */
@media (prefers-reduced-motion: reduce) {
  body[class*="wiki-page-"] *,
  body[class*="wiki-page-"] *::before,
  body[class*="wiki-page-"] *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .wiki-portal-tile:hover,
  .wiki-portal-btn:hover,
  .wiki-editor-tool:active { transform: none; }
}


/* ============================================================================
   14. 模板外壳（layout.php）：body / 跳转链接 / Logo / 论坛入口 / 登录注册 / 无脚本提示
   —— 全部追加在文件末尾，不改动任何既有规则
   ========================================================================== */

/* <body class="wiki-body wiki-page-*">：这里只补基础字面，
   布局与配色仍由上面 body[class*="wiki-page-"] 那条负责，两者是互补而不是覆盖 */
.wiki-body {
  font-family: var(--forum-font);
  font-size: 15px; font-weight: 300;
  line-height: var(--wiki-content-lh);
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 「跳到正文」：屏幕阅读器/键盘用户第一个 Tab 就能跳过顶栏，平时整块移出视口。
   两个类名是同一件东西（模板用 .wiki-skip，早期版本用 .wiki-skip-link），规则只留这一份。 */
.wiki-skip, .wiki-skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 130;
  padding: 10px 16px;
  font-size: 13.5px; text-decoration: none;
  color: var(--text); background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 0 0 var(--radius-md) 0;
  box-shadow: var(--shadow-md);
}
.wiki-skip:focus, .wiki-skip:focus-visible,
.wiki-skip-link:focus, .wiki-skip-link:focus-visible { left: 0; color: var(--text); }
.wiki-skip:hover, .wiki-skip-link:hover { color: var(--text); }

/* Logo：SVG 用 currentColor 才能跟着顶栏的文字色日夜切换（写死颜色会在夜间模式里变成黑块） */
.wiki-logo-mark { width: 22px; height: 22px; flex: 0 0 auto; display: block; color: var(--primary); }
.wiki-logo-mark svg { width: 100%; height: 100%; display: block; }
.wiki-logo-mark path, .wiki-logo-mark circle { fill: currentColor; }
.wiki-logo-text {
  font-size: 15.5px; font-weight: 700; letter-spacing: .01em;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 顶栏的「论坛」入口：比同级导航项多一层边界感，暗示「这是去另一个站」 */
.wiki-forum-link {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; white-space: nowrap;
  color: var(--text-secondary); background: transparent;
  border: 1px solid var(--card-border);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-forum-link:hover {
  color: var(--primary); background: var(--primary-light);
  border-color: var(--primary-ring); text-decoration: none;
}

/* 未登录：注册是主行动，登录是次行动 —— 主次靠填充而不是靠颜色深浅 */
.wiki-login, .wiki-register {
  flex: 0 0 auto;
  display: inline-flex; align-items: center;
  padding: 5px 13px; border-radius: var(--radius-full);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-login { color: var(--text-secondary); background: transparent; border: 1px solid var(--card-border); }
.wiki-login:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary-ring); text-decoration: none; }
.wiki-register { color: var(--card-bg); background: var(--primary); border: 1px solid var(--primary); }
.wiki-register:hover { color: var(--card-bg); background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }

/* 跨域名族登录态接力入口（未登录时才有）：维基挂在 .cn / .top 两个注册域上，Cookie 不互通，
   在另一族登录过的人点它就能把登录态带过来（走主站的 /auth_handoff.php）。
   文案说「同步登录态」而不是「同步 cookies」：这是给偶尔路过的维基读者看的，说人话更有用。
   视觉上比「登录」更轻 —— 它是个补救入口，不是主行动。 */
.wiki-sync {
  flex: 0 0 auto;
  display: inline-flex; align-items: center;
  padding: 5px 10px; border-radius: var(--radius-full);
  font-size: 13.5px; font-weight: 500; white-space: nowrap; text-decoration: none;
  color: var(--text-secondary); background: transparent;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.wiki-sync:hover { color: var(--primary); background: var(--primary-light); text-decoration: none; }

/* 无 JS 提示：默认可见 —— 模板只在 <noscript> 里输出它，而 <noscript> 本身已经表达了
   「有无 JS」这件事；再靠 :only-child 之类猜 DOM 结构，改一行模板就会失效 */
.wiki-noscript {
  margin: 0 0 16px; padding: 9px 14px; font-size: 13px; line-height: 1.65;
  color: var(--warning); background: var(--warning-light);
  border: 1px solid color-mix(in srgb, var(--warning) 32%, transparent);
  border-radius: var(--radius-md);
}
.wiki-noscript.is-hidden { display: none; }

/* 页脚：左站名 / 中链接 / 底注释 三段 */
.wiki-footer-brand { display: flex; flex-direction: column; gap: 2px; line-height: 1.6; min-width: 0; }
.wiki-footer-brand strong { font-size: 13px; font-weight: 700; color: var(--text); }
.wiki-footer-brand span { font-size: 12.5px; color: var(--text-secondary); }
.wiki-footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-size: 12.5px; }
/* 页脚免责声明：原来用 --text-muted，实测对比度只有 2.18（低于 AA 4.5），是要读的字不是装饰 */
.wiki-footer-note {
  flex: 1 0 100%;                 /* 自己占一行：它是小字注释，不该跟链接抢横向空间 */
  margin-top: 8px; padding-top: 8px;
  font-size: 12px; line-height: 1.7; color: var(--text-secondary);
  border-top: 1px solid var(--wiki-border-soft);
}


/* ============================================================================
   15. 左目录栏的补充件与「条目不存在」页
   ========================================================================== */

/* 侧栏小盒子的标题。.wiki-toc-title 是目录专用的，这个是通用件 */
.wiki-rail-title {
  margin: 0 0 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  color: var(--text-muted);
}
.wiki-rail-links { margin: 0; padding: 0; list-style: none; }
.wiki-rail-links li { margin: 0; padding: 0; }
.wiki-rail-links a {
  display: block; padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.wiki-rail-links a:hover { color: var(--primary); background: var(--primary-light); text-decoration: none; }
/* 分类条目数：右对齐 + 等宽数字，一列竖着看才不会歪 */
.wiki-rail-count {
  float: right; margin-left: 8px;
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

/* 条目尚未创建：内容区用「虚线框 + 居中」和普通条目页明确区分 */
.wiki-missing { max-width: 640px; margin: 12px auto 0; text-align: center; }
.wiki-missing .wiki-empty {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--primary) 34%, transparent);
  background: var(--primary-light);
}


/* ============================================================================
   16. 门户与列表的补充件
   ========================================================================== */

.wiki-portal-hints {
  margin: 12px auto 0; text-align: center;
  font-size: 12.5px; line-height: 1.8; color: var(--text-muted);
}
.wiki-portal-hints a { color: var(--link); }
.wiki-portal-list-meta, .wiki-pagelist-meta {
  display: block;
  font-size: 12px; line-height: 1.6; color: var(--text-secondary);
  font-variant-numeric: lining-nums;
}
.wiki-portal-list-meta { margin-top: 1px; }
.wiki-pagelist-meta { margin-top: 2px; font-size: 11.5px; }
.wiki-portal-more {
  display: inline-flex; align-items: center; gap: 3px;
  margin-top: 8px; font-size: 13px; color: var(--link);
  transition: color .15s var(--ease);
}
.wiki-portal-more:hover { color: var(--link-hover); text-decoration: underline; }
.wiki-portal-note {
  margin: 14px 0 0; padding: 10px 14px;
  font-size: 12.5px; line-height: 1.75; color: var(--text-secondary);
  background: var(--wiki-surface-tint);
  border: 1px solid var(--wiki-border-soft);
  border-radius: var(--radius-md);
}
.wiki-category-desc {
  margin: 0 0 18px; padding-bottom: 12px;
  font-size: 13.5px; line-height: 1.75; color: var(--text-secondary);
  border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-cat-count {
  margin-left: 5px;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}
/* 底部分类条前缀：模板写死了「分类」二字，样式里就不再额外注入内容 */
.wiki-cats-label { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.wiki-special-note {
  margin: 0 0 18px; padding: 10px 14px;
  font-size: 13.5px; line-height: 1.75; color: var(--text-secondary);
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
/* 空状态里的行动按钮：居中横排 */
.wiki-empty-actions {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px; margin-top: 16px;
}
/* 紧凑版空状态：侧栏 / 栏目里用，纵向留白只有一半 */
.wiki-empty-inline {
  display: block; padding: 20px 16px; text-align: center;
  font-size: 13px; line-height: 1.7; color: var(--text-secondary);
  background: var(--card-bg);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
}


/* ============================================================================
   17. 搜索页
   ========================================================================== */

.wiki-search-page-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 20px; }
.wiki-search-page-form input[type="search"],
.wiki-search-page-form input[type="text"],
.wiki-search-page-form .wiki-input { flex: 1 1 260px; width: auto; min-width: 0; }
.wiki-search-page-form .wiki-btn { flex: 0 0 auto; }
.wiki-search-hit-title {
  display: block;
  font-family: var(--wiki-serif); font-size: 16.5px; font-weight: 700; line-height: 1.45;
  color: var(--link);                    /* 结果标题当链接用：整行可点，比只让标题里几个字可点好按 */
  transition: color .15s var(--ease);
}
.wiki-search-hit-title:hover { color: var(--link-hover); text-decoration: underline; }
.wiki-search-meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  margin-top: 6px; font-size: 12px; color: var(--text-secondary);
}


/* ============================================================================
   18. 最近更改列表（home.php / special.php）
   一行的信息顺序：标题 → ±字节 → 时间与编者 → 摘要 → 操作。
   窄屏整行允许折行，不让摘要把标题挤没。
   ========================================================================== */

.wiki-recentlist { margin: 8px 0 0; padding: 0; list-style: none; }
.wiki-recentlist li { list-style: none; }
.wiki-recentlist-item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-recentlist-item:hover { background: var(--wiki-hover-bg); }
.wiki-recentlist-title { font-size: 14.5px; font-weight: 500; line-height: 1.5; }
.wiki-recentlist-diff {
  font-size: 12.5px; font-weight: 600;
  font-variant-numeric: lining-nums; white-space: nowrap;
}
.wiki-recentlist-diff.is-plus { color: var(--wiki-add-text); }
.wiki-recentlist-diff.is-minus { color: var(--wiki-del-text); }
.wiki-recentlist-meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 12px; color: var(--text-secondary);
}
.wiki-recentlist-summary {
  flex: 1 1 220px; min-width: 0;
  font-size: 12.5px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wiki-recentlist-ops {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-left: auto; font-size: 12.5px;
}


/* ============================================================================
   19. 差异页的补充件（版本选择器 / 行标记 / 折叠提示）
   ========================================================================== */

.wiki-diff-picker {
  margin: 0 0 16px; padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--wiki-shadow);
}
.wiki-diff-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* label 里的「从 / 到」和 select 必须同一行：默认它们是行内流，会在窄处折行，
   label 变成两行 69px 高，而旁边的「对比」按钮只有 32px —— 一行里高矮差一倍，看着就是错位。 */
.wiki-diff-form label { display: flex; align-items: center; gap: 6px; }
.wiki-diff-form .wiki-select, .wiki-diff-form select { flex: 1 1 220px; width: auto; min-width: 0; }
.wiki-diff-meta { margin: 0 0 12px; font-size: 12.5px; line-height: 1.7; color: var(--text-secondary); }
/* 行首的 +/− 列：等宽居中，符号本身就带语义，颜色只是加强 */
.wiki-diff-mark {
  width: 1%; min-width: 22px; padding: 1px 6px;
  text-align: center; vertical-align: top;
  color: var(--text-secondary); background: var(--wiki-hover-bg);
  font-variant-numeric: tabular-nums; user-select: none;
  border-right: 1px solid var(--wiki-border-soft);
}
.wiki-diff-line.is-add .wiki-diff-mark { color: var(--wiki-add-text); background: var(--wiki-add-bg); }
.wiki-diff-line.is-del .wiki-diff-mark { color: var(--wiki-del-text); background: var(--wiki-del-bg); }
/* 「⋯ 中间有未改动的行 ⋯」——居中灰色，视觉上不该像一行代码 */
.wiki-diff-gap {
  padding: 7px 12px; text-align: center;
  font-family: var(--forum-font);
  font-size: 12px; color: var(--text-secondary);
  background: var(--wiki-gap-bg);
  border-top: 1px solid var(--wiki-border-soft);
  border-bottom: 1px solid var(--wiki-border-soft);
}


/* ============================================================================
   20. 版本历史表
   ========================================================================== */

.wiki-history-table {
  width: 100%; margin-top: 8px;
  font-size: 13.5px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  border-collapse: separate; border-spacing: 0;
  overflow: hidden;
}
.wiki-history-table th {
  padding: 9px 12px; text-align: left; font-weight: 600; color: var(--text);
  background: var(--wiki-surface-soft);
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}
.wiki-history-table td {
  padding: 9px 12px; vertical-align: top; line-height: 1.6;
  color: var(--text); border-bottom: 1px solid var(--wiki-border-soft);
}
.wiki-history-table tbody tr:last-child td { border-bottom: 0; }
.wiki-history-table tbody tr:hover td { background: var(--wiki-hover-bg); }
/* 当前版本：整行淡底，左侧主色线只落在首格，避免破坏表格列宽。 */
.wiki-history-table .wiki-history-row.is-current td { background: var(--primary-light); }
.wiki-history-table .wiki-history-row.is-current td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.wiki-history-table del { color: var(--text-muted); }
.wiki-history-table ins { color: var(--wiki-add-text); text-decoration: none; }
.wiki-history-table time { color: var(--text-secondary); }

.wiki-history-rev { font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 徽章「当前 / 新建 / 小编辑」：小字 + 药丸形，颜色只作区分不作唯一线索 */
.wiki-history-current, .wiki-history-new, .wiki-history-minor {
  display: inline-block; padding: 1px 7px; border-radius: var(--radius-full);
  font-size: 11.5px; line-height: 1.7; white-space: nowrap;
}
.wiki-history-current { color: var(--primary); background: var(--primary-light); border: 1px solid var(--primary-ring); }
.wiki-history-new { color: var(--badge-precept-color); background: var(--badge-precept-bg); }
.wiki-history-minor { color: var(--text-secondary); background: var(--code-bg); }
.wiki-history-time { font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: lining-nums; white-space: nowrap; }
/* 摘要列：长文本一行截断，鼠标悬停看全文（title 属性由模板给） */
.wiki-history-summary { max-width: 320px; }
.wiki-history-summary > span,
.wiki-history-summary .wiki-history-summary-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-history-ops { white-space: nowrap; }
.wiki-history-ops > * { margin-right: 8px; }
.wiki-history-ops > *:last-child { margin-right: 0; }

/* 行内表单 + 长得像链接的提交按钮（回退、删除这类轻量操作） */
.wiki-inline-form { display: inline; margin: 0; padding: 0; }
.wiki-linkbtn {
  display: inline; padding: 0; margin: 0;
  font: inherit; font-size: 13px; line-height: inherit;
  color: var(--link); background: none; border: 0; border-radius: 0;
  cursor: pointer; text-align: left;
  transition: color .15s var(--ease);
}
.wiki-linkbtn:hover { color: var(--link-hover); text-decoration: underline; }
.wiki-linkbtn:disabled { color: var(--text-muted); cursor: not-allowed; text-decoration: none; }
.wiki-linkbtn.is-danger { color: var(--wiki-danger-link); }
.wiki-linkbtn.is-danger:hover { color: var(--wiki-danger-link); background: var(--danger-light); border-radius: var(--radius-sm); }


/* ============================================================================
   21. 编辑页的补充件（字段说明 / 工具栏 / 预览开关 / 保存状态 / 冲突块 / 语法速查）
   ========================================================================== */

.wiki-field-hint { display: block; margin: 5px 0 0; font-size: 12.5px; line-height: 1.7; color: var(--text-muted); }
.wiki-field-optional { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--text-muted); }

/* 把后面的「预览」按钮推到工具栏右端 */
.wiki-editor-tool-spacer { flex: 1 1 auto; }
/* 预览开关：默认是次要按钮；打开时用主色底 + 白字表示「现在看到的正文是预览」 */
.wiki-editor-preview-toggle {
  padding: 5px 11px; font-size: 13px; line-height: 1.5; cursor: pointer;
  color: var(--text-secondary); background: var(--input-bg);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.wiki-editor-preview-toggle:hover { color: var(--primary); background: var(--primary-light); border-color: var(--primary-ring); }
.wiki-editor-preview-toggle.is-active,
.wiki-editor-preview-toggle[aria-pressed="true"] {
  color: var(--card-bg); background: var(--primary); border-color: var(--primary);
}
.wiki-editor-preview-toggle.is-active:hover,
.wiki-editor-preview-toggle[aria-pressed="true"]:hover { color: var(--card-bg); background: var(--primary-hover); }

/* 保存状态行：内容由 wiki.js 写入，这里只定位置与三种状态的色相 */
.wiki-editor-status {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 1.7em;
  font-size: 12.5px; line-height: 1.7; color: var(--text-muted);
}
.wiki-editor-status.is-dirty { color: var(--warning); }
.wiki-editor-status.is-saved { color: var(--success); }
.wiki-editor-status.is-error { color: var(--danger); }
.wiki-editor-status.is-saving { color: var(--text-secondary); }
.wiki-editor-savehint { display: block; margin-top: 6px; font-size: 12px; color: var(--text-muted); }

/* 语法速查：键（代码）在左、说明在右的两列网格。
   编辑页的 .wiki-editor-help-grid 与帮助页的 .wiki-help-grid 共用同一套视觉，
   所以选择器写在一起 —— 两边分开写迟早会长歪。 */
.wiki-editor-help-grid, .wiki-help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1px;                       /* 靠底色的缝隙当分隔线，比给每格画边框干净 */
  margin: 10px 0 0;
  background: var(--wiki-border-soft);
  border: 1px solid var(--wiki-border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.wiki-editor-help-grid > *, .wiki-help-grid > * { padding: 8px 12px; background: var(--card-bg); font-size: 12.5px; line-height: 1.7; }
.wiki-editor-help-grid code, .wiki-help-grid code {
  display: inline-block; padding: 1px 5px;
  font-size: 12px; color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--wiki-border-soft);
  border-radius: var(--radius-sm);
}
.wiki-editor-help-grid .wiki-help-key, .wiki-help-grid .wiki-help-key { color: var(--text); }
.wiki-editor-help-grid .wiki-help-desc, .wiki-help-grid .wiki-help-desc { color: var(--text-secondary); }

/* 编辑冲突：改用警示色一整套，但标题文字本身写明「编辑冲突」，不靠颜色单独表意 */
.wiki-conflict {
  margin: 0 0 16px; padding: 12px 14px;
  font-size: 13.5px; line-height: 1.75; color: var(--text);
  background: var(--warning-light);
  border: 1px solid color-mix(in srgb, var(--warning) 34%, transparent);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-md);
}
.wiki-conflict-title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--warning); }
.wiki-conflict-details { margin-top: 10px; }
.wiki-conflict-details > summary {
  cursor: pointer; font-size: 13px; color: var(--text-secondary);
  padding: 3px 0;
}
.wiki-conflict-details > summary:hover { color: var(--primary); }
.wiki-conflict-details > summary:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 2px; }
.wiki-conflict-details pre, .wiki-conflict-details .wiki-pre {
  margin: 8px 0 0; max-height: 320px; overflow: auto;
  font-size: 12.5px;
  background: var(--code-bg);
  border: 1px solid var(--wiki-border-soft);
  border-radius: var(--radius-sm);
}


/* ============================================================================
   22. 帮助页
   ========================================================================== */

.wiki-help { max-width: var(--wiki-content-maxw); font-size: var(--wiki-content-font); line-height: var(--wiki-content-lh); color: var(--text); }
.wiki-help > h2 { font-family: var(--wiki-serif); font-size: 1.35em; margin: 1.6em 0 .6em; padding-bottom: .25em; border-bottom: 1px solid var(--wiki-border-soft); }
.wiki-help > h3 { font-family: var(--wiki-serif); font-size: 1.12em; margin: 1.3em 0 .5em; }
.wiki-help > p { margin: 0 0 1em; }
.wiki-help > ul, .wiki-help > ol { margin: 0 0 1em; padding-left: 1.7em; }


/* ============================================================================
   23. 头像占位与其它杂项
   ========================================================================== */

/* 没有头像时用姓氏首字：圆形 + 主色淡底，尺寸跟着 .wiki-avatar 走 */
.wiki-avatar-text {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex: 0 0 auto;
  border-radius: var(--radius-full);
  font-size: 12px; font-weight: 600; line-height: 1;
  color: var(--primary); background: var(--primary-light);
  border: 1px solid var(--primary-ring);
  user-select: none;
}


/* ============================================================================
   24. 响应式补充：新增的表格与列表在窄屏的行为
   ========================================================================== */

@media (max-width: 1080px) {
  .wiki-history-summary { max-width: 240px; }
  .wiki-recentlist-summary { flex: 1 1 100%; white-space: normal; }
  .wiki-recentlist-ops { margin-left: 0; }
}

@media (max-width: 768px) {
  /* 六列版本表在手机上一定放不下：改成横向滚动，列宽不再压缩 */
  .wiki-history-table { min-width: 720px; white-space: nowrap; }
  .wiki-history-summary, .wiki-history-table .wiki-history-summary > span { max-width: 180px; }

  .wiki-diff-form .wiki-select, .wiki-diff-form select { flex: 1 1 100%; }
  .wiki-search-page-form input[type="search"],
  .wiki-search-page-form input[type="text"],
  .wiki-search-page-form .wiki-input { flex: 1 1 100%; }
  .wiki-search-page-form .wiki-btn { flex: 1 1 100%; }

  .wiki-editor-help-grid, .wiki-help-grid { grid-template-columns: minmax(0, 1fr); }
  .wiki-editor-choice-item { grid-template-columns: minmax(0, 1fr); gap: 3px; min-height: 76px; }
  .wiki-footer-links { flex: 1 1 100%; }
  .wiki-empty-actions { flex-direction: column; align-items: stretch; }
}


/* ============================================================================
   25. 标签（2026-09-26 新增）
   与「分类」的分工：分类是层级归属（一个条目基本只归一个），标签是自由关键词，
   一个条目可以挂任意多个。视觉上刻意区分：分类是实心浅底药丸，标签是 # 前缀的描边片。
   ========================================================================== */

.wiki-tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin: 22px 0 0; padding: 12px 14px;
  border: 1px dashed var(--wiki-border-soft); border-radius: var(--radius-md);
  background: transparent;
}
.wiki-tags-label {
  font-size: 12.5px; letter-spacing: .04em; color: var(--text-secondary);
}
.wiki-tags-label::after { content: "："; }
.wiki-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; font-size: 12.5px; line-height: 1.6;
  color: var(--link); background: var(--card-bg);
  border: 1px solid var(--wiki-border-soft); border-radius: var(--radius-full);
  text-decoration: none; transition: color .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.wiki-tag::before { content: "#"; opacity: .55; }
.wiki-tag:hover {
  color: var(--primary); background: var(--primary-light);
  border-color: var(--primary-ring); text-decoration: none;
}
.wiki-tag-count {
  font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-secondary);
}
/* 标签云：不加外框，密排 */
.wiki-tags-cloud {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0; padding: 0; border: 0; background: transparent;
}
.wiki-tags-index { gap: 8px 10px; margin-top: 6px; }
.wiki-tags-index .wiki-tag { line-height: 1.5; }

@media (max-width: 768px) {
  .wiki-tags { padding: 10px 12px; gap: 6px; }
  .wiki-tags-index .wiki-tag { font-size: 13px !important; }
}

/* ============================================================================
   论坛顶栏与巨型菜单的样式，原样搬自 assets/css/style.css（第 200-765 行）。
   用户要求「直接把论坛的导航栏搬过来」—— 与其照着重写（上一版重写就是坏的），
   不如整段复用：类名、列布局、动画、夜间覆盖都与论坛逐字一致。
   注意范围要一次取全：.nav-mega-col 与 .nav-mega-col a 在 560 行之后，
   漏掉它们的结果是「面板能开但里面没有内容」（列不成列、链接字号也不对）。
   ========================================================================== */
/* CSS variables reused from global :root above */
.night-mode {
  --nav-link-color: rgba(255,255,255,0.55);
  --nav-link-hover: #fff;
}

.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-height);
  background: var(--nav-surface);
  z-index: 10001;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.topbar.scrolled {
  background: var(--nav-surface);
  box-shadow: none;
}
.night-mode .topbar {
  background: var(--nav-surface);
}
.night-mode .topbar.scrolled {
  background: var(--nav-surface);
  box-shadow: none;
}
.topbar.mega-open,
.topbar.scrolled.mega-open { box-shadow: none; }
.topbar-inner {
  max-width: 1024px; margin: 0 auto;
  width: 100%; height: 100%;
  display: flex; align-items: center; padding: 0 24px;
}

/*
  主导航居中：flex 布局下 .nav-links 只会在「logo 右边 → 右侧集群左边」这段空间里居中，
  左右两块不等宽（未登录时右侧多出「登录 / 注册 / 同步 cookies」三枚按钮）就把导航整体带偏
  （实测 1280px 视口左偏 61px）。改成三栏网格后，左右两栏都是 1fr：空间够时严格等宽 → 导航
  恒在视口中心；空间不够时右栏按自身最小宽度占位、只在两侧之间轻微偏移，永不重叠、永不错位溢出。
  ≤600px 三块放不下（未登录时右侧集群 + logo 已顶满整条），退回原来的流式布局，不做居中。
*/
@media (min-width: 601px) {
  .topbar-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .logo { grid-column: 1; justify-self: start; }
  .nav-links { grid-column: 2; }
  /* 右侧集群禁止被压扁：否则「同步 cookies」这类长标签会在窄屏折成两行把导航栏撑高；
     放不下时宁可让两栏不等宽（导航轻微偏移），也不改按钮换行。 */
  .nav-right { grid-column: 3; justify-self: end; min-width: max-content; }
  /* 维基右侧簇的类名不是论坛的 .nav-right。若不显式放进第三列，Grid
     自动布局会把它排到下一行，固定 48px 的顶栏里就会与正文重叠。 */
  .wiki-topbar-right { grid-column: 3; grid-row: 1; justify-self: end; min-width: max-content; }
}

/* Logo */
.logo {
  flex-shrink: 0; z-index: 2;
  font-size: 21px; font-weight: 500; color: #1d1d1f !important;
  text-decoration: none !important; white-space: nowrap;
  letter-spacing: -0.3px; display: flex; align-items: center; gap: 0;
  opacity: 0.92; transition: opacity 0.2s;
}
.logo:hover { opacity: 1; color: #1d1d1f !important; }
.night-mode .logo { color: #f5f5f7 !important; }
.night-mode .logo:hover { color: #fff !important; }
.logo-img { width: 18px; height: 18px; display: block; object-fit: contain; }
.logo-img + * { display: none; }

/* Nav links — Apple.com.cn 精确：12px, rgba(0,0,0,0.8), 居中对齐，li 间距紧凑 */
.nav-links {
  list-style: none; margin: 0; padding: 0;
  flex: 1; display: flex; justify-content: center; align-items: center; gap: 0;
  z-index: 2; transform: none;
}
.nav-links > li {
  display: flex; justify-content: center; align-items: center;
  padding: 0 16px;
}
.nav-links .nav-dropdown-label,
.nav-links > li > a {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 !important; border: none; border-radius: 0;
  color: rgba(0, 0, 0, 0.8);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  transition: color 0.24s ease;
  text-decoration: none !important;
  background: none !important; cursor: pointer; font-family: inherit;
  line-height: var(--nav-height); height: var(--nav-height);
}

/* hover → 纯黑 */
.nav-links .nav-dropdown-label:hover,
.nav-links > li > a:hover {
  font-weight: 400;
  color: #000;
}
.nav-ucdn-link { position: relative; }
.nav-ucdn-link::before { content: ''; position: absolute; left: 12px; right: 12px; bottom: 3px; height: 2px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .24s ease; opacity: .65; }
.nav-ucdn-link:hover::before, .nav-ucdn-link.active::before { transform: scaleX(1); }
.nav-ucdn-link.active { animation: ucdn-nav-pulse 2.4s ease-in-out infinite; }
.nav-new-feature { animation: ucdn-nav-pulse 2.8s ease-in-out infinite; }
@keyframes ucdn-nav-pulse { 0%,100% { text-shadow: 0 0 0 transparent; } 50% { text-shadow: 0 0 9px color-mix(in srgb, currentColor 45%, transparent); } }
@media (prefers-reduced-motion: reduce) { .nav-ucdn-link.active { animation: none; } }

/* JS 高亮 */
.nav-links .nav-dropdown-label.nav-hover,
.nav-links > li > a.nav-hover {
  font-weight: 400;
  color: #000;
}

/* active */
.nav-links > li > a.nav-active,
.nav-links .nav-dropdown-label.nav-active {
  opacity: 1;
  color: rgba(0,0,0,0.8);
}

/* Night mode — nav links turn white */
.night-mode .nav-links .nav-dropdown-label,
.night-mode .nav-links > li > a {
  color: rgba(255, 255, 255, 0.65);
}
.night-mode .nav-links .nav-dropdown-label:hover,
.night-mode .nav-links > li > a:hover {
  color: #fff;
}
.night-mode .nav-links .nav-dropdown-label.nav-hover,
.night-mode .nav-links > li > a.nav-hover {
  color: #fff;
}
.night-mode .nav-links .nav-dropdown-label.nav-active,
.night-mode .nav-links > li > a.nav-active {
  color: rgba(255, 255, 255, 0.65);
}

/* 下拉箭头 - Apple 风格隐藏 */
.nav-dropdown-label::after {
  display: none;
}

/* ==================== Mega Dropdown Panel — Apple.com.cn 精确 ==================== */
.nav-dropdown { position: static; }

/*
  模糊遮罩 — 仅模糊二级菜单下方的页面内容。
  top:var(--nav-height) 确保导航栏不被模糊
*/
.nav-mega-backdrop {
  position: fixed; top: var(--nav-height); left: 0; width: 100vw; height: calc(100vh - var(--nav-height));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9997;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-mega-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#navMega {
  position: fixed; top: calc(var(--nav-height) - 1px); left: 0; right: 0;
  background: var(--nav-surface);
  z-index: 10000;
  padding: 32px 0 42px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  clip-path: inset(0 0 100% 0);
  visibility: hidden;
  transition: opacity 0.24s cubic-bezier(0.4, 0, 1, 1),
              transform 0.28s cubic-bezier(0.4, 0, 1, 1),
              clip-path 0.28s cubic-bezier(0.4, 0, 1, 1),
              visibility 0s 0.28s;
}

#navMega.open {
  max-height: calc(100vh - var(--nav-height));
  max-height: calc(100dvh - var(--nav-height));
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 1;
  transform: translateY(0);
  clip-path: inset(0);
  visibility: visible;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
              clip-path 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0s 0s;
}

/* Close animation for the outer surface panel */
#navMega.open.closing {
  animation: megaBgOut 0.30s cubic-bezier(0.4, 0, 1, 1) forwards;
  transition: none;
}
#navMega.open.switching {
  overflow: hidden;
  transition: height 0.36s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes megaBgOut {
  from { opacity: 1; transform: translateY(0); clip-path: inset(0); max-height: calc(100dvh - var(--nav-height)); overflow: hidden; }
  to   { opacity: 0; transform: translateY(-8px); clip-path: inset(0 0 100% 0); max-height: 0; overflow: hidden; }
}
/* overflow 由 open/closed 状态直接控制 */
.night-mode #navMega {
  background: var(--nav-surface);
}

@media (max-width: 834px) {
  #navMega {
    /* Keep full-size columns and wrap whole groups when the row is full. */
    padding: 16px 0 24px;
  }
  #navMega.open {
    max-height: calc(100vh - var(--nav-height));
    max-height: calc(100dvh - var(--nav-height));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-mega-inner.active,
  .nav-mega-inner.measuring {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    column-gap: clamp(16px, 4vw, 32px);
    row-gap: 24px;
    overflow: visible;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 14px;
  }
  .nav-mega-col {
    flex: 0 0 max-content;
    min-width: max-content;
  }
}

@media (max-width: 520px) {
  .nav-mega-inner.active,
  .nav-mega-inner.measuring {
    column-gap: 8px;
    row-gap: 24px;
  }
}

.nav-mega-inner {
  display: flex;
  gap: 48px;
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 24px;
  opacity: 0;
  transform: translateY(12px);
  filter: blur(4px);
  visibility: hidden;
  pointer-events: none;
  position: absolute; top: 0; left: 0; right: 0;
}

.nav-mega-inner.active {
  display: flex;
  position: relative;
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
  visibility: visible;
  pointer-events: auto;
  /* open: CSS transition handles entrance */
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.04s,
              transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) 0.04s,
              filter 0.35s cubic-bezier(0.16, 1, 0.3, 1) 0.04s;
}

.nav-mega-inner.measuring {
  display: flex;
  position: absolute;
  opacity: 0;
  transform: none;
  filter: none;
  visibility: hidden;
  pointer-events: none;
}

/* Close animation — must keep .active ON during closing so position stays relative and panel stays in-flow */
.nav-mega-inner.active.closing {
  animation: megaCloseOut 0.26s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
  /* Override open transition with animation */
  transition: none;
}
@keyframes megaCloseOut {
  from { opacity: 1; transform: translateY(0);  filter: blur(0); }
  to   { opacity: 0; transform: translateY(12px); filter: blur(4px); }
}

.nav-mega-inner.active.switching-out {
  animation: megaSwitchOut 0.18s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
  transition: none;
}
@keyframes megaSwitchOut {
  from { opacity: 1; transform: translateY(0); filter: blur(0); }
  to   { opacity: 0; transform: translateY(-10px); filter: blur(4px); }
}

/* Progressive stagger: each column fades in with delay */
.nav-mega-inner.active .nav-mega-col {
  opacity: 0;
  animation: megaColIn 0.45s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.nav-mega-inner.active .nav-mega-col:nth-child(1) { animation-delay: 0.06s; }
.nav-mega-inner.active .nav-mega-col:nth-child(2) { animation-delay: 0.14s; }
.nav-mega-inner.active .nav-mega-col:nth-child(3) { animation-delay: 0.22s; }
.nav-mega-inner.active .nav-mega-col:nth-child(4) { animation-delay: 0.30s; }
.nav-mega-inner.active .nav-mega-col:nth-child(5) { animation-delay: 0.38s; }
.nav-mega-inner.active .nav-mega-col:nth-child(6) { animation-delay: 0.46s; }

/* Progressive stagger: each link within a column */
.nav-mega-inner.active .nav-mega-col a {
  opacity: 0;
  animation: megaLinkIn 0.38s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.nav-mega-inner.active .nav-mega-col:nth-child(1) a:nth-child(2) { animation-delay: 0.10s; }
.nav-mega-inner.active .nav-mega-col:nth-child(1) a:nth-child(3) { animation-delay: 0.14s; }
.nav-mega-inner.active .nav-mega-col:nth-child(1) a:nth-child(4) { animation-delay: 0.18s; }
.nav-mega-inner.active .nav-mega-col:nth-child(1) a:nth-child(5) { animation-delay: 0.22s; }
.nav-mega-inner.active .nav-mega-col:nth-child(1) a[href="polls.php"] { animation-delay: 0.26s; }
.nav-mega-inner.active .nav-mega-col:nth-child(1) a[href="canvas.php"] { animation-delay: 0.30s; }
.nav-mega-inner.active .nav-mega-col:nth-child(1) a[href="canvas_view.php"] { animation-delay: 0.34s; }
.nav-mega-inner.active .nav-mega-col:nth-child(2) a:nth-child(2) { animation-delay: 0.18s; }
.nav-mega-inner.active .nav-mega-col:nth-child(2) a:nth-child(3) { animation-delay: 0.22s; }
.nav-mega-inner.active .nav-mega-col:nth-child(2) a:nth-child(4) { animation-delay: 0.26s; }
.nav-mega-inner.active .nav-mega-col:nth-child(2) a:nth-child(5) { animation-delay: 0.30s; }
.nav-mega-inner.active .nav-mega-col:nth-child(3) a:nth-child(2) { animation-delay: 0.26s; }
.nav-mega-inner.active .nav-mega-col:nth-child(3) a:nth-child(3) { animation-delay: 0.30s; }
.nav-mega-inner.active .nav-mega-col:nth-child(3) a:nth-child(4) { animation-delay: 0.34s; }
.nav-mega-inner.active .nav-mega-col:nth-child(3) a:nth-child(5) { animation-delay: 0.38s; }
.nav-mega-inner.active .nav-mega-col:nth-child(4) a:nth-child(2) { animation-delay: 0.34s; }
.nav-mega-inner.active .nav-mega-col:nth-child(4) a:nth-child(3) { animation-delay: 0.38s; }
.nav-mega-inner.active .nav-mega-col:nth-child(4) a:nth-child(4) { animation-delay: 0.42s; }
.nav-mega-inner.active .nav-mega-col:nth-child(4) a:nth-child(5) { animation-delay: 0.46s; }
.nav-mega-inner.active .nav-mega-col:nth-child(5) a:nth-child(2) { animation-delay: 0.42s; }
.nav-mega-inner.active .nav-mega-col:nth-child(5) a:nth-child(3) { animation-delay: 0.46s; }
.nav-mega-inner.active .nav-mega-col:nth-child(5) a:nth-child(4) { animation-delay: 0.50s; }
.nav-mega-inner.active .nav-mega-col:nth-child(6) a:nth-child(2) { animation-delay: 0.50s; }
.nav-mega-inner.active .nav-mega-col:nth-child(6) a:nth-child(3) { animation-delay: 0.54s; }
.nav-mega-inner.active .nav-mega-col:nth-child(6) a:nth-child(4) { animation-delay: 0.58s; }

/* New destinations continue the existing link stagger without changing panel motion. */
.nav-mega-inner[data-panel="home"].active .nav-mega-col:first-child a[href="courts.php"],
.nav-mega-inner[data-panel="community"].active .nav-mega-col:first-child a[href="courts.php"] { animation-delay: 0.30s; }
.nav-mega-inner[data-panel="home"].active .nav-mega-col:first-child a[href="announcements.php"],
.nav-mega-inner[data-panel="community"].active .nav-mega-col:first-child a[href="announcements.php"] { animation-delay: 0.34s; }
.nav-mega-inner[data-panel="home"].active .nav-mega-col:first-child a[href="canvas.php"],
.nav-mega-inner[data-panel="community"].active .nav-mega-col:first-child a[href="canvas.php"] { animation-delay: 0.38s; }
.nav-mega-inner[data-panel="home"].active .nav-mega-col:first-child a[href="canvas_view.php"],
.nav-mega-inner[data-panel="community"].active .nav-mega-col:first-child a[href="canvas_view.php"] { animation-delay: 0.42s; }
.nav-mega-inner[data-panel="home"].active .nav-mega-col:first-child a[href="go.php"],
.nav-mega-inner[data-panel="community"].active .nav-mega-col:first-child a[href="go.php"] { animation-delay: 0.44s; }
.nav-mega-inner[data-panel="home"].active .nav-mega-col:first-child a[href="shared_files.php"],
.nav-mega-inner[data-panel="community"].active .nav-mega-col:first-child a[href="shared_files.php"] { animation-delay: 0.46s; }
.nav-mega-inner[data-panel="community"].active .nav-mega-col:nth-child(3) a[href="invitation.php"] { animation-delay: 0.42s; }

@keyframes megaColIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes megaLinkIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* On close, reset child animations — but NOT while .closing is running */
.nav-mega-inner:not(.active):not(.closing) .nav-mega-col {
  animation: none;
  opacity: 0;
}
.nav-mega-inner:not(.active):not(.closing) .nav-mega-col a {
  animation: none;
  opacity: 0;
}

.nav-mega-col {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

/* 分类标题 — Apple 灰色小字 */
.nav-mega-heading {
  font-size: 11px;
  font-weight: 600;
  color: #86868b;
  margin-bottom: 8px;
  text-transform: none;
  letter-spacing: -0.12px;
  line-height: 1.4;
}

/* 链接 — Apple 风格超大加粗 */
.nav-mega-col a {
  font-size: 28px;
  font-weight: 800;
  color: #1d1d1f;
  text-decoration: none;
  line-height: 1.2;
  padding: 7px 0;
  transition: color 0.15s;
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.nav-mega-col a + .nav-mega-heading {
  margin-top: 28px;
}

.night-mode .nav-mega-heading {
  color: #86868b;
}

.night-mode .nav-mega-col a {
  color: #f5f5f7;
}

.nav-mega-col a:hover {
  color: #86868b;
  text-decoration: none;
}

.night-mode .nav-mega-col a:hover {
  color: #a1a1a6;
}
.nav-mega-underlay { display: none; }

/* Search — 与右侧用户区同属一个集群（间距交给 .nav-right 的 gap） */
.nav-search-btn {
  flex-shrink: 0; margin-right: 0; z-index: 2;
  background: none; border: none; font-size: 15px; cursor: pointer;
  padding: 4px; opacity: 0.7; transition: opacity 0.15s; color: var(--text);
  line-height: 1;
}
.nav-search-btn:hover { opacity: 1 }

/* Search overlay panel — progressive animation matching mega menu */
.search-panel {
  position: fixed; top: var(--nav-height); left: 0; right: 0;
  background: var(--nav-surface);
  z-index: 9998; padding: 16px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-8px);
  visibility: hidden;
  transition: opacity 0.28s cubic-bezier(0.4, 0, 1, 1),
              transform 0.32s cubic-bezier(0.4, 0, 1, 1),
              visibility 0s 0.32s,
              max-height 0s 0.32s;
}
.search-panel.open {
  max-height: 80px;
  overflow: visible;
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.35s cubic-bezier(0.22, 0.61, 0.36, 1),
              visibility 0s 0s,
              max-height 0s 0s;
}
/* Progressive input entrance */
.search-panel.open .search-panel-input {
  opacity: 0;
  animation: searchInputIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1) 0.08s forwards;
}
@keyframes searchInputIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.night-mode .search-panel {
  background: var(--nav-surface);
  border-bottom-color: var(--card-border);
  box-shadow: var(--shadow-md);
}
.search-panel-inner { max-width: 1024px; margin: 0 auto; padding: 0 22px; }
.search-panel-form { display: flex; align-items: center; gap: 8px; }
.search-panel-input {
  flex: 1; padding: 12px 16px; border: none; border-radius: 0;
  background: rgba(128,128,128,0.08); color: var(--text);
  font-size: 17px; font-family: inherit; outline: none;
  transition: background 0.2s;
}
.search-panel-input:focus { background: rgba(128,128,128,0.14); }
.search-panel-input::placeholder { color: var(--text-muted); }
.search-panel-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  padding: 8px; opacity: 0.5; transition: opacity 0.15s; color: var(--text);
  line-height: 1;
}
.search-panel-close:hover { opacity: 0.8 }

/* Right side */
.nav-right {
  flex-shrink: 0; display: flex; align-items: center; gap: 16px; z-index: 10001;
  position: relative;
}
.nav-avatar {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 12px; color: rgba(0,0,0,0.8);
  transition: color 0.2s; position: relative;
  text-decoration: none !important;
  user-select: none; -webkit-user-select: none;
}
.nav-avatar:hover { color: #000 }
.nav-avatar.nav-hover { color: #000 }
.night-mode .nav-avatar { color: rgba(255,255,255,0.75); }
.night-mode .nav-avatar:hover { color: #fff; }
.night-mode .nav-avatar.nav-hover { color: #fff; }
.nav-avatar-img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; clip-path: circle(50%); }
.nav-avatar-default { font-size: 16px; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; }
.nav-username { font-size: 12px; font-weight: 400; }
.nav-right .btn { font-size: 12px; padding: 4px 11px; border-radius: 0; }
.night-toggle-btn {
  background: none; border: none; font-size: 15px; cursor: pointer;
  padding: 0; opacity: 0.7; transition: opacity 0.15s; color: rgba(0,0,0,0.8);
}
.night-mode .night-toggle-btn { color: rgba(255,255,255,0.75); }
.night-toggle-btn:hover { opacity: 1 }

/* Nav mega 面板内的通知徽章 */
.nav-mega-col a .nav-user-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
  padding: 1px 7px; border-radius: 0;
  font-size: 11px; font-weight: 600;
  vertical-align: middle;
  min-width: 18px; text-align: center;
  line-height: 1.4;
}

/* Mobile — nav always visible but compact, mega hidden */
.mobile-menu-btn { display: none !important; }

/* 菜单展开时仅模糊下方页面内容，不变暗 */
main.container.blurred,
footer.footer.blurred {
  filter: blur(5px);
  transition: filter 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* 首页含 fixed 左栏时，分别模糊两栏，避免 filter 改变 fixed 的定位参照。 */
main.container.blurred:has(.home-sidebar) { filter: none }
main.container.blurred:has(.home-sidebar) .home-sidebar,
main.container.blurred:has(.home-sidebar) .dashboard-shell {
  filter: blur(5px);
  transition: filter 0.35s cubic-bezier(0.25, 0.1, 0.25, 1);
}


/* —— 维基侧的收尾（论坛那段 CSS 没覆盖到的两处） ——
   论坛的 .topbar 是 position:fixed，论坛的 body 在别处留了顶部内边距；
   维基的 body 内边距只在桌面写过，窄屏要补，否则内容会被固定顶栏盖住。
   另外窄屏下 .nav-links 要左对齐并允许横向滑动（居中在可滚动行里等于看不到开头）。 */
@media (max-width: 900px) {
  body[class*="wiki-page-"] { padding-top: var(--nav-height, 48px); }
  .nav-links { justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links > li { padding: 0 12px; }
}

/* —— 顶栏内层要对齐维基版心（用户截图报的错位就是这里） ——
   论坛的 .topbar-inner 是 1024px 宽，因为论坛正文容器就是 1080px，两者本来就配；
   但维基的版心是 --wiki-maxw = 1360px，直接搬过来就会出现：
   1680 宽的窗口上顶栏只占 328..1352，而正文占 160..1520 ——
   logo 比正文左边缩进 168px、右侧元素又短 168px，整条导航像浮在中间的一条窄带。
   把内层宽度与左右内边距都对齐到正文（正文是 max-width + 20px padding），
   logo 才落在正文左边界、右侧簇才落在正文右边界。 */
.topbar-inner {
  max-width: var(--wiki-maxw);
  padding: 0 20px;
}

/* 截图实测桌面端所有顶栏内容的视觉中心比 48px 栏高中心低约 3px。
   只校正内层，不改变顶栏高度与下拉面板的定位基准。 */
@media (min-width: 769px) {
  .topbar-inner { transform: translateY(-3px); }
}

/* 巨型面板同理：论坛的面板是 1020 宽（配它 1080 的版心），
   维基版心 1360，不改的话面板里的栏目左边界比 logo 又缩进 170px。
   与顶栏一样对齐到 --wiki-maxw + 20px 内边距，栏目左边界才与正文、logo 成一条竖线。 */
.nav-mega-inner {
  max-width: var(--wiki-maxw);
  padding: 0 20px;
}

/* 搜索面板（顶栏放大镜点开的那条输入条）同样对齐版心，理由与上面两条一样：
   论坛的 1024 + 22px 内边距是配它 1080 的正文，搬到维基就会左右各缩进 168px。
   另外 .search-panel-form 要 position:relative —— 建议下拉（.wiki-suggest）是
   绝对定位、锚在表单上，缺了它列表会跑到面板左上角去。 */
.search-panel-inner {
  max-width: var(--wiki-maxw);
  padding: 0 20px;
}
.search-panel-form { position: relative; }


/* ============================================================================
   26. 手机端（≤768px）：顶栏换成两行、正文优先、触控尺寸（2026-09-26）
   —— 第 13 节的窄屏规则写的是 .wiki-topbar / .wiki-nav / .wiki-topbar-inner，
      而 layout.php 现在的顶栏来自论坛那套（.topbar / .nav-links / .wiki-topbar-right），
      旧选择器一个都不命中。390px 实测到的样子：
        · .nav-links 被压成 0 宽，四个导航按钮只剩 12×48，文字叠在一起
        · .wiki-topbar-right 里的搜索框与用户区叠成两行，整块 213×70，
          相对 48px 的固定顶栏上下各溢出 11px，压住正文第一屏
      这一节把顶栏在新类名上重写成两行：第一行「品牌 + 夜间/论坛/登录」，
      第二行「导航（可横滑）+ 搜索」。--nav-height 随之改成 96px，
      巨型面板的 top、遮罩的 top、面板最大高度都读这个变量，因而自动对齐。
   ========================================================================== */

@media (max-width: 768px) {
  :root { --nav-height: 96px; }

  /* —— 顶栏：两行 ——
     sticky 而不是 fixed：顶栏回到文档流后自己占位，body 不必再预留高度，
     也不会像 fixed 那样在软键盘弹出时被顶飞。 */
  .topbar { position: sticky; height: auto; }
  .topbar-inner {
    display: flex; flex-wrap: wrap; align-items: center; align-content: center;
    height: auto; min-height: var(--nav-height);
    gap: 4px 8px; padding: 6px 14px;
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
  body[class*="wiki-page-"] { padding-top: 0; }

  .logo { order: 1; font-size: 16px; min-width: 0; }
  .logo-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wiki-logo-img { width: 24px; height: 24px; margin-right: 6px; }

  /* 第一行「品牌 + 用户区（放大镜 / 夜间 / 登录）」，第二行「导航」。
     顶栏的 DOM 是 .topbar-inner > (logo, nav-links, .wiki-topbar-right > (用户区…))，
     用户区是「右侧簇」的子元素，光靠父级 flex-wrap 分不出这两行 —— 那样会得到
     「品牌 / 用户区 / 导航」三行、顶栏高 172px。这里让 .wiki-topbar-right
     用 display: contents 把它那个子项直接交给顶栏容器，再用 order 排成两行。
     （div 没有语义角色，display:contents 在这里不会碰无障碍树那类问题。）
     2026-09-26 起搜索框收进面板，第二行只剩导航，终于能占满整行横滑。 */
  .wiki-topbar-right { display: contents; }
  .wiki-user { order: 2; margin-left: auto; gap: 6px; }
  .nav-links { order: 3; flex: 1 1 auto; min-width: 0; }
  /* 放大镜跟导航同排、贴右端：塞进第一行会把「品牌 + 用户区」挤到换行，顶栏从 96px 涨到 126px */
  .wiki-search-btn { order: 4; margin-left: 4px; }

  /* 导航项：论坛那套是 height/line-height: var(--nav-height)（手机上=96px），必须改掉。
     52px 一行、左右 10px 内边距，四个入口合计约 204px。 */
  .nav-links > li { padding: 0 2px; }
  .nav-links .nav-dropdown-label,
  .nav-links > li > a { height: 42px; line-height: 42px; padding: 0 10px !important; font-size: 13.5px; }

  /* 触控目标：顶栏里所有可点件至少 36px（原来夜间按钮 30、搜索按钮 26） */
  .wiki-night-toggle { width: 36px; height: 36px; }
  .wiki-search-btn { width: 36px; height: 36px; }
  .wiki-user-link, .wiki-forum-link, .wiki-login, .wiki-register { min-height: 36px; display: inline-flex; align-items: center; }
  /* 窄屏第一行只放得下「品牌 + 登录 / 注册」：同步登录态让位。
     手机上从论坛点过来的场景本来就由 wiki/includes/handoff.php 的自动接力覆盖。 */
  .wiki-sync { display: none; }
  .wiki-avatar { width: 28px; height: 28px; }

  /* 搜索面板：手机上输入条要够高（≥44px），关闭键也要能点中 */
  .search-panel { padding: 12px 0; }
  .search-panel.open { max-height: 76px; }
  .search-panel-input { padding: 11px 14px; }
  .search-panel-close { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

  /* —— 正文：先读文章，信息框留到最后 ——
     原来的 grid-template-areas 是 "rail" "aside" "content"：手机读者要先滚过 343px 的目录栏、
     再滚过整块信息框（实测 657px），才看到第一句话。 */
  .wiki-body-grid,
  .wiki-body-grid:not(:has(.wiki-aside > *)),
  .wiki-body-grid:not(:has(.wiki-rail > *)) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "rail" "content" "aside";
    gap: 16px;
  }

  /* 目录栏：目录与「页面工具 / 链入页面」收进同一个折叠。
     不折叠时这一块在手机上能到 300~460px，等于把正文推到第二屏。 */
  /* 只在「有目录折叠按钮」时才收起这两个盒子（按钮由 wiki.js 在目录项 ≥2 条时注入）：
     条目没有目录时不能把它们藏掉，否则页面上再也没有入口。 */
  .wiki-rail:has(.wiki-toc-toggle) > .wiki-rail-box:not(.wiki-toc) { display: none; }
  .wiki-rail.is-open > .wiki-rail-box:not(.wiki-toc) { display: block; margin-top: 12px; }
  .wiki-toc-toggle { min-height: 44px; font-size: 14px; }
  .wiki-toc-item > a { padding: 9px 8px; font-size: 13.5px; }

  /* —— 宽表格：不把六列压成六条 54px 的竖条 ——
     列数 ≥4 时 parser 会加 .wiki-table-wide（列数只有它知道），
     这里给它一个能读的最小宽度，交给 .wiki-table-wrap 横向滚动；
     首列吸边，横滑时不至于丢掉「这是哪一行」。 */
  .wiki-table-wide { min-width: 560px; }
  .wiki-table-wrap { position: relative; }
  .wiki-table-wide thead th:first-child,
  .wiki-table-wide tbody td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--card-bg);
    box-shadow: 1px 0 0 var(--wiki-border-soft);
  }
  .wiki-table-wide thead th:first-child { background: var(--wiki-surface-soft); }

  /* —— 触控尺寸：按钮/页签/清单项 —— 正文里的行内链接不动，那会把段落撑散 —— */
  .wiki-tab { padding: 9px 14px; font-size: 14px; }
  .wiki-action { padding: 9px 13px; font-size: 13.5px; }
  .wiki-rail-links a { padding: 10px 10px; font-size: 13.5px; }
  .wiki-pagelist-item > a { padding: 10px 10px; }
  .wiki-search-hit-title { padding: 8px 0; }
  .wiki-search-hit { padding: 10px 0; }
  .wiki-footer-links a { display: inline-flex; align-items: center; min-height: 36px; }
  .wiki-portal-list li { padding: 6px 0; }
  .wiki-empty-actions .wiki-btn { min-height: 44px; }
  .wiki-heading-anchor { padding: 4px 6px; }        /* 锚点是行内元素，靠内边距把点击区撑到 24px 以上 */

  /* —— 表单：字号 ≥16px，否则 iOS Safari 一聚焦就自动放大整页 —— */
  body[class*="wiki-page-"] :where(input, textarea, select) { font-size: 16px; }
  .wiki-editor-textarea { min-height: 260px; }

  /* —— 门户首页 ——
     （容器内边距、目录折叠、正文单栏等其余窄屏规则仍在第 13 节，这里只管顶栏与触控尺寸） */
  .wiki-portal-wordmark { font-size: clamp(30px, 8.4vw, 38px); }

  .wiki-portal-hints a { display: inline-block; padding: 6px 0; }   /* 门户首屏的三个入口，别只有 15px 高 */
  .wiki-portal-more { display: inline-block; padding: 8px 0; }

  .wiki-footer { padding: 20px 14px calc(28px + env(safe-area-inset-bottom)); }
  .wiki-footer-links { gap: 4px 14px; }
}

/* 更窄的屏幕（≤380px，老款 320/360 机型）：第一行「品牌 + 夜间/登录/注册」放不下
   （实测 320px 时右侧簇被挤到第二行，顶栏变成三行 170px 高）。
   这里收掉「论坛」这一枚跨站入口 —— 它在折叠面板的「有分歧时」和页脚「返回论坛」里都还在，
   而站名、夜间模式、登录/注册在顶栏上没有替代品。 */
@media (max-width: 380px) {
  .wiki-forum-link { display: none; }
  .wiki-user { gap: 4px; }
}
