/*
Theme Name: Koishi
Theme URI: https://muidar.com
Author: Muidar Chang
Author URI: https://muidar.com
Description: 极简双栏 WordPress 主题，融合 cmd.tw 侧栏骨架与 muidar.com 配色系统。衬线标题、无衬线正文、等宽标签三级字体，亮/暗双模 CSS 变量驱动，纯原生 JS。
Version: 1.0.0
License: MIT
Text Domain: koishi
*/

/* ===== CSS 变量（亮色）===== */
:root {
  color-scheme: light;
  --paper: #f6f5f0;
  --paper-2: #fffefb;
  --ink: #18171a;
  --ink-soft: #4a4852;
  --faint: #7a788a;
  --accent: #5e72e4;
  --accent-soft: rgba(94, 114, 228, .10);
  --accent-soft-2: rgba(94, 114, 228, .06);
  --bg-soft: rgba(0, 0, 0, .05);
  --line: rgba(0, 0, 0, .10);
  --line-strong: rgba(0, 0, 0, .20);
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', 'Noto Serif SC', serif;
  --sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --mono: 'JetBrains Mono', SFMono-Regular, Consolas, 'Liberation Mono', monospace;
  --ease: cubic-bezier(.22, .68, 0, 1.2);
  --side: 260px;
  --radius: 4px;
  --radius-sm: 2px;
  --content-max: 780px;
  --shell-max: 1040px;
}

/* ===== 暗色 ===== */
html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0e0e12;
  --paper-2: #16151c;
  --ink: #f0eff4;
  --ink-soft: #a9a7b6;
  --faint: #7c7a8a;
  --accent: #8b9cf7;
  --accent-soft: rgba(139, 156, 247, .12);
  --accent-soft-2: rgba(139, 156, 247, .07);
  --bg-soft: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .22);
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  transition: background .35s var(--ease), color .35s var(--ease);
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ===== 辅助 ===== */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 99;
  background: var(--accent); color: #fff;
  padding: 10px 16px; font-size: 13px;
  border-radius: var(--radius);
  transition: left .18s var(--ease), top .18s var(--ease);
}
.skip-link:focus { left: 12px; top: 12px; outline: 2px solid var(--ink); outline-offset: 2px; }

/* ===== 全局布局外壳 ===== */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; max-width: var(--shell-max); margin: 0 auto; }
.main { width: 100%; max-width: var(--content-max); min-width: 0; margin: 0 auto; padding: 64px 56px 0; }

/* ===== 侧栏 ===== */
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh; max-height: 100vh;
  min-width: 0; overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  padding: 38px 30px 26px;
  display: flex; flex-direction: column; gap: 22px;
  background: var(--paper);
}

/* 侧栏头部与折叠按钮 */
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.side-toggle {
  display: none; width: 36px; height: 36px; flex: 0 0 36px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; color: var(--ink-soft);
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.side-toggle:hover { border-color: var(--line-strong); color: var(--accent); }
.side-toggle svg { width: 18px; height: 18px; }
.side-toggle .ti-close { display: none; }
.sidebar.is-open .side-toggle .ti-open { display: none; }
.sidebar.is-open .side-toggle .ti-close { display: block; }

/* 折叠面板（桌面端始终展开） */
.side-panel { display: flex; flex-direction: column; gap: 30px; flex: 1 1 auto; min-height: 0; }
.brand { display: flex; flex-direction: column; gap: 6px; }
.brand .logo { font-family: var(--serif); font-size: 28px; line-height: 1.1; letter-spacing: -.01em; }
.brand .logo em { font-style: normal; color: var(--accent); }
.brand .custom-logo-link { display: block; }
.brand .custom-logo-link img { max-height: 40px; width: auto; }
.brand .sub { font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--faint); }

/* 导航 */
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav ul { list-style: none; display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; }
.side-nav li { margin: 0; }
.side-nav .group-title {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--faint); padding: 16px 0 10px;
}
.side-nav a {
  position: relative; display: flex; align-items: baseline; gap: 10px;
  padding: 9px 0; font-size: 14px; color: var(--ink-soft);
  border-bottom: 1px solid transparent;
  transition: color .25s var(--ease);
}
.side-nav a .idx {
  font-family: var(--mono); font-size: 10px; color: var(--faint);
  transition: color .25s var(--ease);
}
.side-nav a::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 0;
  background: var(--accent); transition: width .32s var(--ease);
}
.side-nav a:hover { color: var(--ink); }
.side-nav a:hover::after,
.side-nav a.current-menu-item::after,
.side-nav a.current::after { width: 100%; }
.side-nav a:hover .idx,
.side-nav a.current-menu-item .idx,
.side-nav a.current .idx { color: var(--accent); }
.side-nav a.current-menu-item,
.side-nav a.current { color: var(--ink); }

