/* ==================================================================
   EcoWiki-Next · 中文游戏维基主题
   ------------------------------------------------------------------
   设计原则：高信息密度、克制的蓝绿点缀、细腻边框、可读的中文排版。
   - 无外部字体 / 无 CDN / 无图片依赖（图标走 icons.svg sprite）
   - 浅色为默认；[data-theme="dark"] 深色；[data-theme="auto"] 跟随系统
   - 布局：56px sticky 顶栏；桌面 = 侧栏 260 + 正文(max 1100) + 目录 220
   - 断点：≤1100 收起右栏；≤820 侧栏变抽屉；≤560 进一步压缩顶栏
   - 宽表是重点：横向滚动 + thead sticky + 首列 sticky + 可切换自动换行
   ================================================================== */

/* ------------------------------------------------------------------
   1. 设计令牌
   ------------------------------------------------------------------ */
:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, Consolas, "Cascadia Code", monospace;

  --accent: #0f766e;
  --accent-strong: #0d5f59;
  --accent-soft: rgba(15, 118, 110, 0.09);
  --accent-contrast: #ffffff;

  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --surface-3: #e8ecf0;
  --zebra: #f7f8fa;
  --hover: #eef4f3;

  --text: #1f2328;
  --text-2: #57606a;
  --text-3: #6e7781;
  --link: #0b6b62;

  --border: #e3e7ec;
  --border-strong: #d0d7de;

  --danger: #cf222e;
  --danger-soft: rgba(207, 34, 46, 0.08);
  --success: #1a7f37;
  --success-soft: rgba(26, 127, 55, 0.09);
  --warning: #9a6700;
  --warning-soft: rgba(154, 103, 0, 0.11);
  --info: #0969da;
  --info-soft: rgba(9, 105, 218, 0.08);
  --purple: #8250df;
  --purple-soft: rgba(130, 80, 223, 0.09);

  --code-bg: #f6f8fa;
  --code-border: #e6ebf0;

  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.05);
  --shadow-md: 0 6px 24px rgba(31, 35, 40, 0.08);
  --shadow-lg: 0 18px 50px rgba(31, 35, 40, 0.18);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --header-h: 56px;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --content-max: 1100px;

  --focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.28);

  color-scheme: light;
}

/* 深色：显式切换 */
[data-theme="dark"] {
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --accent-contrast: #04231f;

  --bg: #0f1419;
  --surface: #161b22;
  --surface-2: #1b222b;
  --surface-3: #222b36;
  --zebra: #1a212a;
  --hover: #1e2f2d;

  --text: #e6edf3;
  --text-2: #9aa7b4;
  --text-3: #7d8894;
  --link: #4fd1c5;

  --border: #2a313a;
  --border-strong: #3b444f;

  --danger: #ff7b72;
  --danger-soft: rgba(248, 81, 73, 0.14);
  --success: #56d364;
  --success-soft: rgba(63, 185, 80, 0.16);
  --warning: #e3b341;
  --warning-soft: rgba(187, 128, 9, 0.18);
  --info: #79c0ff;
  --info-soft: rgba(56, 139, 253, 0.15);
  --purple: #d2a8ff;
  --purple-soft: rgba(163, 113, 247, 0.16);

  --code-bg: #11161c;
  --code-border: #2a313a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 3px rgba(45, 212, 191, 0.35);

  color-scheme: dark;
}

/* 跟随系统（JS 未执行时的兜底；theme-init.js 正常时会把 auto 解析成 light/dark） */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-soft: rgba(45, 212, 191, 0.12);
    --accent-contrast: #04231f;
    --bg: #0f1419;
    --surface: #161b22;
    --surface-2: #1b222b;
    --surface-3: #222b36;
    --zebra: #1a212a;
    --hover: #1e2f2d;
    --text: #e6edf3;
    --text-2: #9aa7b4;
    --text-3: #7d8894;
    --link: #4fd1c5;
    --border: #2a313a;
    --border-strong: #3b444f;
    --danger: #ff7b72;
    --danger-soft: rgba(248, 81, 73, 0.14);
    --success: #56d364;
    --success-soft: rgba(63, 185, 80, 0.16);
    --warning: #e3b341;
    --warning-soft: rgba(187, 128, 9, 0.18);
    --info: #79c0ff;
    --info-soft: rgba(56, 139, 253, 0.15);
    --purple: #d2a8ff;
    --purple-soft: rgba(163, 113, 247, 0.16);
    --code-bg: #11161c;
    --code-border: #2a313a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(45, 212, 191, 0.35);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------
   2. Reset 与基础
   ------------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* 中文长串、页面 id、URL 等不应把移动端撑出横向滚动条 */
  overflow-wrap: break-word;
}

/* 需要强制断行的文本（标题、提示、错误信息、路径） */
.page-title,
.page-subtitle,
.notice-body,
.error-message,
.empty-text,
.page-namespace,
.search-result-path,
.search-result-snippet,
.change-summary,
.rev-summary {
  overflow-wrap: anywhere;
}

img,
svg,
video {
  max-width: 100%;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* 滚动条（WebKit / Firefox） */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  background-clip: padding-box;
}

/* 工具类 */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-block;
  vertical-align: -0.16em;
}

.js-only {
  display: none !important;
}

html.js .js-only {
  display: inline-flex !important;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 14px;
  font-weight: 600;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
  text-decoration: none;
}

/* ------------------------------------------------------------------
   3. 按钮 / 徽标 / 提示 / 表单
   ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

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

.btn-danger-text:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  gap: 5px;
}

.btn-xs {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  gap: 4px;
  border-radius: 6px;
}

.btn-xs .icon,
.btn-sm .icon {
  width: 14px;
  height: 14px;
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.btn-kbd {
  margin-left: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.16);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
}

.badge--accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.badge--mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.6;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.chip .icon {
  width: 13px;
  height: 13px;
}

.chip--closable:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.delta {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.is-plus {
  color: var(--success);
}

.is-minus {
  color: var(--danger);
}

.is-zero {
  color: var(--text-3);
}

/* 提示条 */
.notices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 20px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.notice-icon {
  display: inline-flex;
  color: var(--info);
  margin-top: 2px;
}

