/*
Theme Name: Jijian
Theme URI: https://jjbsy.com/jijian
Author: 九哥
Description: 极简文字流 WordPress 博客主题。支持正文图片与原生评论。
Version: 1.0.4
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: jijian
Author URI: https://jjbsy.com
Tags: 极简, 自适应, 单栏, 博客, 自定义站点宽度, 白昼切换
*/

:root {
  --text: #222;
  --muted: #888;
  --link: #2a6db0;
  --bg: #fff;
  --line: #eee;
  --content-width: 800px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;

  /* Sticky footer 布局 */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* 内容区自动撑开，把页脚推到最下方 */
body > main {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
}

/* 页脚和头部保持自身高度，不被压缩 */
body > .site-header,
body > .site-footer {
  flex-shrink: 0;
}

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

.wrap {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ==================================================
   头部：站点标题 + 描述同行
   ================================================== */
.site-header { padding: 30px 0 20px; }

.site-branding {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 12px;
  margin-bottom: 20px;
}

.site-title {
  margin: 0;
  font-size: 35px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.site-title a,
.site-title a:focus {
  color: var(--text);
  text-decoration: none;
}

.site-title a:hover {
  color: var(--link);
  text-decoration: none;
}

.site-desc {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

/* ==================================================
   汉堡按钮（桌面端隐藏）
   ================================================== */
.menu-toggle {
  display: none;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: color .15s, border-color .15s;
}

.menu-toggle:hover {
  color: var(--link);
  border-color: var(--link);
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.menu-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 18px;
  height: 14px;
}

.menu-icon span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform .2s ease, opacity .2s ease;
}

/* 展开时三条线变叉号 */
.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(2) {
  opacity: 0;
}
.menu-toggle[aria-expanded="true"] .menu-icon span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ==================================================
   头部：导航 + 搜索 + 主题切换
   ================================================== */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

/* 搜索框 + 主题切换按钮的容器 */
.header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-search {
  flex: none;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  transition: border-color .15s;
}

.header-search:focus-within { border-bottom-color: var(--link); }

.header-search input[type="search"] {
  border: none;
  background: none;
  padding: 6px 0;
  font: inherit;
  font-size: 15px;
  width: 140px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.header-search input[type="search"]::placeholder { color: var(--muted); }
.header-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.header-search button {
  border: none;
  background: none;
  padding: 6px 0 6px 10px;
  font: inherit;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s;
}

.header-search button:hover { color: var(--link); }

/* 主题切换按钮 */
.theme-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: none;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.theme-toggle:hover {
  color: var(--link);
  border-color: var(--link);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* 白天只显示太阳，夜晚只显示月亮 */
.theme-toggle .icon-sun { display: inline-block; }
.theme-toggle .icon-moon { display: none; }

[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }

/* ==================================================
   搜索结果页
   ================================================== */
.search-result-info {
  margin: 32px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.search-result-info strong { color: var(--text); font-weight: 600; }

/* 搜索页分页 */
.pagination {
  margin: 40px 0;
  font-size: 15px;
  text-align: center;
}

.pagination a,
.pagination span {
  margin: 0 6px;
}

.pagination .current {
  color: var(--text);
  font-weight: 600;
}

/* 评论分页（独立于搜索页分页） */
.comment-pagination {
  margin: 28px 0;
  font-size: 14px;
  text-align: center;
}

.comment-pagination .page-numbers {
  margin: 0 6px;
}

.comment-pagination .page-numbers.current {
  color: var(--text);
  font-weight: 600;
}

/* 窄屏：搜索框独占一行，禁止溢出 */
@media (max-width: 560px) {
  .header-bar {
    flex-wrap: wrap;
    gap: 14px;
  }

  /* 容器占满整行，允许收缩 */
  .header-actions {
    flex: 1 1 100%;
    gap: 12px;
    min-width: 0;
  }

  /* 搜索框占满剩余空间，不再被内容撑开 */
  .header-actions .header-search {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }

  /* 输入框：宽度归零，完全由 flex 决定，防固有宽度撑破 */
  .header-search input[type="search"] {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: 100%;
  }

  /* 搜索按钮保持不收缩 */
  .header-search button {
    flex: none;
  }
}

/* ==================================================
   主菜单（含悬停下拉）
   ================================================== */
.main-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 16px;
}

.main-nav a { color: var(--text); }

.main-nav a:hover,
.main-nav a:focus {
  text-decoration: none;
  color: var(--link);
}

.main-nav .current-menu-item > a { color: var(--link); }

/* 每个菜单项作为下拉定位基准 */
.main-nav li {
  position: relative;
}

/* 下拉菜单：横版，子项横向排列 */
.main-nav ul ul {
  position: absolute;
  top: 100%;
  left: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 100;
  white-space: nowrap;
}

/* 菜单项与下拉之间 6px 透明桥接 */
.main-nav ul ul::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
}

/* 子项：横向排列 */
.main-nav ul ul li {
  padding: 0;
  flex: none;
}

/* 横版子项之间加细分隔线 */
.main-nav ul ul li + li {
  border-left: 1px solid var(--line);
}

.main-nav ul ul a {
  display: block;
  padding: 8px 16px;
  font-size: 15px;
  white-space: nowrap;
  color: var(--text);
  line-height: 1.5;
}

.main-nav ul ul a:hover {
  background: #f7f7f7;
  text-decoration: none;
  color: var(--link);
}

/* 三级菜单：也从父项下方展开 */
.main-nav ul ul ul {
  top: 100%;
  left: 0;
  right: auto;
}

/* 悬停 / 键盘聚焦：显示下拉 */
.main-nav li:hover > ul,
.main-nav li:focus-within > ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 窄屏：下拉菜单改为竖版 */
@media (max-width: 768px) {
  .main-nav ul ul {
    display: block;
    min-width: 160px;
    max-width: calc(100vw - 40px);
    flex-wrap: nowrap;
    white-space: normal;
  }

  .main-nav ul ul li {
    display: block;
    flex: none;
  }

  .main-nav ul ul a {
    display: block;
    padding: 10px 18px;
    white-space: nowrap;
  }

  .main-nav ul ul li + li {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .main-nav ul ul ul {
    top: 100%;
    left: 0;
    right: auto;
  }
}

/* ==================================================
   文章列表 + 加载更多
   ================================================== */
.post-list { margin: 36px 0 0; }

.post-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}

.post-item .post-title { color: var(--text); font-size: 18px; }
.post-item .post-title:hover { color: var(--link); text-decoration: none; }

.post-item time {
  flex: none;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ==================================================
   首页“查看所有文章”
   ================================================== */
.load-more-wrap { text-align: center; margin: 36px 0 60px; }

.view-all-btn {
  display: inline-block;
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 22px;
  border-radius: 20px;
  font-size: 14px;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}

.view-all-btn:hover {
  border-color: var(--link);
  color: var(--link);
  text-decoration: none;
}

/* ==================================================
   文章页
   ================================================== */
.single-header { margin: 36px 0 8px; }
.single-title { margin: 0 0 10px; font-size: 26px; line-height: 1.5; font-weight: 600; text-align: center; }
.single-meta { color: var(--muted); font-size: 14px; margin-bottom: 20px; text-align: center; }

.entry-content { font-size: 18px; line-height: 1.9; }
.entry-content p { margin: 0 0 1.4em; }
.entry-content h2 { font-size: 21px; margin: 2em 0 .8em; }
.entry-content h3 { font-size: 19px; margin: 1.8em 0 .7em; }
.entry-content blockquote {
  margin: 1.6em 0;
  padding: 0 0 0 18px;
  border-left: 3px solid var(--line);
  color: #555;
}
.entry-content ul, .entry-content ol { padding-left: 1.4em; margin: 0 0 1.4em; }
.entry-content code {
  background: #f5f5f5;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: .9em;
}
.entry-content pre {
  background: #f6f6f6;
  padding: 16px;
  border-radius: 4px;
  overflow: auto;
  font-size: 15px;
  line-height: 1.6;
}
.entry-content pre code { background: none; padding: 0; }

/* 正文图片 */
.entry-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.6em auto;
  border-radius: 3px;
}
.entry-content .wp-caption,
.entry-content figure { max-width: 100%; margin: 1.6em auto; }
.entry-content .wp-caption-text,
.entry-content figcaption {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  margin-top: 8px;
}
.entry-content .alignleft { float: left; margin: 0 1.2em .8em 0; }
.entry-content .alignright { float: right; margin: 0 0 .8em 1.2em; }
.entry-content .aligncenter { margin-left: auto; margin-right: auto; }

/* ==================================================
   上一篇 / 下一篇
   ================================================== */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 48px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
}

.post-nav-next { text-align: right; }
.post-nav-label { font-size: 13px; color: var(--muted); }

.post-nav-title {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  transition: color .15s;
}

a.post-nav-item:hover .post-nav-title { color: var(--link); }
.post-nav-empty { visibility: hidden; }

/* ==================================================
   评论区域：整条评论串一个框，内部虚线分隔
   ================================================== */
.comments-area {
  margin: 30px 0 30px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.comment-reply-title {
  font-size: 17px;
  font-weight: 600;
  margin: 16px 0 16px;
  letter-spacing: .3px;
  line-height: 1.6;
}

.comment-reply-title:empty { display: none; }

.comment-reply-title small a {
  font-weight: 400;
  font-size: 14px;
  color: var(--muted);
  margin-left: 10px;
}

.comment-reply-title small a:hover { color: var(--link); }

/* 列表基础：去掉默认标记与缩进 */
.comment-list,
.comment-list .children,
.comment-list ol,
.comment-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 顶层评论 li：整条评论串作为一个卡片 */
.comment-list > li {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  transition: border-color .12s;
}

.comment-list > li:hover {
  border-color: var(--muted);
}

/* 卡片内所有 children 容器：透明、无边框、无缩进 */
.comment-list .children,
.comment-list .children .children {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.comment-list .children > li {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

/* 卡片内每条评论：无边框，仅用顶部虚线分隔 */
.comment-list .comment-body {
  margin: 0;
  padding: 10px 0;
  border: 0;
  border-top: 1px dashed #ddd;
  border-radius: 0;
  background: transparent;
}

/* 卡片的第一条（顶层评论）：不要顶部分隔线 */
.comment-list > li > .comment-body {
  border-top: 0;
  padding-top: 0;
}

/* 元信息行 */
.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 12px;
  margin-bottom: 4px;
  font-size: .9em;
  line-height: 1.5;
  color: #333;
}

/* 作者 */
.comment-author {
  color: var(--text);
  font-size: inherit;
  font-weight: 500;
}

.comment-author a.comment-author-link,
.comment-author a.comment-author-link:visited,
.comment-author a.comment-author-link:focus,
.comment-author a.comment-author-link:active {
  color: inherit;
  text-decoration: none;
  transition: color .15s;
}

.comment-author a.comment-author-link:hover {
  color: var(--link);
}

/* 日期 */
.comment-date {
  color: var(--muted);
  font-size: .8em;
  font-variant-numeric: tabular-nums;
}

/* 回复按钮 */
.comment-reply {
  font-size: .9em;
  margin-left: auto;
}

.comment-reply a {
  display: inline-block;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 8px;
  font-size: .85em;
  transition: color .12s, border-color .12s;
}

.comment-reply a:hover {
  color: var(--link);
  border-color: var(--link);
  text-decoration: none;
}

/* 桌面端：悬停每条评论才显示其回复按钮 */
@media (hover: hover) and (pointer: fine) {
  .comment-body:not(:hover) > .comment-meta > .comment-reply {
    visibility: hidden;
  }
}

/* 评论正文 */
.comment-content {
  font-size: 16px;
  line-height: 1.85;
  color: #333;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.comment-content p { margin: 0 0 .7em; }
.comment-content p:last-child { margin-bottom: 0; }

.reply-to {
  margin-right: 2px;
}

/* ==================================================
   评论表单：白色描边卡片
   ================================================== */
.comment-respond {
  margin: 0 0 24px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
}

.comment-respond .comment-reply-title {
  margin: 4px 0 12px;
}

.comment-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}

.comment-form > p {
  margin: 0;
  grid-column: 1 / -1;
}

.comment-form > p.comment-form-author,
.comment-form > p.comment-form-email,
.comment-form > p.comment-form-url {
  grid-column: auto;
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 2px;
  font: inherit;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  line-height: 1.5;
}

.comment-form input::placeholder,
.comment-form textarea::placeholder {
  color: #aaa;
}

.comment-form input:not(:focus),
.comment-form textarea:not(:focus) {
  outline: 1px solid var(--line);
  outline-offset: -1px;
}

.comment-form input:focus,
.comment-form textarea:focus {
  outline: 2px solid var(--link);
  outline-offset: -1px;
  border-color: var(--link);
}

.comment-form textarea {
  min-height: 110px;
  resize: vertical;
}

.comment-form .submit {
  background: #444;
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 3px;
  font-size: 15px;
  cursor: pointer;
  transition: background .15s;
}

.comment-form .submit:hover {
  background: var(--link);
}

/* Cookies 同意复选框 */
.comment-form-cookies-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.comment-form-cookies-consent input[type="checkbox"] {
  flex: none;
  margin: 3px 0 0;
  width: 14px;
  height: 14px;
  accent-color: var(--link);
  cursor: pointer;
}

.comment-form-cookies-consent label {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  cursor: pointer;
}

/* 评论关闭提示 */
.comments-closed {
  margin: 30px 0 30px;
  padding-top: 28px;
  text-align: center;
  border-top: 1px solid var(--line);
  font-size: 20px;
  color: var(--muted);
  line-height: 1.8;
}

/* ==================================================
   页脚
   ================================================== */
.site-footer {
  padding: 20px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.site-footer a,
.site-footer a:focus {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--link);
  text-decoration: none;
}

/* ==================================================
   友链页
   ================================================== */
.friend-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.friend-item {
  display: block;
  min-width: 0;
  padding: 4px 0;
  line-height: 1.8;
}

.friend-item a {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 16px;
  text-decoration: none;
}

.friend-item a:hover {
  color: var(--link);
  text-decoration: none;
}

/* ==================================================
   互动榜
   ================================================== */
.interact-ranking {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 6px 28px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.interact-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 16px;
  line-height: 1.6;
}

.interact-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interact-name a,
.interact-name a:visited {
  color: var(--text);
  text-decoration: none;
  transition: color .15s, border-bottom-color .15s;
}

.interact-name a:hover {
  color: var(--link);
  text-decoration: none;
}

.interact-count {
  flex: none;
  font-size: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.interact-empty { color: var(--muted); margin: 40px 0; }

/* ==================================================
   响应式补强
   ================================================== */

/* 长单词、长 URL 断行，防止横向溢出 */
.entry-content,
.comment-content {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* 宽表格：横向滚动 */
.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 16px;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.entry-content table th,
.entry-content table td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.entry-content table th {
  background: #fafafa;
  font-weight: 600;
}

/* iframe / video / embed 不溢出 */
.entry-content iframe,
.entry-content video,
.entry-content embed,
.entry-content object {
  max-width: 100%;
  display: block;
  margin: 1.6em auto;
}

/* 平板：评论三列改成两列 */
@media (max-width: 768px) and (min-width: 561px) {
  .comment-form {
    grid-template-columns: repeat(2, 1fr);
  }
  .comment-form > p.comment-form-url {
    grid-column: 1 / -1;
  }
}

/* 触屏设备：禁用 hover 下拉，改由 JS 控制 */
@media (hover: none) {
  .main-nav li:hover > ul {
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
  }
  .main-nav li.is-open > ul {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
}

/* 手机 */
@media (max-width: 560px) {
  .comment-form { grid-template-columns: 1fr; }
  .comment-form > p.comment-form-author,
  .comment-form > p.comment-form-email,
  .comment-form > p.comment-form-url {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  body { font-size: 17px; }
  .site-title { font-size: 26px; }
  .single-title { font-size: 22px; }
  .post-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .post-item time {
    align-self: stretch;
    text-align: right;
    width: auto;
    flex: none;
  }

  .post-nav { grid-template-columns: 1fr; gap: 18px; }
  .post-nav-next { text-align: left; }

  .friend-items { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px 16px; }
  .interact-ranking { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 4px 18px; }

  .site-branding {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ==================================================
   返回顶部
   ================================================== */
.back-to-top {
  position: fixed;
  bottom: 150px;
  right: max(16px, calc((100vw - var(--content-width)) / 2 - 52px));
  z-index: 200;

  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;

  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, visibility .2s ease, transform .2s ease,
              color .15s ease, border-color .15s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  color: var(--link);
  border-color: var(--link);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .back-to-top {
    right: 16px;
    bottom: 50px;
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top {
    transition: none;
  }
}

/* ==================================================
   手机：汉堡折叠导航（覆盖版，放在文件末尾）
   ================================================== */
@media (max-width: 560px) {
  .header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .site-branding {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
  }

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

  .header-bar {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
  }

  .header-bar.is-open {
    display: flex;
  }

  .main-nav { width: 100%; }

  .main-nav ul {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    width: 100%;
  }

  .main-nav > ul > li {
    border-bottom: 1px dashed var(--line);
  }

  .main-nav > ul > li:last-child {
    border-bottom: 0;
  }

  .main-nav > ul > li > a {
    display: block;
    padding: 10px 0;
  }

  /* 子菜单：内嵌展开 */
  .main-nav ul ul {
    position: static;
    display: none;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0 0 8px 16px;
    min-width: 0;
    max-width: none;
    white-space: normal;
    flex-direction: column;
    flex-wrap: wrap;
    z-index: auto;
  }

  .main-nav ul ul li {
    display: block;
    flex: none;
  }

  .main-nav ul ul a {
    padding: 6px 0 6px 12px;
    font-size: 14px;
    color: var(--muted);
    border: 0;
    border-left: 2px solid var(--line);
    background: none;
  }

  .main-nav ul ul li + li {
    border: 0;
  }

  .main-nav li:hover > ul {
    display: none;
  }
  .main-nav li.is-open > ul {
    display: flex;
  }

  .header-actions {
    flex: 1 1 100%;
    gap: 12px;
    min-width: 0;
  }

  .header-actions .header-search {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
  }

  .header-search input[type="search"] {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    max-width: 100%;
  }

  .header-search button {
    flex: none;
  }
}

/* ==================================================
   归档页
   ================================================== */
.archive-list {
  margin-top: 36px;
}

.archive-year {
  border-bottom: 1px dashed var(--line);
}

.archive-year:last-child {
  border-bottom: 0;
}

/* 年份行：下三角 + 年份 + 篇数（靠右） */
.archive-year-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  transition: color .15s;
}

.archive-year-summary::-webkit-details-marker { display: none; }
.archive-year-summary::marker { content: ""; }

.archive-year-summary:hover {
  color: var(--link);
}

/* 下三角 */
.archive-year-summary::before {
  content: "";
  flex: none;
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform .2s ease, border-top-color .15s ease;
}

.archive-year[open] > .archive-year-summary::before {
  transform: rotate(180deg);
  border-top-color: var(--link);
}

.archive-year[open] > .archive-year-summary {
  color: var(--link);
}

.archive-count {
  margin-left: auto;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 年份下的文章列表 */
.archive-posts {
  list-style: none;
  margin: 0;
  padding: 0 0 14px;
}

.archive-posts li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}

.archive-posts li:last-child {
  border-bottom: 0;
}

.archive-posts time {
  flex: none;
  width: 48px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.archive-posts a {
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.archive-posts a:hover {
  color: var(--link);
  text-decoration: none;
}

.archive-empty {
  color: var(--muted);
  margin: 40px 0;
}

/* 归档页：站点统计 */
.archive-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 32px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.archive-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.archive-stat-num {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.archive-stat-label {
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 560px) {
  .archive-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 12px;
  }
  .archive-stat-num {
    font-size: 20px;
  }
}

@media (max-width: 520px) {
  .archive-posts li { gap: 12px; }
  .archive-posts time { width: 42px; font-size: 13px; }
}

/* ==================================================
   404 页面
   ================================================== */
.error-404 {
  padding: 80px 0 40px;
  text-align: center;
}

.error-code {
  margin: 0;
  font-size: 96px;
  font-weight: 600;
  line-height: 1;
  color: var(--line);
  letter-spacing: 4px;
  font-variant-numeric: tabular-nums;
}

.error-title {
  margin: 16px 0 12px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.error-desc {
  margin: 0 auto;
  max-width: 420px;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.8;
}

.error-search {
  margin: 32px auto 0;
  max-width: 360px;
}

.error-search .header-search {
  width: 100%;
}

.error-search .header-search input[type="search"] {
  flex: 1;
  width: auto;
}

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

.error-btn {
  display: inline-block;
  padding: 8px 22px;
  border-radius: 20px;
  font-size: 14px;
  border: 1px solid var(--text);
  background: var(--text);
  color: #fff;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}

.error-btn:hover {
  background: var(--link);
  border-color: var(--link);
  color: #fff;
  text-decoration: none;
}

.error-btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.error-btn-ghost:hover {
  background: transparent;
  color: var(--link);
  border-color: var(--link);
}

.error-recent {
  margin: 56px auto 0;
  max-width: 480px;
  text-align: left;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.error-recent-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .3px;
}

.error-recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.error-recent-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}

.error-recent-list li:last-child {
  border-bottom: 0;
}

.error-recent-list a {
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.error-recent-list a:hover {
  color: var(--link);
  text-decoration: none;
}

.error-recent-list time {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 520px) {
  .error-404 { padding: 56px 0 32px; }
  .error-code { font-size: 72px; }
  .error-title { font-size: 20px; }
  .error-search { max-width: 100%; }
}

/* ==================================================
   暗色主题
   ================================================== */
[data-theme="dark"] {
  --text: #e8e8e8;
  --muted: #888;
  --link: #6aa9e0;
  --bg: #1a1a1a;
  --line: #333;
}

/* 正文内硬编码色值的元素 */
[data-theme="dark"] .entry-content code,
[data-theme="dark"] .entry-content pre,
[data-theme="dark"] .entry-content table th {
  background: #2a2a2a;
}

[data-theme="dark"] .entry-content blockquote {
  color: #aaa;
}

/* 下拉菜单 */
[data-theme="dark"] .main-nav ul ul {
  background: #1f1f1f;
  border-color: var(--line);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .main-nav ul ul a:hover {
  background: #2a2a2a;
}

/* 评论卡片 */
[data-theme="dark"] .comment-list > li {
  background: #1f1f1f;
}

[data-theme="dark"] .comment-list .comment-body {
  background: transparent;
  border-top-color: #333;
}

[data-theme="dark"] .comment-content {
  color: var(--text);
}

/* 评论表单 */
[data-theme="dark"] .comment-respond {
  background: #1f1f1f;
  border-color: var(--line);
}

[data-theme="dark"] .comment-form input[type="text"],
[data-theme="dark"] .comment-form input[type="email"],
[data-theme="dark"] .comment-form input[type="url"],
[data-theme="dark"] .comment-form textarea {
  background: #141414;
  color: var(--text);
  border-color: var(--line);
}

[data-theme="dark"] .comment-form input::placeholder,
[data-theme="dark"] .comment-form textarea::placeholder {
  color: #666;
}

[data-theme="dark"] .comment-form input:not(:focus),
[data-theme="dark"] .comment-form textarea:not(:focus) {
  outline-color: #3a3a3a;
}

[data-theme="dark"] .comment-form .submit {
  background: #e8e8e8;
  color: #1a1a1a;
}

[data-theme="dark"] .comment-form .submit:hover {
  background: var(--link);
  color: #fff;
}

/* 404 按钮 */
[data-theme="dark"] .error-btn {
  background: #e8e8e8;
  color: #1a1a1a;
  border-color: #e8e8e8;
}

[data-theme="dark"] .error-btn:hover {
  background: var(--link);
  color: #fff;
  border-color: var(--link);
}

[data-theme="dark"] .error-btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

[data-theme="dark"] .error-btn-ghost:hover {
  color: var(--link);
  border-color: var(--link);
}

/* ==================================================
   浏览量
   ================================================== */
.entry-views {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.single-header .single-meta .entry-views {
  display: inline-block;
}

/* ==================================================
   友链页：分类标题
   ================================================== */
.friend-category {
  margin: 0 0 24px;
}

.friend-category-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  line-height: 1.6;
  letter-spacing: .3px;
}

.friend-category-title .cat-hint {
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
  margin-left: 4px;
}

/* ==================================================
   正文段落：首行缩进 2 个汉字
   ================================================== */
.entry-content p {
  text-indent: 2em;
}

/* 以下情况不需要缩进 */
.entry-content blockquote p,
.entry-content li p,
.entry-content td p,
.entry-content th p,
.entry-content figcaption,
.entry-content .wp-caption-text,
.entry-content .aligncenter,
.entry-content .has-text-align-center,
.entry-content .has-text-align-right {
  text-indent: 0;
}