/* 侧栏底部 */
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 16px; }
.controls { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: transparent; cursor: pointer;
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .icon-sun { display: none; }
html[data-theme="dark"] .icon-btn .icon-sun { display: block; }
html[data-theme="dark"] .icon-btn .icon-moon { display: none; }

/* 搜索 */
.side-search { position: relative; min-width: 0; width: 100%; }
.side-search input {
  width: 100%; max-width: 100%; min-width: 0; height: 34px; -webkit-appearance: none; appearance: none; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: transparent; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em;
  color: var(--ink); transition: border-color .25s var(--ease);
}
.side-search input:focus { border-color: var(--line-strong); outline: none; }
.side-search button {
  position: absolute; right: 0; top: 0; width: 34px; height: 34px;
  border: none; background: transparent; cursor: pointer; color: var(--faint);
  display: flex; align-items: center; justify-content: center;
}

/* 侧栏小工具 */
.side-widget { font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.side-widget h3, .side-widget .widget-title {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 10px;
}
.side-widget ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.side-widget ul li a { font-size: 13px; color: var(--ink-soft); transition: color .25s var(--ease); }
.side-widget ul li a:hover { color: var(--accent); }

/* ===== Hero 区 ===== */
.hero { padding: 8px 0 56px; border-bottom: 1px solid var(--line); margin-bottom: 0; }
.hero .kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--accent);
}
.hero .kicker::before { content: ""; width: 26px; height: 1px; background: var(--accent); }
.hero h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 4rem); line-height: 1.04; letter-spacing: -.02em;
  margin: 20px 0 18px; text-wrap: balance;
}
.hero h1::after {
  content: ""; display: block; width: 56px; height: 2px; margin-top: 22px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.hero .lede { max-width: 48ch; font-size: 15.5px; line-height: 1.75; color: var(--ink-soft); text-wrap: pretty; }
.hero .lede strong { color: var(--accent); font-weight: 600; }

/* ===== 区块 ===== */
.block { padding: 48px 0; border-bottom: 1px solid var(--line); }
.block:last-of-type { border-bottom: 0; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.block-head .t { display: flex; align-items: center; gap: 12px; }
.block-head .num {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; color: var(--accent);
}
.block-head h2 { font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: -.005em; }
.block-head .hint { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }

/* ===== 文章列表 ===== */
.posts { display: flex; flex-direction: column; }
.post-row {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: baseline; gap: 18px;
  padding: 16px 2px; border-top: 1px solid var(--line);
  transition: background .25s var(--ease);
}
.post-row:last-child { border-bottom: 1px solid var(--line); }
.post-row:hover { background: var(--accent-soft); }
.post-row .no { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.post-row .ti { font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row:hover .ti { color: var(--accent); }
.post-row .dt { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; }

/* 说说列表 */
.shuoshuo-item {
  padding: 20px 2px; border-top: 1px solid var(--line);
  font-size: 14.5px; line-height: 1.8; color: var(--ink-soft);
}
.shuoshuo-item:last-child { border-bottom: 1px solid var(--line); }
.shuoshuo-item .shuoshuo-meta {
  display: flex; align-items: center; gap: 14px; margin-top: 12px;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
}
.shuoshuo-item .shuoshuo-content p { margin: 0; }
.shuoshuo-item .shuoshuo-content img { margin: 10px 0; border-radius: var(--radius); }

/* ===== 分页 ===== */
.pagination {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 36px 0 0; font-family: var(--mono); font-size: 12px;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink-soft); transition: border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .dots { border-color: transparent; }

/* ===== 单篇文章 ===== */
.article-thumb { margin-bottom: 40px; border-radius: var(--radius); overflow: hidden; }
.article-thumb img { width: 100%; height: auto; display: block; }
.article-header { padding-bottom: 36px; border-bottom: 1px solid var(--line); margin-bottom: 40px; }
.article-header .meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: .06em;
  margin-bottom: 18px;
}
.article-header .meta a { color: var(--ink-soft); transition: color .25s var(--ease); }
.article-header .meta a:hover { color: var(--accent); }
.article-header .meta .sep { color: var(--line-strong); }
.article-header h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(2rem, 4vw, 3rem); line-height: 1.12; letter-spacing: -.01em;
}

/* 文章正文 */
.article-content {
  font-size: 15.5px; line-height: 1.85; color: var(--ink-soft);
  padding-bottom: 48px; border-bottom: 1px solid var(--line);
}
.article-content h2 {
  font-family: var(--serif); font-size: 22px; font-weight: 400; color: var(--ink);
  margin: 40px 0 18px; letter-spacing: -.005em;
}
.article-content h3 {
  font-size: 17px; font-weight: 600; color: var(--ink); margin: 32px 0 14px;
}
.article-content p { margin-bottom: 20px; }
/* 首字下沉：在编辑器文章区块添加 CSS class 「drop-cap」开启 */
.article-content.drop-cap > p:first-of-type::first-letter {
  font-size: 3em; line-height: .92; float: left; margin: 6px 12px 0 0;
}
.article-content a { color: var(--accent); border-bottom: 1px solid var(--accent-soft); transition: border-color .25s var(--ease); }
.article-content a:hover { border-color: var(--accent); }
.article-content ul, .article-content ol { padding-left: 22px; margin-bottom: 18px; }
.article-content li { margin-bottom: 6px; }
.article-content blockquote {
  border-left: 3px solid var(--accent); padding: 10px 18px; margin: 24px 0;
  color: var(--ink-soft); background: var(--accent-soft-2); border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 14.5px;
}
.article-content blockquote p:last-child { margin-bottom: 0; }
.article-content code {
  font-family: var(--mono); font-size: .9em; padding: 2px 6px;
  background: var(--accent-soft-2); border-radius: var(--radius-sm); color: var(--accent);
}
.article-content pre {
  position: relative;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 24px 0; overflow-x: auto; font-size: 13.5px; line-height: 1.6;
}
.article-content pre code {
  background: none; padding: 0; color: var(--ink-soft); font-size: inherit;
}

/* 代码块复制按钮 */
.copy-btn {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  padding: 4px 10px; font-size: 12px; font-family: var(--sans);
  color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; opacity: 0;
  transition: opacity .18s ease, color .15s ease, border-color .15s ease;
}
.article-content pre:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover,
.copy-btn.is-done { color: var(--accent); border-color: var(--accent); }
@media (hover: none) {
  .copy-btn { opacity: 1; }
}

/* 阅读进度条 */
.read-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px; z-index: 999; pointer-events: none;
}
.read-progress span {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width .1s linear;
}
.article-content img {
  border-radius: var(--radius); margin: 26px auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .06);
  transition: transform .4s var(--ease), box-shadow .4s var(--ease);
}
.article-content img:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(0, 0, 0, .10); }
.article-content hr { border: none; border-top: 1px solid var(--line); margin: 36px 0; }
.article-content table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 14px; }
.article-content th, .article-content td { padding: 10px 14px; border: 1px solid var(--line); text-align: left; }
.article-content th { font-family: var(--mono); font-size: 11px; text-transform: uppercase; color: var(--faint); background: var(--accent-soft-2); }