.notice-icon .icon {
  width: 18px;
  height: 18px;
}

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

.notice-body a {
  font-weight: 600;
  text-decoration: underline;
}

.notice--success {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.notice--success .notice-icon {
  color: var(--success);
}

.notice--tip {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.notice--tip .notice-icon {
  color: var(--accent);
}

.notice--note,
.notice--info {
  border-left-color: var(--info);
  background: var(--info-soft);
}

.notice--warning {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.notice--warning .notice-icon {
  color: var(--warning);
}

.notice--error {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.notice--error .notice-icon {
  color: var(--danger);
}

/* 表单 */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.field--inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field--inline > span {
  font-weight: 500;
}

.input,
.select,
.textarea {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select {
  cursor: pointer;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

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

.input--sm {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.inline-input {
  width: 104px;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

/* ------------------------------------------------------------------
   4. 顶栏
   ------------------------------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}

@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .site-header {
    background: var(--surface);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 0 16px;
}

.sidebar-toggle {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: none;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #0b3b36));
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), var(--shadow-sm);
}

[data-theme="dark"] .brand-mark {
  color: #04231f;
}

.brand-mark .icon {
  width: 20px;
  height: 20px;
}

.brand-mark--sm {
  width: 26px;
  height: 26px;
  border-radius: 8px;
}

.brand-mark--sm .icon {
  width: 17px;
  height: 17px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.12;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-tagline {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--text-3);
  text-transform: uppercase;
  white-space: nowrap;
}

/* 搜索框 */
.site-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 520px;
  min-width: 0;
  margin: 0 auto;
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field-icon {
  position: absolute;
  left: 10px;
  width: 17px;
  height: 17px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 68px 0 34px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--focus-ring);
}

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

.search-kbd {
  position: absolute;
  right: 38px;
  padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 18px;
  pointer-events: none;
}

.search-submit {
  position: absolute;
  right: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
}

.search-submit:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.search-submit .icon {
  width: 16px;
  height: 16px;
}

/* 即时建议下拉 */
.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  min-width: 320px;
  max-height: min(68vh, 520px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.search-suggest[hidden] {
  display: none;
}

.suggest-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
}

.suggest-item:hover,
.suggest-item.is-active {
  background: var(--accent-soft);
  text-decoration: none;
}

.suggest-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.suggest-title .icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.suggest-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggest-snippet {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.suggest-snippet mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
}

.suggest-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
}

.suggest-footer kbd {
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.suggest-empty,
.suggest-loading {
  padding: 14px 12px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

/* 顶栏右侧 */
.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}

.header-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.header-link .icon {
  width: 17px;
  height: 17px;
}

.header-login {
  margin-left: 2px;
}

/* 用户菜单 */
.user-menu {
  position: relative;
  margin-left: 2px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 8px 0 4px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
}

.user-chip::-webkit-details-marker {
  display: none;
}

.user-chip:hover {
  background: var(--surface-2);
}

.user-menu[open] .user-chip {
  background: var(--surface-2);
  border-color: var(--border);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.avatar--lg {
  width: 44px;
  height: 44px;
  font-size: 19px;
}

.user-name {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}

.user-chip-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 80;
  min-width: 224px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.menu-header {
  display: flex;
  flex-direction: column;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}

.menu-header strong {
  font-size: 14px;
}

.menu-login {
  color: var(--text-3);
  font-size: 12px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  text-decoration: none;
}

.menu-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.menu-item .icon {
  width: 16px;
  height: 16px;
  color: var(--text-3);
}

.menu-item--danger {
  color: var(--danger);
}

.menu-item--danger .icon {
  color: var(--danger);
}

.menu-form {
  margin: 0;
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}

.menu-note {
  display: block;
  padding: 6px 10px;
  color: var(--text-3);
  font-size: 12px;
}

/* ------------------------------------------------------------------
   5. 主布局 / 侧栏 / 目录
   ------------------------------------------------------------------ */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
  max-width: 1720px;
  margin: 0 auto;
}

.layout.has-toc {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
}

.layout.no-sidebar {
  grid-template-columns: minmax(0, 1fr);
}

.layout.no-sidebar.has-toc {
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
}

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100vh - var(--header-h));
}

.main {
  flex: 1 0 auto;
  min-width: 0;
}

.article {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 36px 56px;
}

.article--wide {
  max-width: none;
}

/* 侧栏 */
.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  padding: 16px 12px 28px;
  scrollbar-gutter: stable;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.sidebar-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sidebar-close {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-group > summary,
.nav-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.nav-group-title::-webkit-details-marker {
  display: none;
}

.nav-group-title:hover {
  color: var(--text-2);
  background: var(--surface-2);
}

.nav-chevron {
  width: 13px;
  height: 13px;
  transition: transform 0.15s ease;
}

.nav-group:not([open]) .nav-chevron {
  transform: rotate(-90deg);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: 3px;
  list-style: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  border-left: 2px solid transparent;
  border-radius: 0 7px 7px 0;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-link.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-link.is-missing {
  color: var(--danger);
  border-bottom: 1px dashed transparent;
  opacity: 0.82;
}

.nav-link.is-missing::after {
  content: "未创建";
  margin-left: auto;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-3);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0;
}

.nav-depth-1 {
  padding-left: 24px;
}

.nav-depth-2 {
  padding-left: 36px;
}

.nav-depth-3 {
  padding-left: 46px;
}

.nav-external {
  width: 12px;
  height: 12px;
  color: var(--text-3);
}

.sidebar-extra {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: 12px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.sidebar-extra-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text-3);
  font-size: 12.5px;
  text-decoration: none;
}

.sidebar-extra-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.sidebar-extra-link .icon {
  width: 15px;
  height: 15px;
}

.sidebar-empty {
  padding: 12px 10px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.7;
}

.sidebar-empty code {
  font-family: var(--font-mono);
  font-size: 12px;
}

.sidebar-empty .btn {
  margin-top: 8px;
}

.sidebar-user {
  padding: 10px 10px 0;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.6;
}

.sidebar-backdrop {
  position: fixed;
  inset: var(--header-h) 0 0;
  z-index: 70;
  background: rgba(10, 14, 18, 0.42);
  backdrop-filter: blur(1px);
}

.sidebar-backdrop[hidden] {
  display: none;
}

/* 右栏目录 */
.toc-col {
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 26px 14px 32px 8px;
  border-left: 1px solid var(--border);
}

.toc-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 6px 8px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.toc-title::-webkit-details-marker {
  display: none;
}

.toc-chevron {
  width: 13px;
  height: 13px;
  transition: transform 0.15s ease;
}

.toc:not([open]) .toc-chevron {
  transform: rotate(-90deg);
}

.toc-list {
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc-link {
  display: block;
  padding: 3px 8px 3px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.toc-link:hover {
  color: var(--text);
  text-decoration: none;
}

.toc-link.is-active {
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.toc-level-3,
.toc-level-4,
.toc-level-5,
.toc-level-6 {
  font-size: 12.5px;
}

.toc-level-3 .toc-link {
  padding-left: 24px;
}

.toc-level-4 .toc-link {
  padding-left: 36px;
}

.toc-level-5 .toc-link {
  padding-left: 46px;
}

.toc-level-6 .toc-link {
  padding-left: 54px;
}

/* ------------------------------------------------------------------
   6. 面包屑 / 页头 / 页脚
   ------------------------------------------------------------------ */
.breadcrumbs {
  margin-bottom: 14px;
}

.crumb-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  list-style: none;
  font-size: 12.5px;
  color: var(--text-3);
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.crumb + .crumb::before {
  content: "/";
  margin-right: 2px;
  color: var(--border-strong);
}

.crumb-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
  text-decoration: none;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crumb-link:hover {
  color: var(--accent);
}

.crumb-link .icon {
  width: 13px;
  height: 13px;
}

.crumb--current > span {
  color: var(--text);
  font-weight: 600;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-head {
  margin-bottom: 14px;
}

.page-title {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--text);
}

.page-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--text-3);
  font-size: 13.5px;
}

.page-subtitle a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-2);
}

.page-subtitle a:hover {
  color: var(--accent);
}

.page-subtitle .icon {
  width: 14px;
  height: 14px;
}

.page-subtitle-sep {
  color: var(--border-strong);
}

.page-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 8px;
}

.page-namespace {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-mono);
}

.page-namespace .icon {
  width: 14px;
  height: 14px;
}

.page-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.page-footer {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.section-label .icon {
  width: 15px;
  height: 15px;
  color: var(--text-3);
}

.section-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 24px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.meta-item dt {
  color: var(--text-3);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.meta-item dd {
  margin-top: 2px;
  color: var(--text);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.meta-user {
  color: var(--text-2);
}

.page-meta .section-label {
  margin-bottom: 8px;
}

.page-media > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}

.page-media[open] > summary {
  margin-bottom: 10px;
}

.page-media > summary::-webkit-details-marker {
  display: none;
}

.media-mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.media-mini-thumb {
  display: block;
  width: 76px;
  height: 76px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

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

.recent-mini-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.recent-mini-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.recent-mini-item:last-child {
  border-bottom: 0;
}

.recent-mini-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-mini-time {
  flex: none;
  color: var(--text-3);
  font-size: 11.5px;
  font-family: var(--font-mono);
}

.content-empty {
  padding: 40px 0;
  color: var(--text-3);
  text-align: center;
}

/* 路由在对不存在的页面渲染 <p class="page-missing"> */
.page-missing {
  padding: 30px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
  text-align: center;
}

.missing-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

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

/* ------------------------------------------------------------------
   7. 正文排版（渲染器输出）
   ------------------------------------------------------------------ */
.wiki-content {
  color: var(--text);
  font-size: 16px;
  line-height: 1.85;
  overflow-wrap: break-word;
}

.wiki-content > *:first-child {
  margin-top: 0;
}

.wiki-content p {
  margin: 0.85em 0;
}

.wiki-content h1,
.wiki-content h2,
.wiki-content h3,
.wiki-content h4,
.wiki-content h5,
.wiki-content h6 {
  position: relative;
  scroll-margin-top: calc(var(--header-h) + 18px);
  color: var(--text);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.wiki-content h1 {
  margin: 1.4em 0 0.7em;
  font-size: 1.8rem;
}

.wiki-content h2 {
  margin: 2.1em 0 0.8em;
  padding-bottom: 0.32em;
  border-bottom: 1px solid var(--border);
  font-size: 1.38rem;
}

.wiki-content h3 {
  margin: 1.7em 0 0.6em;
  font-size: 1.16rem;
}

.wiki-content h4 {
  margin: 1.5em 0 0.5em;
  font-size: 1.04rem;
}

.wiki-content h5,
.wiki-content h6 {
  margin: 1.3em 0 0.5em;
  font-size: 0.98rem;
  color: var(--text-2);
}

.wiki-content .section {
  position: relative;
}

.wiki-content .anchor {
  display: inline-block;
  margin-left: 8px;
  color: var(--text-3);
  font-weight: 400;
  font-size: 0.78em;
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.wiki-content h1:hover .anchor,
.wiki-content h2:hover .anchor,
.wiki-content h3:hover .anchor,
.wiki-content h4:hover .anchor,
.wiki-content h5:hover .anchor,
.wiki-content h6:hover .anchor,
.wiki-content .section:focus-within .anchor {
  opacity: 1;
}

.wiki-content .anchor:hover {
  color: var(--accent);
}

.wiki-content a {
  color: var(--link);
  text-decoration: none;
  border-radius: 2px;
}

.wiki-content a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.wiki-content a.wikilink2 {
  color: var(--danger);
  border-bottom: 1px dashed var(--danger);
}

.wiki-content a.wikilink2:hover {
  background: var(--danger-soft);
  text-decoration: none;
}

.wiki-content a.urlextern::after {
  content: "";
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  margin-left: 0.2em;
  background-color: currentColor;
  opacity: 0.55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M14 4h6v6M20 4l-9 9'/%3E%3Cpath d='M19 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M14 4h6v6M20 4l-9 9'/%3E%3Cpath d='M19 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.wiki-content strong,
.wiki-content b {
  font-weight: 700;
  color: var(--text);
}

.wiki-content em {
  font-style: italic;
}

.wiki-content u {
  text-underline-offset: 2px;
}

.wiki-content del {
  color: var(--text-3);
}

.wiki-content sub,
.wiki-content sup {
  font-size: 0.75em;
  line-height: 0;
}

.wiki-content ul,
.wiki-content ol {
  margin: 0.8em 0;
  padding-left: 1.7em;
}

.wiki-content li {
  margin: 0.28em 0;
}

.wiki-content li > ul,
.wiki-content li > ol {
  margin: 0.25em 0;
}

.wiki-content li::marker {
  color: var(--text-3);
}

.wiki-content code {
  padding: 0.12em 0.38em;
  border: 1px solid var(--code-border);
  border-radius: 4px;
  background: var(--code-bg);
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.wiki-content pre {
  position: relative;
  margin: 1.1em 0;
  padding: 14px 16px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  overflow-x: auto;
  tab-size: 2;
}

.wiki-content pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  color: inherit;
  overflow-wrap: normal;
}

.wiki-content pre.file code,
.wiki-content pre[class*="language"] code {
  color: var(--text);
}

.wiki-content blockquote {
  margin: 1.1em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2);
  color: var(--text-2);
}

.wiki-content blockquote > :first-child {
  margin-top: 0;
}

.wiki-content blockquote > :last-child {
  margin-bottom: 0;
}

.wiki-content hr,
.wiki-content .hr {
  height: 0;
  margin: 2.2em 0;
  border: 0;
  border-top: 1px solid var(--border-strong);
}

.wiki-content img.media {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.wiki-content a.media:hover img.media {
  border-color: var(--accent);
}

.wiki-content .media-missing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px dashed var(--danger);
  border-radius: 5px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.86em;
}

.wiki-content .color {
  font-weight: 600;
}

/* WRAP 提示框 */
.wiki-content .wrap {
  position: relative;
  max-width: 100%;
  margin: 1.15em 0;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--text);
  line-height: 1.75;
  clear: both;
}

.wiki-content .wrap.round {
  border-radius: var(--radius-lg);
}

.wiki-content .wrap.box {
  border-width: 1px 1px 1px 4px;
  border-left-width: 4px;
  box-shadow: var(--shadow-sm);
}

.wiki-content .wrap.left {
  margin-right: auto;
  text-align: left;
}

.wiki-content .wrap.center {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.wiki-content .wrap.right {
  margin-left: auto;
  text-align: right;
}

.wiki-content .wrap.justify {
  text-align: justify;
}

.wiki-content .wrap > :first-child {
  margin-top: 0;
}

.wiki-content .wrap > :last-child {
  margin-bottom: 0;
}

.wiki-content .wrap.tip,
.wiki-content .wrap.download {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.wiki-content .wrap.important {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.wiki-content .wrap.warning,
.wiki-content .wrap.alert {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}

.wiki-content .wrap.help,
.wiki-content .wrap.info,
.wiki-content .wrap.note {
  border-left-color: var(--info);
  background: var(--info-soft);
}

.wiki-content .wrap.todo {
  border-left-color: var(--purple);
  background: var(--purple-soft);
}

.wiki-content .wrap.draft {
  border-left-color: var(--text-3);
  background: var(--surface-2);
}

/* 脚注 */
.wiki-content .fn {
  font-size: 0.75em;
}

.wiki-content .fn a {
  padding: 0 2px;
}

.wiki-content .footnotes {
  margin-top: 2.4em;
  padding-top: 0.6em;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.75;
}

.wiki-content .footnotes hr {
  margin: 0 0 1em;
}

.wiki-content .footnotes ol {
  padding-left: 1.5em;
}

/* ------------------------------------------------------------------
   8. 表格（宽表体验的核心）
   ------------------------------------------------------------------ */
.table-wrap {
  position: relative;
  max-width: 100%;
  margin: 1.2em 0;
  overflow: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.table-wrap.is-scrollable {
  box-shadow: inset -14px 0 14px -14px rgba(15, 23, 32, 0.28);
}

.table-wrap.is-scrolled {
  box-shadow: inset 14px 0 14px -14px rgba(15, 23, 32, 0.28), inset -14px 0 14px -14px rgba(15, 23, 32, 0.28);
}

.table-wrap.is-scrolled-end {
  box-shadow: inset 14px 0 14px -14px rgba(15, 23, 32, 0.28);
}

.wiki-content table,
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  line-height: 1.6;
  background: var(--surface);
}

.wiki-content table th,
.wiki-content table td,
.data-table th,
.data-table td {
  padding: 7px 11px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
  background-clip: padding-box;
}

.wiki-content table tr > :last-child,
.data-table tr > :last-child {
  border-right: 0;
}

.wiki-content table tbody tr:last-child > td,
.data-table tbody tr:last-child > td {
  border-bottom: 0;
}

.wiki-content table thead th,
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
}

.wiki-content table tbody tr:nth-child(even) > td,
.data-table tbody tr:nth-child(even) > td {
  background: var(--zebra);
}

.wiki-content table tbody tr:hover > td,
.data-table tbody tr:hover > td {
  background: var(--hover);
}

.wiki-content table.th-aligncenter,
.wiki-content table td[style*="center"] {
  text-align: center;
}

/* 宽表：列很多时首列吸附，单元格默认不换行（数字/短词为主的装备表） */
.wiki-content table.wikitable--wide th,
.wiki-content table.wikitable--wide td {
  white-space: nowrap;
  padding: 6px 10px;
}

.wiki-content table.wikitable--wide thead th:first-child,
.wiki-content table.wikitable--wide tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}

.wiki-content table.wikitable--wide thead th:first-child {
  z-index: 4;
  background: var(--surface-2);
}

.wiki-content table.wikitable--wide tbody tr:nth-child(even) td:first-child {
  background: var(--zebra);
}

.wiki-content table.wikitable--wide tbody tr:hover td:first-child {
  background: var(--hover);
}

/* JS「自动换行」开关 */
.wiki-content table.wikitable--wide.wikitable--wrapped th,
.wiki-content table.wikitable--wide.wikitable--wrapped td {
  white-space: normal;
  min-width: 96px;
}

.wiki-content table.wikitable--wide.wikitable--wrapped td:first-child,
.wiki-content table.wikitable--wide.wikitable--wrapped th:first-child {
  min-width: 120px;
}

/* 表格工具条（app.js 注入） */
.table-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1.2em 0 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11.5px;
}

.table-bar + .table-wrap {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.table-bar-meta {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.table-bar .btn {
  height: 24px;
  padding: 0 8px;
  font-size: 11.5px;
  background: var(--surface);
}

/* ------------------------------------------------------------------
   9. 最近更新 / 搜索 / 目录
   ------------------------------------------------------------------ */
.recent-page,
.search-page,
.index-page,
.diff-page {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.change-day-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.change-day-count {
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 400;
}

.change-list {
  list-style: none;
}

.change-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px 10px;
  padding: 7px 6px;
  border-bottom: 1px dashed var(--border);
  border-radius: 5px;
  font-size: 14px;
}

.change-item:hover {
  background: var(--surface-2);
}

.change-time {
  flex: none;
  width: 42px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
}

.change-title {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.change-title:hover {
  color: var(--accent);
}

.change-user {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 12px;
}

.change-user .icon {
  width: 12px;
  height: 12px;
}

.change-summary {
  flex-basis: 100%;
  padding-left: 52px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.change-type--new {
  border-color: transparent;
  background: var(--success-soft);
  color: var(--success);
}

.change-type--delete {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

.change-type--revert {
  border-color: transparent;
  background: var(--warning-soft);
  color: var(--warning);
}

.change-type--upload {
  border-color: transparent;
  background: var(--purple-soft);
  color: var(--purple);
}

.recent-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 6px;
}

/* 搜索页 */
.search-page-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-page-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.search-page-field > .icon {
  width: 20px;
  height: 20px;
  color: var(--text-3);
  flex: none;
}

.search-page-field .input {
  height: 42px;
  font-size: 15px;
}

.search-page-field .btn {
  height: 42px;
  flex: none;
}

.search-scope {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 13px;
}

.search-scope .icon {
  width: 14px;
  height: 14px;
}

.search-summary {
  color: var(--text-2);
  font-size: 13.5px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.search-result {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover {
  background: var(--surface-2);
}

.search-result-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.search-result-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.search-result-ns {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
}

.search-result-path {
  margin-top: 2px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow-wrap: anywhere;
}

.search-result-snippet {
  margin-top: 5px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.search-result-snippet mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.search-result-meta {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 12px;
}

.search-more {
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  text-align: center;
}

.empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-icon .icon {
  width: 26px;
  height: 26px;
}

.empty-title {
  font-size: 17px;
  font-weight: 700;
}

.empty-text {
  max-width: 460px;
  color: var(--text-3);
  font-size: 13.5px;
  line-height: 1.75;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

/* 全站目录 */
.index-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.index-filter {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  max-width: 420px;
}

.index-filter > .icon {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}

.index-filter .input {
  padding-left: 34px;
}

.index-body {
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.index-list {
  list-style: none;
  padding-left: 0;
}

.index-list .index-list {
  padding-left: 20px;
  margin-left: 12px;
  border-left: 1px dashed var(--border);
}

.index-leaf {
  padding: 1px 0;
}

.index-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 14px;
}

.index-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.index-icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.index-ns-details > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  list-style: none;
}

.index-ns-details > summary::-webkit-details-marker {
  display: none;
}

.index-ns-details > summary::before {
  content: "▸";
  color: var(--text-3);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.index-ns-details[open] > summary::before {
  content: "▾";
}

.index-ns-details > summary:hover {
  background: var(--surface-2);
}

.index-ns-name {
  overflow-wrap: anywhere;
}

.index-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

.index-ns[hidden],
.index-leaf[hidden] {
  display: none;
}

.index-media {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--surface);
}

.index-media > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}

.index-media > summary::-webkit-details-marker {
  display: none;
}

.index-media[open] > summary {
  margin-bottom: 10px;
}

/* ------------------------------------------------------------------
   10. 历史 / 对比
   ------------------------------------------------------------------ */
.compare-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.compare-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.compare-label .icon {
  width: 15px;
  height: 15px;
  color: var(--text-3);
}

.compare-form .select {
  width: auto;
  min-width: 200px;
  height: 34px;
}

.compare-vs {
  color: var(--text-3);
  font-size: 12.5px;
}

.data-table th,
.data-table td {
  font-size: 13px;
}

.revisions-table .rev-row.is-current td {
  background: var(--accent-soft);
}

.revisions-table .rev-row.is-current td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.rev-time {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.rev-link {
  color: var(--text);
}

.rev-link:hover {
  color: var(--accent);
}

.rev-time .badge {
  margin-left: 6px;
}

.rev-user {
  white-space: nowrap;
  font-size: 13px;
}

.rev-ip {
  display: block;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.rev-size {
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}

.rev-total {
  display: block;
  color: var(--text-3);
  font-size: 10.5px;
}

.rev-summary {
  min-width: 180px;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.rev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  white-space: nowrap;
}

.rev-actions .inline-form {
  display: inline-flex;
}

/* diff */
.diff-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diff-versions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.diff-version {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}

.diff-version--old {
  border-left: 3px solid var(--danger);
}

.diff-version--new {
  border-left: 3px solid var(--success);
}

.diff-version-label {
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.diff-rev {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.diff-rev-user {
  color: var(--text-3);
  font-family: var(--font-sans);
  font-size: 12px;
}

.diff-arrow {
  color: var(--text-3);
}

.diff-arrow .icon {
  width: 18px;
  height: 18px;
}

.diff-legend {
  display: flex;
  gap: 6px;
  font-size: 12px;
}

.diff-legend-item {
  padding: 1px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.diff-legend-item--add {
  background: var(--success-soft);
  color: var(--success);
}

.diff-legend-item--del {
  background: var(--danger-soft);
  color: var(--danger);
}

.diff-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
}

.diff-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.diff-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
}

.diff-wrap td,
.diff-wrap th {
  padding: 2px 10px;
  border: 0;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-wrap .lineno,
.diff-wrap .diff-lineno,
.diff-wrap .diff-gutter,
.diff-gutter {
  width: 1%;
  color: var(--text-3);
  text-align: right;
  user-select: none;
  background: var(--surface-2);
  white-space: nowrap;
  font-size: 11.5px;
}

.diff-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12px;
  white-space: nowrap;
}

.diff-added,
.diff-line-added,
.diff-add,
.diffins,
ins.diffins,
.diff-line--add,
td.added {
  background: var(--success-soft) !important;
  color: var(--success);
}

.diff-deleted,
.diff-line-deleted,
.diff-del,
.diffdel,
del.diffdel,
.diff-line--del,
.diff-deletedline,
td.removed {
  background: var(--danger-soft) !important;
  color: var(--danger);
}

/* DokuWiki 风格的 diff 结构（diff.js 若直接输出原站类名也能正确着色） */
.diff-addedline {
  background: var(--success-soft) !important;
  color: var(--success);
}

.diff-deletedline {
  background: var(--danger-soft) !important;
  color: var(--danger);
}

.diff-lineheader,
.diff-blockheader {
  color: var(--text-3);
  background: var(--surface-2) !important;
  font-family: var(--font-sans);
  font-size: 11.5px;
  white-space: nowrap;
}

.diff-wrap ins.diffins,
.diff-wrap del.diffdel {
  border-radius: 3px;
  padding: 0 1px;
  text-decoration: none;
}

.diff-line {
  display: grid;
  grid-template-columns: 44px 44px minmax(0, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
}

.diff-line:last-child {
  border-bottom: 0;
}

.diff-line .diff-gutter {
  width: auto;
  text-align: right;
  padding: 1px 8px;
  color: var(--text-3);
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  user-select: none;
}

.diff-text {
  display: block;
  padding: 1px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-line--add {
  background: var(--success-soft);
}

.diff-line--add .diff-text {
  color: var(--success);
}

.diff-line--del {
  background: var(--danger-soft);
}

.diff-line--del .diff-text {
  color: var(--danger);
}

.diff-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 42px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-3);
  font-size: 13.5px;
  text-align: center;
}

.diff-empty .icon {
  width: 30px;
  height: 30px;
}

.diff-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ------------------------------------------------------------------
   11. 登录 / 错误页
   ------------------------------------------------------------------ */
.auth-page {
  display: flex;
  justify-content: center;
  padding: 40px 0 60px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  padding: 28px 28px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.auth-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 18px;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: var(--accent);
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #0b3b36));
  color: #fff;
}

.auth-logo .icon {
  width: 26px;
  height: 26px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

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

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form .btn-block {
  height: 40px;
  margin-top: 2px;
}

.auth-hint {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.7;
}

.auth-current {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.auth-current-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 72px 16px 96px;
  text-align: center;
}

.error-code {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: clamp(64px, 14vw, 120px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  opacity: 0.85;
}

.error-title {
  font-size: 24px;
  font-weight: 700;
}

.error-message {
  max-width: 560px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

/* ------------------------------------------------------------------
   12. 编辑器
   ------------------------------------------------------------------ */
.editor-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.editor-mode-tabs {
  display: none;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.editor-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.editor-pane-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.editor-pane-title .icon {
  width: 14px;
  height: 14px;
  color: var(--text-3);
}

.preview-state {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 400;
}

.preview-state.is-busy {
  color: var(--accent);
}

.preview-state.is-error {
  color: var(--danger);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 5px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 1px;
}

.toolbar-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border-strong);
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 29px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
}

.toolbar-btn:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.toolbar-btn:active {
  background: var(--accent-soft);
  color: var(--accent);
}

.toolbar-btn .icon {
  width: 16px;
  height: 16px;
}

.editor-textarea {
  width: 100%;
  min-height: 58vh;
  max-height: 78vh;
  padding: 14px 16px;
  border: 0;
  outline: none;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.72;
  tab-size: 2;
  overflow: auto;
}

.editor-textarea:focus {
  box-shadow: inset 0 0 0 2px var(--accent-soft);
}

.editor-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
}

.editor-dirty {
  color: var(--warning);
  font-weight: 700;
}

.editor-dirty::before {
  content: "●";
  margin-right: 4px;
}

.editor-preview {
  min-height: 58vh;
  max-height: 78vh;
  padding: 16px 20px;
  overflow: auto;
  overflow-wrap: anywhere;
}

.editor-preview .wiki-content {
  font-size: 15px;
}

.editor-preview .preview-placeholder {
  color: var(--text-3);
  font-size: 13.5px;
  padding: 28px 12px;
  text-align: center;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.editor-summary {
  flex: 1 1 320px;
  max-width: 460px;
}

.editor-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.editor-hint {
  color: var(--text-3);
  font-size: 12px;
}

/* 编辑器页没有侧栏，限制最宽宽度，避免超宽屏上过散 */
.page--edit .article {
  max-width: 1600px;
}

.conflict-banner {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  background: var(--warning-soft);
}

.conflict-icon {
  color: var(--warning);
  margin-top: 2px;
}

.conflict-icon .icon {
  width: 20px;
  height: 20px;
}

.conflict-body strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.conflict-body p {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.7;
}

.conflict-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* ------------------------------------------------------------------
   13. 管理后台
   ------------------------------------------------------------------ */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
}

.admin-tab:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.admin-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.admin-tab .icon {
  width: 16px;
  height: 16px;
}

.admin-panel {
  margin-bottom: 26px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.admin-panel-head {
  margin-bottom: 14px;
}

.admin-panel-title {
  font-size: 16px;
  font-weight: 700;
}

.admin-panel-desc {
  display: block;
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12.5px;
}

.admin-table {
  margin-bottom: 16px;
}

.admin-table td,
.admin-table th {
  font-size: 13px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}

.row-actions .inline-form {
  display: inline-flex;
  gap: 4px;
}

.admin-form {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.admin-form-title {
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 700;
}

.admin-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.admin-note {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.7;
}

.admin-note .icon {
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  color: var(--text-3);
}

.admin-status {
  margin-bottom: 16px;
}

.admin-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}

.admin-action-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin: 0;
}

.admin-action-card:hover {
  border-color: var(--accent);
}

.admin-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}

.admin-action-icon .icon {
  width: 18px;
  height: 18px;
}

.admin-action-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.55;
}

.admin-action-body strong {
  font-size: 13.5px;
  color: var(--text);
}

/* ------------------------------------------------------------------
   14. 媒体库
   ------------------------------------------------------------------ */
.upload-zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.upload-zone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.upload-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.upload-input:focus-visible + .upload-label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
}

.upload-icon .icon {
  width: 22px;
  height: 22px;
}

.upload-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.upload-text strong {
  font-size: 14px;
}

.upload-text span {
  color: var(--text-3);
  font-size: 12px;
}

.upload-fake-btn {
  margin-left: auto;
  flex: none;
}

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.upload-filename {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
  list-style: none;
}

.media-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.media-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.media-card-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  border-radius: 7px;
  overflow: hidden;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface-3) 0 50%) 0 0 / 16px 16px;
}

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

.media-card-thumb--file {
  color: var(--text-3);
  background: var(--surface-2);
}

.media-card-thumb--file .icon {
  width: 34px;
  height: 34px;
}

.media-card-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.media-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-card-meta {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.media-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.media-card-actions .btn {
  height: 25px;
  padding: 0 6px;
  font-size: 11.5px;
}

/* ------------------------------------------------------------------
   15. 分页 / 页脚 / 返回顶部 / 灯箱 / Toast
   ------------------------------------------------------------------ */
.pagination {
  margin: 22px 0;
}

.page-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.page-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
}

.page-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.page-item.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.page-item.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

.page-ellipsis {
  padding: 0 4px;
  color: var(--text-3);
}

.heading-anchor-offset {
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.site-footer {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 22px 36px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.footer-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  min-width: 0;
}

.footer-brand-text strong {
  font-size: 13.5px;
}

.footer-brand-text span {
  color: var(--text-3);
  font-size: 11.5px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 12.5px;
}

.footer-links a {
  color: var(--text-2);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-note {
  flex-basis: 100%;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--text-3);
  font-size: 11.5px;
}

.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: var(--shadow-md);
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.back-to-top:hover {
  transform: translateY(-2px);
  color: var(--accent);
  border-color: var(--accent);
}

.back-to-top[hidden] {
  display: none;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  background: rgba(8, 12, 16, 0.92);
  backdrop-filter: blur(2px);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: min(1600px, 100%);
  max-height: 100%;
  margin: 0;
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 6px;
  background: #0b0e12;
  box-shadow: var(--shadow-lg);
}

.lightbox-caption {
  color: #cfd8e3;
  font-size: 13px;
  text-align: center;
  overflow-wrap: anywhere;
}

.lightbox-counter {
  color: #8b98a6;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.lightbox-counter:empty {
  display: none;
}

.lightbox-close,
.lightbox-nav {
  flex: none;
  color: #e6edf3;
  background: rgba(255, 255, 255, 0.08);
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.lightbox-nav[disabled] {
  opacity: 0.3;
  pointer-events: none;
}

.lightbox-prev {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-next {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

body.lightbox-open {
  overflow: hidden;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 130;
  transform: translate(-50%, 10px);
  padding: 9px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

/* 代码块复制按钮（app.js 注入） */
.code-wrap {
  position: relative;
}

.code-wrap .code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 11.5px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.code-wrap:hover .code-copy,
.code-wrap .code-copy:focus-visible {
  opacity: 1;
}

.code-wrap .code-copy:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.code-wrap .code-copy .icon {
  width: 13px;
  height: 13px;
}

/* ------------------------------------------------------------------
   16. 响应式
   ------------------------------------------------------------------ */
@media (max-width: 1280px) {
  .header-link span {
    display: none;
  }

  .header-link {
    width: 34px;
    justify-content: center;
    padding: 0;
  }
}

@media (max-width: 1100px) {
  .layout,
  .layout.has-toc,
  .layout.no-sidebar.has-toc {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .layout.no-sidebar,
  .layout.no-sidebar.has-toc {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc-col {
    display: none;
  }

  .article {
    padding: 20px 28px 48px;
  }
}

@media (max-width: 820px) {
  .layout,
  .layout.has-toc,
  .layout.no-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    z-index: 75;
    width: min(320px, 86vw);
    height: calc(100vh - var(--header-h));
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
    border-right: 1px solid var(--border-strong);
    background: var(--surface);
  }

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

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-close {
    display: inline-flex;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .header-inner {
    gap: 6px;
    padding: 0 10px;
  }

  .brand-text {
    display: none;
  }

  .header-link--optional {
    display: none;
  }

  .header-link {
    width: 34px;
    padding: 0;
    justify-content: center;
  }

  .site-search {
    max-width: none;
  }

  .search-suggest {
    position: fixed;
    top: calc(var(--header-h) + 6px);
    left: 8px;
    right: 8px;
    min-width: 0;
    max-height: min(64vh, 480px);
  }

  .search-kbd {
    display: none;
  }

  .search-input {
    padding-right: 40px;
  }

  .search-submit {
    display: none;
  }

  .user-name {
    display: none;
  }

  .user-chip {
    padding: 0 4px;
  }

  .user-chip-chevron {
    display: none;
  }

  .article {
    padding: 16px 16px 44px;
  }

  .page-title {
    font-size: 1.6rem;
  }

  .wiki-content {
    font-size: 15.5px;
    line-height: 1.8;
  }

  .meta-list {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    padding: 12px;
  }

  .compare-form .select {
    width: 100%;
    min-width: 0;
  }

  .compare-form .field--inline {
    flex: 1 1 100%;
  }

  .footer-inner {
    padding: 18px 16px;
  }

  .auth-card {
    padding: 22px 18px 20px;
  }

  .auth-page {
    padding: 16px 0 40px;
  }

  .editor-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .editor-mode-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    align-self: flex-start;
  }

  .editor-mode-tab {
    height: 30px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
  }

  .editor-mode-tab.is-active {
    background: var(--surface);
    border-color: var(--border);
    color: var(--accent);
    font-weight: 600;
  }

  .editor-shell[data-mode="edit"] .editor-pane--preview {
    display: none;
  }

  .editor-shell[data-mode="preview"] .editor-pane--edit {
    display: none;
  }

  .editor-textarea,
  .editor-preview {
    min-height: 56vh;
    max-height: 62vh;
  }

  .editor-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-summary {
    max-width: none;
  }

  .editor-buttons {
    justify-content: flex-end;
  }

  .diff-versions {
    flex-direction: column;
    align-items: stretch;
  }

  .diff-arrow {
    display: none;
  }

  .search-page-field {
    flex-wrap: wrap;
  }

  .search-page-field .input {
    flex: 1 1 160px;
  }

  .search-page-field .btn {
    width: 100%;
  }

  .upload-zone {
    padding: 10px;
  }

  .upload-label {
    flex-wrap: wrap;
  }

  .upload-fake-btn {
    display: none;
  }

  .admin-actions-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-panel {
    padding: 13px;
  }

  .lightbox {
    padding: 12px;
  }

  .lightbox-nav {
    display: none;
  }
}

@media (max-width: 560px) {
  .header-nav .header-link {
    display: none;
  }

  .search-input {
    height: 34px;
    font-size: 13.5px;
  }

  .page-title {
    font-size: 1.45rem;
  }

  .page-subtitle {
    font-size: 12.5px;
  }

  .wiki-content h1 {
    font-size: 1.55rem;
  }

  .wiki-content h2 {
    font-size: 1.25rem;
  }

  .wiki-content h3 {
    font-size: 1.1rem;
  }

  .wiki-content pre {
    padding: 12px;
    font-size: 12px;
  }

  .search-result {
    padding: 11px 12px;
  }

  .editor-status {
    gap: 4px;
    font-size: 10px;
  }

  .editor-buttons {
    flex-wrap: wrap;
  }

  .editor-buttons .btn {
    flex: 1 1 auto;
  }

  .recent-mini-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .change-summary {
    padding-left: 0;
  }

  .change-time {
    width: auto;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .toast {
    max-width: calc(100vw - 32px);
  }
}

/* 很窄的屏幕：登录按钮只显示图标 */
@media (max-width: 400px) {
  .header-login span {
    display: none;
  }

  .header-login {
    width: 34px;
    height: 34px;
    padding: 0;
  }

  .article {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* 减少动态效果偏好 */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ------------------------------------------------------------------
   17. 打印
   ------------------------------------------------------------------ */
@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #fff;
    --text: #000;
    --text-2: #222;
    --text-3: #444;
    --border: #999;
    --border-strong: #666;
    --zebra: #fff;
    --hover: #fff;
    --accent: #000;
    --link: #000;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.6;
  }

  .site-header,
  .sidebar,
  .toc-col,
  .site-footer,
  .breadcrumbs,
  .page-toolbar,
  .page-actions,
  .notices,
  .back-to-top,
  .lightbox,
  .sidebar-backdrop,
  .table-bar,
  .toast,
  .skip-link,
  .editor-toolbar,
  .editor-mode-tabs,
  .editor-actions,
  .editor-status,
  .editor-hint,
  .upload-zone,
  .media-card-actions,
  .admin-tabs {
    display: none !important;
  }

  .layout,
  .layout.has-toc,
  .layout.has-sidebar,
  .layout.no-sidebar {
    display: block;
  }

  .main-col {
    min-height: 0;
  }

  .article,
  .article--wide {
    max-width: none;
    padding: 0;
  }

  .wiki-content {
    font-size: 11pt;
    line-height: 1.6;
  }

  .wiki-content a {
    color: #000;
    text-decoration: underline;
  }

  .wiki-content a.urlextern::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    opacity: 1;
    background: none;
    display: inline;
    width: auto;
    height: auto;
    -webkit-mask: none;
    mask: none;
  }

  .table-wrap {
    overflow: visible !important;
    border-color: #666;
  }

  .table-wrap table {
    width: 100%;
  }

  .wiki-content table th,
  .wiki-content table td {
    position: static !important;
    white-space: normal !important;
    background: #fff !important;
    border-color: #999;
    font-size: 9pt;
    padding: 4px 6px;
  }

  .wiki-content h1,
  .wiki-content h2,
  .wiki-content h3 {
    break-after: avoid;
    page-break-after: avoid;
  }

  .wiki-content tr,
  .wiki-content img,
  .wiki-content .wrap {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .wiki-content img.media {
    max-width: 100%;
    border: 0;
  }

  .wiki-content .wrap {
    border: 1px solid #666;
    background: #fff;
  }

  .diff-wrap {
    overflow: visible;
  }
}