/* 文章底部 */
.article-footer { padding: 28px 0; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.article-footer .tags { display: flex; flex-wrap: wrap; gap: 8px; }
.article-footer .tags a {
  display: inline-flex; align-items: center; height: 28px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 12px; line-height: 1; color: var(--ink-soft);
  transition: border-color .25s var(--ease), color .25s var(--ease);
}
.article-footer .tags a:hover { border-color: var(--accent); color: var(--accent); }
.article-nav { display: flex; justify-content: space-between; gap: 16px; padding: 28px 0; border-top: 1px solid var(--line); }
.article-nav a {
  font-size: 14px; color: var(--ink-soft); transition: color .25s var(--ease);
}
.article-nav a:hover { color: var(--accent); }
.article-nav .prev::before { content: "← "; }
.article-nav .next::after { content: " →"; }

/* ===== 评论 ===== */
.comments { margin-top: 40px; }
.comments-title {
  font-family: var(--serif); font-size: 22px; font-weight: 400; margin-bottom: 30px;
}
.comment-list { list-style: none; display: flex; flex-direction: column; }
.comment { padding: 22px 0; border-top: 1px solid var(--line); }
.comment:last-child { border-bottom: 1px solid var(--line); }
.comment .comment-author { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.comment .comment-author .avatar { width: 36px; height: 36px; border-radius: 50%; }
.comment .comment-author cite {
  font-style: normal; font-size: 14.5px; font-weight: 600; color: var(--ink);
}
.comment .comment-meta {
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
}
.comment .comment-meta a { color: var(--faint); transition: color .25s var(--ease); }
.comment .comment-meta a:hover { color: var(--accent); }
.comment p { font-size: 14px; color: var(--ink-soft); line-height: 1.7; margin-top: 8px; }
.comment .reply {
  font-family: var(--mono); font-size: 11px; margin-top: 8px;
}
.comment .reply a { color: var(--faint); transition: color .25s var(--ease); }
.comment .reply a:hover { color: var(--accent); }
.comment .children { margin-left: 32px; list-style: none; }

/* 评论表单 */
.comment-respond { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line); }
.comment-respond h3 {
  font-family: var(--serif); font-size: 20px; font-weight: 400; margin-bottom: 24px;
}
.comment-form { display: flex; flex-direction: column; gap: 16px; }
.comment-form p { margin: 0; }
.comment-form label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--faint); margin-bottom: 6px; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); font-size: 14px; color: var(--ink);
  transition: border-color .25s var(--ease);
}
.comment-form input:focus, .comment-form textarea:focus { border-color: var(--line-strong); outline: none; }
.comment-form textarea { min-height: 140px; resize: vertical; }
.comment-form .submit {
  display: inline-flex; align-items: center; height: 40px; padding: 0 24px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; cursor: pointer;
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.comment-form .submit:hover { background: transparent; color: var(--accent); }

/* ===== 归档时间线 ===== */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 1px; background: var(--line);
}
.timeline-year { margin: 32px 0 12px; }
.timeline-year h3 {
  font-family: var(--serif); font-size: 22px; font-weight: 400; color: var(--accent);
  position: relative; display: flex; align-items: baseline; gap: 10px;
}
.timeline-year h3 .year-count {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--faint);
}
.timeline-year h3::before {
  content: ""; position: absolute; left: -32px; top: 12px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent);
}
.timeline-item {
  display: grid; grid-template-columns: 90px 1fr; gap: 16px; align-items: baseline;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.timeline-item:first-child { border-top: 0; }
.timeline-item .tl-date {
  font-family: var(--mono); font-size: 11px; color: var(--faint);
}
.timeline-item .tl-date { transition: color .25s var(--ease); }
.timeline-item .tl-title {
  font-size: 14.5px; color: var(--ink); display: inline-block;
  transition: color .25s var(--ease), transform .25s var(--ease);
}
.timeline-item:hover .tl-title { color: var(--accent); transform: translateX(3px); }
.timeline-item:hover .tl-date { color: var(--accent); }

/* ===== 搜索 ===== */
.search-form-block { margin-bottom: 36px; }
.search-form-block input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); font-size: 14px; color: var(--ink);
  transition: border-color .25s var(--ease);
}
.search-form-block input:focus { border-color: var(--line-strong); outline: none; }
.search-form { position: relative; min-width: 0; width: 100%; max-width: 360px; }
.search-form .search-field {
  width: 100%; padding: 12px 46px 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); font-size: 14px; color: var(--ink);
  transition: border-color .25s var(--ease); -webkit-appearance: none; appearance: none;
}
.search-form .search-field:focus { border-color: var(--line-strong); outline: none; }
.search-form .search-submit {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: none; background: transparent; cursor: pointer;
  color: var(--faint); display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: color .25s var(--ease), background .25s var(--ease);
}
.search-form .search-submit:hover { color: var(--accent); background: var(--accent-soft); }
.search-results-count {
  font-family: var(--mono); font-size: 11px; color: var(--faint); margin-bottom: 24px;
}

/* ===== 404 ===== */
.error-404 { text-align: center; padding: 80px 0 60px; }
.error-404 h1 {
  font-family: var(--serif); font-size: clamp(3rem, 8vw, 5rem); font-weight: 400; color: var(--accent);
  line-height: 1; margin-bottom: 16px;
}
.error-404 p { font-size: 15px; color: var(--ink-soft); margin-bottom: 28px; }
.error-404 .btn { display: inline-flex; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 22px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: transparent;
  font-size: 13.5px; letter-spacing: .02em; cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: transparent; color: var(--accent); }

/* ===== 页脚 ===== */
.site-foot {
  padding: 30px 56px 42px; max-width: var(--shell-max); margin: 4px auto 0;
  display: flex; flex-direction: row; flex-wrap: wrap;
  align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  border-top: 1px solid var(--line);
}
.site-foot-left {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  font-size: 11.5px; line-height: 1.6; color: var(--faint);
}
.site-foot .copy { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; }
.site-foot .beian { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.site-foot .beian-link {
  display: inline-flex; flex-direction: row; align-items: center; gap: 5px;
  flex-wrap: nowrap; white-space: nowrap; max-width: 100%;
  font-size: 11.5px; color: var(--faint); border-bottom: 1px solid transparent;
  transition: color .25s var(--ease), border-color .25s var(--ease);
}
.site-foot .beian-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.site-foot .beian-icon {
  width: 16px; height: 16px; flex: 0 0 16px; display: inline-block;
  object-fit: contain; border-radius: 2px; opacity: .9;
  vertical-align: middle; transition: opacity .25s var(--ease);
}
.site-foot .beian-link:hover .beian-icon { opacity: 1; }
.site-foot .beian-text { display: inline-block; line-height: 1.4; }
.site-foot .site-foot-right { margin-left: auto; display: flex; align-items: center; }
.site-foot .credit {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em;
  color: var(--faint); text-decoration: none;
  transition: color .25s var(--ease);
}
.site-foot .credit:hover { color: var(--accent); }
.site-foot a { color: var(--ink-soft); text-decoration: none; transition: color .25s var(--ease), border-color .25s var(--ease); }
.site-foot a:hover { color: var(--accent); border-color: var(--accent); }

/* ===== 加载态 ===== */
.loading, .no-results {
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
  padding: 22px 2px; border-top: 1px solid var(--line);
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; max-height: none; min-height: 0;
    overflow: visible; overscroll-behavior: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 14px 22px 14px; gap: 14px;
  }
  .side-toggle { display: inline-flex; }
  .side-panel { display: none; gap: 18px; padding-bottom: 6px; }
  .sidebar.is-open .side-panel { display: flex; }
  .side-nav { flex-direction: row; flex-wrap: wrap; gap: 0 18px; }
  .side-nav .group-title { display: none; }
  .side-nav a { padding: 6px 0; font-size: 13.5px; }
  .side-foot { margin-top: 0; flex-direction: row; align-items: center; justify-content: space-between; }
  .main { padding: 40px 22px 0; max-width: none; }
  .hero { padding-bottom: 38px; }
  .hero h1 { font-size: 2.2rem; }
  .block { padding: 36px 0; }
  .post-row { grid-template-columns: 34px 1fr; gap: 12px; }
  .post-row .dt { grid-column: 2; font-size: 10.5px; }
  .timeline-item { grid-template-columns: 70px 1fr; gap: 10px; }
  .comment .children { margin-left: 16px; }
  .article-content pre { padding: 14px 16px; font-size: 12.5px; }
  .site-foot { padding: 26px 22px 34px; max-width: none; flex-direction: column; align-items: flex-start; gap: 12px; }
  .site-foot .site-foot-right { margin-left: 0; }
  .site-foot .beian-link { white-space: normal; }
  .site-foot .beian { flex-direction: column; align-items: flex-start; flex-wrap: nowrap; gap: 8px; }
  .site-foot .beian a { font-size: 11px; white-space: nowrap; gap: 5px; }
  .site-foot .beian-icon { width: 15px; height: 15px; }
  .article-nav { flex-direction: column; gap: 12px; }
}

@media (max-width: 520px) {
  .hero h1 { font-size: 1.9rem; }
  .btn { height: 38px; padding: 0 16px; font-size: 13px; }
  .article-header h1 { font-size: 1.7rem; }
  .block-head h2 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* 入场动画 */
@keyframes koishi-fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.hero > * { animation: koishi-fade-up .6s var(--ease) both; }
.hero h1 { animation-delay: .06s; }
.hero .lede { animation-delay: .12s; }
.post-row,.timeline-item,.shuoshuo-item { animation: koishi-fade-up .5s var(--ease) both; }
.post-row:nth-child(1),.timeline-item:nth-child(1) { animation-delay: .04s; }
.post-row:nth-child(2),.timeline-item:nth-child(2) { animation-delay: .08s; }
.post-row:nth-child(3),.timeline-item:nth-child(3) { animation-delay: .12s; }
.post-row:nth-child(4),.timeline-item:nth-child(4) { animation-delay: .16s; }
.post-row:nth-child(5),.timeline-item:nth-child(5) { animation-delay: .20s; }
.post-row:nth-child(n+6),.timeline-item:nth-child(n+6) { animation-delay: .24s; }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.sidebar::-webkit-scrollbar { width: 4px; }

/* 文字细节 */
mark { background: var(--accent-soft); color: var(--ink); padding: 0 3px; border-radius: var(--radius-sm); }
body { font-feature-settings: 'kern' 1, 'liga' 1; }

/* 移动端补充 */
@media (max-width: 900px) {
  .hero h1::after { margin-top: 16px; }
  .post-row,.timeline-item,.shuoshuo-item { animation: none; }
  .article-content.drop-cap > p:first-of-type::first-letter { font-size: 2.4em; }
}

/* ===== 文章目录（TOC）===== */
.toc {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 14px;
}

/* Header: 标题 + 折叠按钮 */
.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.toc .toc-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.toc-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: transform .25s, color .15s;
  flex-shrink: 0;
}
.toc-toggle:hover { color: var(--accent); }
.toc-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }

/* 目录列表 */
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 2000px;
  opacity: 1;
  overflow: hidden;
  will-change: max-height, opacity;
  transition: max-height .15s ease, opacity .12s ease;
}
.toc-list.toc-hidden {
  max-height: 0;
  opacity: 0;
}
.toc ul ul { margin-left: 16px; }
.toc li { margin: 6px 0; }
.toc a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color .15s;
}
.toc a:hover { color: var(--accent); }

/* ---- 右侧浮动（默认）---- */
.toc-right {
  float: right;
  width: 240px;
  margin: 0 0 20px 28px;
}

/* ---- 左侧浮动 ---- */
.toc-left {
  float: left;
  width: 240px;
  margin: 0 28px 20px 0;
}

/* ---- 顶部块级 ---- */
.toc-top {
  width: 100%;
  margin-bottom: 28px;
}

/* ---- sticky 滚动跟随 ---- */
.toc-sticky {
  position: sticky;
  top: 20px;
  z-index: 5;
}

/* 移动端：全部恢复全宽块级 */
@media (max-width: 900px) {
  .toc-right,
  .toc-left,
  .toc-top {
    float: none;
    width: 100%;
    margin: 0 0 20px;
  }
  .toc-sticky { position: static; }
}

/* ===== 相关文章 ===== */
.related-posts {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.related-posts .related-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--ink);
}
.related-posts ul { list-style: none; margin: 0; padding: 0; }
.related-posts li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.related-posts li:last-child { border-bottom: none; }
.related-posts a {
  color: var(--ink);
  text-decoration: none;
  transition: color .15s;
  flex: 1;
  padding-right: 12px;
}
.related-posts a:hover { color: var(--accent); }
.related-posts time {
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
}

/* ===== 评论增强 ===== */
.comment-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.comment-author {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.comment-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.comment-meta { display: flex; flex-direction: column; gap: 2px; }
.comment-meta .fn { font-weight: 600; font-size: 14px; }
.comment-meta time { font-size: 12px; color: var(--ink-soft); }
.comment-content { font-size: 15px; line-height: 1.75; }
.comment-reply { text-align: right; }
.comment-reply a {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
}
.comment-reply a:hover { text-decoration: underline; }
.comment-list .children { list-style: none; margin-left: 32px; padding: 0; }
.comment-awaiting { color: var(--ink-soft); font-style: italic; }

@media (max-width: 900px) {
  .related-posts li { flex-direction: column; gap: 4px; }
  .comment-list .children { margin-left: 16px; }
}
