/* ============================================================
 * Qingyu'Blog · 样式
 * 纯 CSS 变量驱动，支持深色模式与移动端响应式。
 * ============================================================ */

/* ---------- 字体方案（测试中，暂不推送；四款均开源可用） ----------
 * 大标题   梦源宋体 W16      → 本地分片 fonts/dreamserif/result.css（cn-font-split 切分，OFL）
 * 章节标题 源樣明體 SemiBold → GenYoMin2TC 分片 woff2（CDN，OFL）
 * 引用装饰 朱雀仿宋         → Zhuque Fangsong 分片 woff2（CDN，OFL）
 * 正文    思源宋体 VF / Noto Serif SC → cn-fontsource 分片 woff2（CDN，OFL）
 * ----------------------------------------------- */

/* ---------- 主题变量 ---------- */
:root {
  --bg: #faf9f7;
  --bg-soft: #f1efeb;
  --card: #ffffff;
  --fg: #23201b;
  --muted: #7d776b;
  --border: #e6e2da;
  --accent: #c25e3a;
  --accent-soft: #f6e6df;
  --code-bg: #f3f0ea;
  --shadow: 0 1px 2px rgba(35, 32, 27, 0.05), 0 4px 14px rgba(35, 32, 27, 0.06);
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  /* 四级字体栈：正文 / 章节标题 / 大标题 / 装饰引用（管理后台仍用 --font 无衬线） */
  /* 正文跨平台回退栈：优先 webfont/系统思源宋体，再依次匹配各 OS 自带宋体，
   末位 serif 保证任何设备都兜底到系统默认宋体（不存在“没字体”的情况）。
   Android/Linux: Noto Serif CJK SC / Source Han Serif SC · macOS/iOS: Songti SC/华文宋体
   Windows: SimSun/宋体 · 已把正文 webfont 化（思源宋体 VF 走 jsDelivr，每设备一致），此栈仅作回退 */
--font-body: "Source Han Serif SC VF", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", "思源宋体",
             "Songti SC", "STSong", "华文宋体", "SimSun", "宋体", serif;
  --font-heading: "GenYoMin2TC", "源樣明體", var(--font-body);
  --font-display: "QY-Display", "梦源宋体 W16", var(--font-heading);
  --font-deco: "Zhuque Fangsong", "朱雀仿宋", var(--font-body);
  --tok-kw: #cf3a4f;
  --tok-str: #0a7d3f;
  --tok-com: #9aa0a6;
  --tok-num: #b3751c;
}

html[data-theme="dark"] {
  --bg: #171512;
  --bg-soft: #201d18;
  --card: #211e1a;
  --fg: #e8e2d8;
  --muted: #9c9484;
  --border: #35302a;
  --accent: #e08a63;
  --accent-soft: #3a2c22;
  --code-bg: #2a2621;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 14px rgba(0, 0, 0, 0.35);
  --tok-kw: #ff7b72;
  --tok-str: #7ee787;
  --tok-com: #8b949e;
  --tok-num: #d2a8ff;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* 页脚贴底：内容不足一屏时页脚仍固定在视口底部 */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

/* 管理后台不参与字体方案：写作/管理界面维持无衬线，前台阅读区才是宋体 */
.admin-layout { font-family: var(--font); }

/* 应用根节点：参与 body 的纵向 flex，既是 flex item（占满视口）
   又是 header/main/footer 的 flex 容器，保证任何页面页脚都贴底。 */
#app {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  width: 100%;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 60px;
}

.brand {
  justify-self: start;
  font-size: 19px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--fg);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  /* 英文长名（Qingyu'Blog）禁止折行：窄屏下会按字符竖排，需保持单行 */
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand:hover { text-decoration: none; }

.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 8px; position: relative; }

.topbar-left { display: flex; align-items: center; gap: 20px; }

/* 导航（居中显示，可自定义，支持二级下拉） */
.main-nav { justify-self: center; display: flex; gap: 2px; align-items: center; }
.main-nav .nav-link {
  color: var(--muted);
  font-size: 14.5px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.15s ease, background 0.15s ease;
}
.main-nav .nav-link:hover { color: var(--fg); background: var(--bg-soft); text-decoration: none; }
.main-nav .nav-link.active { color: var(--accent); font-weight: 600; }
.nav-item { position: relative; }
.has-sub > .nav-link::after { content: "▾"; font-size: 10px; margin-left: 3px; opacity: 0.7; }
.sub-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 30;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.has-sub:hover .sub-menu,
.has-sub:focus-within .sub-menu { display: flex; opacity: 1; transform: translateY(0); }
.sub-menu a {
  color: var(--fg);
  font-size: 14px;
  padding: 7px 10px;
  border-radius: 7px;
  white-space: nowrap;
}
.sub-menu a:hover { background: var(--bg-soft); color: var(--accent); text-decoration: none; }
.sub-menu a.active { color: var(--accent); font-weight: 600; }

/* ---------- 汉堡按钮（默认隐藏，仅移动端显示） ---------- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 36px; height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
  flex-shrink: 0;
}
.hamburger-btn span {
  display: block;
  width: 20px; height: 2px;
  background: var(--fg);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.hamburger-btn:hover { background: var(--bg-soft); }
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- 遮罩层 ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 199;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* ---------- 移动端侧边导航栏 ---------- */
.mobile-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 280px; height: 100vh;
  height: 100dvh;
  background: var(--bg);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  overflow-y: auto;
}
.mobile-sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--fg);
  letter-spacing: 0.5px;
}
.sidebar-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-close:hover { background: var(--bg-soft); color: var(--fg); }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}
.sidebar-link {
  display: block;
  padding: 12px 24px;
  font-size: 15px;
  color: var(--fg);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--bg-soft); color: var(--accent); text-decoration: none; }
.sidebar-link.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  flex-shrink: 0;
}
.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 深色模式适配 ---------- */
[data-theme="dark"] .mobile-sidebar { box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3); }
[data-theme="dark"] .sidebar-overlay { background: rgba(0, 0, 0, 0.6); }

/* 顶部图标按钮（圆角，与主题同色系） */
.icon-btn {
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--fg);
  width: 34px; height: 34px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* 语言切换器 */
.lang-switch {
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  outline: none;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  padding-right: 22px;
}
.lang-switch:hover { border-color: var(--accent); }
.lang-switch:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* 移动端语言切换器缩小 */
@media (max-width: 992px) {
  .lang-switch { font-size: 12px; padding: 3px 4px; padding-right: 18px; }
}

/* 搜索图标：纯圆环 + 内部圆点（去掉柄） */
.search-icon {
  width: 15px; height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}
.search-dot { fill: currentColor; stroke: none; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}
button.btn { font-family: inherit; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* 键盘可访问性：焦点环 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

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

/* 细滚动条 */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent); color: #fff; filter: brightness(1.08); }

.btn-danger {
  background: #d3544a;
  border-color: #d3544a;
  color: #fff;
}
.btn-danger:hover { background: #c4453c; color: #fff; filter: brightness(1.05); }

.btn-ghost { background: transparent; }

/* ---------- 主区（flex 撑开，保证页脚贴底） ---------- */
main { flex: 1 0 auto; width: 100%; padding: 34px 0 60px; }

/* 视图切换过渡 */
.page-fade { animation: pageFade 0.22s ease; }
@keyframes pageFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  font-size: 26px;
  margin: 0 0 6px;
  font-weight: 700;
  font-family: var(--font-display);
}
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }

/* ---------- 首页头部 ---------- */
.list-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* 当前标签筛选状态（仅在筛选时出现，可一键清除） */
.current-tag { margin-bottom: 14px; }
.current-tag .tag-chip { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tag-clear { color: inherit; margin-left: 4px; font-weight: 700; }
.tag-clear:hover { text-decoration: none; opacity: 0.7; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  line-height: 1.6;
  padding: 1px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  transition: all 0.15s ease;
}
.tag-chip:hover { color: var(--accent); border-color: var(--accent); }

/* 首页搜索框：位于「最新发布」同行最右侧，直接显示可输入 */
/* 顶部导航搜索：圆形 SVG 图标按钮；展开时隐藏整条导航、搜索框占满导航条（电脑/手机通用） */
.topbar-search {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--bg);
  z-index: 11;
}
.topbar.searching .topbar-search { display: flex; }
.topbar.searching .topbar-left,
.topbar.searching .main-nav { display: none; }   /* 展开时隐藏整条顶部导航（品牌 + 链接），由搜索框替代 */
.ts-icon { display: none; }   /* 搜索框内不再显示放大镜图标 */
.search-icon { width: 16px; height: 16px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#globalSearchInput {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
  padding: 9px 14px;
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s ease;
}
#globalSearchInput:focus { border-color: var(--accent); }
.ts-close {
  flex: 0 0 auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 50%;
  width: 30px; height: 30px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ts-close:hover { color: var(--accent); border-color: var(--accent); }

/* 搜索结果下拉面板 */
.search-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  max-height: 72vh;
  overflow-y: auto;
  z-index: 9;
}
.search-panel.open { display: block; }
.search-hit { display: block; padding: 12px 18px; border-bottom: 1px solid var(--border); text-decoration: none; }
.search-hit:last-child { border-bottom: none; }
.search-hit:hover { background: var(--bg-soft); }
.sh-title { font-size: 14.5px; color: var(--fg); font-weight: 600; }
.sh-snip { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.search-empty { padding: 16px 18px; color: var(--muted); font-size: 13px; }

/* 首页标签分类平铺行：位于标题下方、卡片上方 */
.home-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -2px 0 18px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.home-tags-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.home-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  transition: all 0.15s ease;
}
.home-tag:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.home-tag.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.home-tag-count {
  font-size: 11px;
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 0 7px;
  min-width: 18px;
  text-align: center;
}
.home-tag:hover .home-tag-count { background: var(--card); color: var(--muted); }
.home-tag.active .home-tag-count { background: rgba(255,255,255,0.25); color: #fff; }

/* 标签页：标签云 */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 2px;
}
.cloud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--fg);
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 16px;
  transition: all 0.15s ease;
}
.cloud-chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cloud-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.cloud-count {
  font-size: 11.5px;
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 22px;
  text-align: center;
}
.cloud-chip:hover .cloud-count { background: var(--card); }
.cloud-chip.active .cloud-count { background: rgba(255, 255, 255, 0.22); color: #fff; }

/* ---------- 文章卡片 ---------- */
.post-list { display: flex; flex-direction: column; gap: 14px; }

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px 18px;
  min-height: 200px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: stretch;
  gap: 18px;
  color: inherit;
}
.post-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }

/* 卡片左侧内容区（标题 / 摘要 / 元信息）：顶部对齐、高度撑满卡片，
   标签用 margin-top:auto 固定贴底，无摘要时标签也不会向上移动 */
.post-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* 卡片右侧缩略图：圆角独立块（固定尺寸，不随标题/摘要行数变高），
   垂直居中于卡片（内容区 stretch 撑满，缩略图自身居中），
   有图显示图，无图显示主题渐变占位（中性图片图标） */
.post-thumb {
  position: relative;
  flex-shrink: 0;
  align-self: center;
  width: 260px;
  height: 160px;
  aspect-ratio: 13 / 8;          /* 固定宽高比，图片加载前即预留空间，避免布局抖动（CLS） */
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-soft));
  display: flex;
  align-items: center;
  justify-content: center;
}
.post-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.post-thumb-ph {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.85;
  line-height: 1;
  user-select: none;
}

.post-card .meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.post-card .meta .date { letter-spacing: 0.3px; }
.post-card .mini-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: auto 0 0; padding-top: 8px; justify-content: flex-start; align-self: flex-start; }
.post-card .mini-tags span {
  font-size: 11.5px;
  background: var(--bg-soft);
  color: var(--muted);
  padding: 1px 8px;
  border-radius: 999px;
}
/* 深色主题：标签用暖棕底 + 主题橙文字 + 细边框，与卡片底色（#211e1a）明显区分 */
html[data-theme="dark"] .post-card .mini-tags span {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(224, 138, 99, 0.28);
  padding: 0 7px;
}

.post-card h2 { margin: 0 0 6px; font-size: 18.5px; line-height: 1.4; }
.post-card .excerpt {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 56px 0;
}
.empty .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- 文章列表间距（首尾不变，仅卡片之间留空隙） ---------- */
#listContainer { display: flex; flex-direction: column; gap: 18px; }

/* ---------- 翻页器（直角，与文章卡片风格一致） ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 26px; margin-bottom: 32px; }
.pager-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 20px; border: 1px solid var(--border); background: var(--card);
  color: var(--fg); border-radius: 0; font-size: 13.5px; cursor: pointer;
  text-decoration: none; transition: border-color .15s ease, color .15s ease;
}
.pager-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager-btn.disabled { opacity: .4; cursor: default; pointer-events: none; }
.pager-info { color: var(--muted); font-size: 13px; letter-spacing: .5px; }

/* ---------- SVG 图标对齐与动效 ---------- */
.icon-btn svg { display: block; }
.big svg { display: block; margin: 0 auto; }
.pin svg { vertical-align: -2px; margin-right: 4px; }
.meta-views svg { vertical-align: -2px; margin-right: 4px; }
.like-btn.liked svg { fill: currentColor; }
.spin-icon { animation: qy-spin 0.9s linear infinite; transform-origin: center; }
@keyframes qy-spin { to { transform: rotate(360deg); } }

/* ---------- 文章详情 ---------- */
/* 文章详情页：正文居中且保持舒适阅读宽度 */
.post-body {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.post-header { margin-bottom: 26px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.post-header h1 { margin: 0 0 10px; font-size: 28px; line-height: 1.35; font-family: var(--font-display); }
.post-header .meta {
  color: var(--muted);
  font-size: 13.5px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
/* 文章底部标签（左） */
.af-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.af-tags:empty { display: none; }
.af-tags a {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 10px;
  border-radius: 999px;
  transition: all 0.15s ease;
}
.af-tags a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* 文章底部操作行：左标签、右按钮 */
.article-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.af-actions { display: flex; gap: 10px; margin-left: auto; }

/* 点赞：正文尾部，水平居中 */
.like-bar {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}
.like-bar .like-btn { font-size: 14px; padding: 8px 22px; }

/* 详情页 meta：阅读 + 浏览 + 置顶 */
.meta-views { color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }

/* Markdown 正文 */
.article { word-break: break-word; }
.article h1, .article h2, .article h3, .article h4 { line-height: 1.35; margin: 1.6em 0 0.6em; }
.article h1 { font-size: 1.55em; }
.article h2 { font-size: 1.35em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.article h3 { font-size: 1.15em; }
/* 章节标题字体：源樣明體 SemiBold（卡片标题、正文 H2/H3 及写作台预览同步） */
.post-card h2,
.article h2, .article h3,
.write-preview h2, .write-preview h3 { font-family: var(--font-heading); font-weight: 600; }
/* 点击目录跳转时，让标题定位在吸顶导航下方、不被遮挡 */
.article h1[id^="toc-"], .article h2[id^="toc-"], .article h3[id^="toc-"],
.article h4[id^="toc-"], .article h5[id^="toc-"], .article h6[id^="toc-"] {
  scroll-margin-top: 84px;
}
/* 正文标题前的有序编号 */
.article .toc-num {
  display: inline-block;
  font-weight: 600;
  color: var(--muted);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
.article h1 > .toc-num, .article h2 > .toc-num { font-weight: 700; }
.article p { margin: 0.9em 0; }
.article ul, .article ol { padding-left: 1.5em; margin: 0.8em 0; }
.article li { margin: 0.3em 0; }
.article li > ul, .article li > ol { margin: 0.2em 0; }
/* 引用区块：装饰性字体（清刻本悦宋，缺文件时回退正文宋体），略大一号 */
.article blockquote, .write-preview blockquote {
  margin: 1em 0;
  padding: 2px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 0 8px 8px 0;
  font-family: var(--font-deco);
  font-size: 1.06em;
}
.article blockquote p { margin: 0.5em 0; }
.article code.inline-code, .write-preview code.inline-code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 1px 6px;
  border-radius: 5px;
}
.article pre.code-block, .write-preview pre.code-block {
  font-family: var(--mono);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}
.article img, .write-preview img { max-width: 100%; border-radius: 10px; }
.article table, .write-preview table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 14.5px;
}
.article th, .article td, .write-preview th, .write-preview td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.article th { background: var(--bg-soft); font-weight: 600; }
.article hr, .write-preview hr { border: none; border-top: 1px solid var(--border); margin: 1.6em 0; }
.article del { color: var(--muted); }

/* ---------- 写作页 ---------- */
.editor-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.edit-split .edit-cols, .editor-wrap .edit-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field input[type="text"], .field input[type="date"], .field input[type="datetime-local"], .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 90px; }

.editor-meta { margin-bottom: 16px; }
/* 两行并排：标题+日期 / 摘要+标签（首列较宽），置顶+加密第三行；移动端媒体查询恢复单列 */
.editor-grid { display: grid; grid-template-columns: 2.4fr 1fr; gap: 12px; }
/* grid 内间距统一由 gap 控制：覆盖 .field 的 margin-bottom / .check-label 的 margin-top，
   避免行距叠加不均（加密密码框显隐时日期/标签行不产生跳动感） */
.editor-grid > .field { margin-bottom: 0; }
.editor-grid > .check-label { margin-top: 0; }

.editor-area {
  display: block;
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
}
.editor-area:focus { border-color: var(--accent); }

.preview-pane {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  padding: 14px 18px;
  min-height: 420px;
  max-height: 620px;
  overflow-y: auto;
  font-size: 15px;
}

.pane-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.editor-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ---------- 写作台 · 顶栏与布局 ---------- */
/* 写作台较正文更宽：编辑+预览并排时每栏更从容（正文/首页仍 760px 可读） */
.container.write-page { max-width: 1160px; }
.write-page .write-head { margin-bottom: 18px; }
.write-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.write-head .page-title { margin: 0; font-size: 22px; display: inline-flex; align-items: center; gap: 8px; }
.mode-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; letter-spacing: 0.4px;
  padding: 3px 10px; border-radius: 99px;
  color: var(--accent); background: var(--accent-soft);
}
.mode-chip.local { color: var(--muted); background: var(--bg-soft); }
.mode-chip.editing {
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg); background: var(--bg-soft);
  border: 1px solid var(--border);
}

/* 信息卡：标题通栏，其余两列 */
.field-full { grid-column: 1 / -1; }

/* 编辑 / 预览 双栏卡片（带标题头，聚焦高亮） */
.editor-pane {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.editor-pane:focus-within { border-color: var(--accent); }
.pane-head {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.pane-note { margin-left: auto; font-weight: 400; font-size: 11px; opacity: 0.8; }
/* 工具栏融入卡片：去独立边框，作为头部下的工具条 */
.editor-pane .toolbar {
  margin: 0;
  padding: 6px 10px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.md-input {
  width: 100%;
  min-height: 560px;
  border: 0;
  background: var(--bg);
  color: var(--fg);
  padding: 18px 22px;
  font-family: var(--mono);
  font-size: 14.5px;
  line-height: 1.8;
  resize: none;          /* 由 autoGrowMd 按内容自动撑高，超上限后内部滚动 */
  overflow-y: auto;
  outline: none;
}
.preview-body {
  padding: 20px 22px;
  min-height: 560px;
  max-height: 76vh;
  overflow-y: auto;
  font-size: 16px;
  line-height: 1.75;
}

/* 操作条：主操作 | 草稿/导入/外部 | 导出/RSS/Sitemap || 状态+退出 */
.actions-bar {
  align-items: center;
  margin-top: 18px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.action-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.actions-right { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.btn-logout:hover { color: #c0392b; border-color: #c0392b; }
html[data-theme="dark"] .btn-logout:hover { color: #e07b6b; border-color: #e07b6b; }
.draft-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg-soft);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.draft-hint b { color: var(--accent); }

.draft-list { margin-top: 18px; }
.draft-list h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.draft-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.draft-item:hover { border-color: var(--accent); }
.draft-item .draft-title { font-weight: 600; }
.draft-item .draft-meta { color: var(--muted); font-size: 12px; }
.draft-item button {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.draft-item button:hover { color: #d3544a; }

/* ---------- 页脚（贴底 + 可配置链接） ---------- */
footer { flex-shrink: 0; border-top: 1px solid var(--border); background: var(--bg-soft); }
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;   /* 左对齐，不居中 */
  gap: 8px;                  /* 所有行之间距统一 */
  padding: 14px 20px 16px;
}
/* 页脚导航行（电脑端含 RSS；移动端隐藏 RSS 与下方声明区块） */
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  line-height: 1.6;
}
.footer-nav a { color: var(--muted); text-decoration: none; transition: color 0.15s ease; padding: 1px 5px; }
.footer-nav a:hover { color: var(--accent); }
.footer-dot { color: var(--border); margin: 0 1px; }
.footer-rss { color: var(--accent); }
/* 电脑端专属：站点声明 / 联系方式 / 友情链接（行距与其余行统一） */
.footer-extra {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}
.footer-extra p { margin: 0; }
.footer-decl { max-width: 760px; }
.footer-nav a:first-child { padding-left: 0; }   /* 首个链接贴最左边 */
.footer-contact a, .footer-contact a:hover { color: var(--muted); text-decoration: none; }  /* 邮箱纯文本样式 */
.footer-friends a { color: var(--muted); text-decoration: none; }
.footer-friends a:hover { color: var(--accent); text-decoration: none; cursor: pointer; }
.footer-copy { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.footer-icp { margin-left: 8px; }
.footer-icp:hover { color: var(--accent); }

/* 移动端：仅保留导航行与版权行，隐藏声明/联系方式/友链/备案；内容整体居中。
   RSS 保留显示（普通用户的订阅入口，管理员显示写作后台代替） */
@media (max-width: 640px) {
  .footer-extra { display: none; }
  .footer-icp { display: none; }
  .footer-inner { align-items: center; }                  /* 手机端居中 */
  .footer-nav, .footer-copy { justify-content: center; text-align: center; }
}

/* ---------- 关于页 ---------- */
.about-card h3 { margin: 1.4em 0 0.4em; font-size: 15px; }
.about-card h3:first-child { margin-top: 0; }
.about-card ul { margin: 0.4em 0; padding-left: 1.4em; }
.about-card p { margin: 0.5em 0; }
/* 站点简介（Markdown 渲染）与统计信息之间的分隔 */
.about-sep { border: none; border-top: 1px dashed var(--border); margin: 22px 0 18px; }

/* ---------- 回到顶部 ---------- */
/* ---------- 回到顶部（悬浮右下角，滚动后出现） ---------- */
.btn-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 42px;
  height: 42px;
  border-radius: 0;              /* 与全站直角风格一致 */
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 30;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.btn-top:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }
@media (max-width: 640px) {
  .btn-top { right: 14px; bottom: 14px; width: 38px; height: 38px; }
}

/* ---------- 写作页细节：字数 / 保存状态 / 快捷键提示 ---------- */
.word-count { color: var(--muted); font-weight: 400; }
.save-status { color: var(--accent); font-weight: 400; }
.keys-hint {
  align-self: center;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
kbd {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
}

/* ---------- 详情页 meta ---------- */
.post-header .meta .meta-date { letter-spacing: 0.3px; }
.post-header .meta .meta-dot { opacity: 0.5; }

/* ---------- 归档页 ---------- */
.archive-year {
  font-size: 20px;
  margin: 28px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.archive-month h3 {
  font-size: 15px;
  margin: 18px 0 6px;
  color: var(--fg);
}
.archive-month .count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 8px;
}
.archive-month ul { list-style: none; margin: 0; padding: 0; }
.archive-month li {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 6px 0;
  font-size: 14.5px;
  border-bottom: 1px dashed rgba(128, 128, 128, 0.2); /* 弱化虚线，几乎透明 */
}
.archive-month li:last-child {
  border-bottom: 1px dashed rgba(128, 128, 128, 0.2); /* 最后一篇也用弱化虚线，保持一致 */
}
.archive-month li:only-child {
  border-bottom: 1px dashed rgba(128, 128, 128, 0.2); /* 单篇也一致 */
}
.archive-month li .ad {
  color: var(--muted);
  font-size: 13px;
  min-width: 96px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}
.archive-month li a { color: var(--fg); }
.archive-month li a:hover { color: var(--accent); text-decoration: none; }
/* 某个月份仅一篇文章时，不显示虚分线；多篇才显示 */
.archive-month li:only-child { border-bottom: none; }

/* ---------- 关于页统计 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0 4px;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.stat b {
  display: block;
  font-size: 18px;
  color: var(--accent);
  line-height: 1.4;
}
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- 广告位 ---------- */
.ad-slot {
  margin: 18px 0;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  text-align: center;
  overflow-x: auto;
}
.ad-label {
  display: inline-block;
  font-size: 10.5px;
  color: var(--muted);
  opacity: 0.7;
  letter-spacing: 2px;
  margin-bottom: 6px;
}
.ad-slot ins { display: block; }

/* ---------- 置顶徽章 & 复选标签 ---------- */
.post-card .pin {
  font-size: 11.5px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 8px;
  border-radius: 999px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
/* label 内部（checkbox + 图标 + 文字）flex 垂直居中，确保与密码框同一行对齐 */
.check-label label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.check-label svg { flex-shrink: 0; display: block; }
.check-label input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }

/* 加密密码框：与编辑器表单输入框统一主题（边框 / 圆角 / 背景 / 聚焦）。
   宽度取整数值，确保在 grid 1fr 列内显示不溢出、不挤压同行 */
.protect-pwd {
  width: 190px;
  margin-left: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  flex-shrink: 0;
}
.protect-pwd:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.protect-pwd::placeholder { color: var(--muted); }

/* ---------- 加密解锁卡 ---------- */
.lock-card {
  margin: 22px 0;
  padding: 30px 20px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
  text-align: center;
}
.lock-card .big { font-size: 34px; margin-bottom: 8px; }
.lock-card h3 { margin: 0 0 6px; }
.lock-card p { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.lock-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.lock-form input {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  min-width: 200px;
  font-size: 14px;
}
.lock-msg { margin-top: 10px; color: var(--accent); font-size: 13px; }

/* ---------- 评论区 ---------- */
.comments { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); }
.comments h3 { font-size: 17px; margin: 0 0 4px; }
.comment-count { color: var(--muted); font-weight: 400; font-size: 14px; }
.comment-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; }
.comment-form input, .comment-form textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}
.comment-submit-row { display: flex; align-items: center; gap: 10px; }
.c-status { font-size: 13px; color: var(--muted); }
.comment-list { list-style: none; margin: 16px 0 0; padding: 0; }
.comment { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.comment-head { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.comment-author { font-weight: 600; color: var(--accent); }
.comment-date { color: var(--muted); font-size: 12px; }
.comment-del {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  opacity: 0.6;
  padding: 2px 6px;
  border-radius: 6px;
}
.comment-del:hover { opacity: 1; color: var(--danger, #c0392b); background: var(--bg-soft); }
.comment-content { margin: 4px 0 0; font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.comment-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
/* 评论回复 */
.comment-children { list-style: none; margin: 8px 0 0; padding: 0 0 0 20px; }
.comment-children .comment { border-left: 2px solid var(--border); padding-left: 12px; margin-bottom: 8px; }
.comment-reply-btn { background: none; border: none; color: var(--muted, #999); cursor: pointer; font-size: 12px; padding: 2px 6px; border-radius: 4px; }
.comment-reply-btn:hover { background: var(--bg-soft); color: var(--accent); }
.reply-indicator { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; color: var(--text); }
.reply-cancel { background: none; border: none; cursor: pointer; color: var(--muted, #999); font-size: 16px; padding: 0 2px; }
.reply-cancel:hover { color: var(--text); }

/* ---------- 精选文章 ---------- */
.featured-posts {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  margin-bottom: 32px;
}
.featured-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.featured-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.featured-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  text-decoration: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  min-height: 90px;
}
.featured-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  text-decoration: none;
}
.featured-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.featured-card:hover .featured-card-title { color: var(--accent); }
.featured-card-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.featured-card-meta svg { flex-shrink: 0; }
.featured-loading, .featured-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
}
@media (max-width: 640px) {
  .featured-grid { grid-template-columns: 1fr; }
  .featured-card-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: calc(1.5em * 2);
  }
}

/* ---------- 写作页：密码 ---------- */
.pw-label { display: block; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.pw-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.pw-row input { flex: 1; min-width: 0; }
.pw-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.btn-sm { font-size: 12.5px; padding: 6px 12px; white-space: nowrap; }

/* ---------- 目录 TOC ---------- */
.toc {
  margin: 0 0 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 10px 14px;
}
.toc summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  user-select: none;
  list-style: none;
}
.toc summary::-webkit-details-marker { display: none; }
.toc-list { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; }
.toc-list a {
  font-size: 13.5px;
  color: var(--fg);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 6px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}
.toc-list a:hover { color: var(--accent); background: var(--accent-soft); }
.toc-list .toc-num {
  display: inline-block;
  min-width: 18px;
  color: var(--muted);
  font-weight: 500;
  margin-right: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---------- 点赞（正文尾部居中） ---------- */
.like-btn {
  cursor: pointer;
  font-family: inherit;
  background: var(--bg-soft);
  border-radius: 999px;
}
.like-btn:hover { border-color: var(--accent); color: var(--accent); }
.like-btn.liked { color: #e0245e; border-color: rgba(224, 36, 94, 0.35); background: rgba(224, 36, 94, 0.08); }
.like-btn:disabled { cursor: default; }

/* ---------- 代码高亮 token ---------- */
.code-block .tok-kw { color: var(--tok-kw); }
.code-block .tok-str { color: var(--tok-str); }
.code-block .tok-com { color: var(--tok-com); font-style: italic; }
.code-block .tok-num { color: var(--tok-num); }
.code-block code[class*="lang-"] { display: block; }

/* ---------- 编辑器工具栏 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}
.tb-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12.5px;
  font-family: var(--mono);
  cursor: pointer;
  line-height: 1.5;
}
.tb-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 上一篇 / 下一篇 ---------- */
.pn-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.pn-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  background: var(--card);
  min-width: 0;
}
.pn-item:hover { border-color: var(--accent); text-decoration: none; }
.pn-item:hover .pn-title { color: var(--accent); }
.pn-item:hover .pn-dir { color: var(--accent); opacity: 0.9; }
.pn-item.pn-single { grid-column: 1 / -1; }
.pn-dir { font-size: 11.5px; color: var(--muted); }
.pn-title {
  font-size: 14px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 管理员门禁（登录页） ---------- */
.gate-card {
  max-width: 520px;
  margin: 56px auto 0;
  padding: 44px 34px 26px;
  text-align: center;
}
.gate-badge {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.gate-title { margin: 0 0 8px; font-size: 20px; letter-spacing: 0.5px; }
.gate-sub {
  margin: 0 auto 22px;
  max-width: 300px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.gate-form { display: flex; flex-direction: column; gap: 10px; }
.gate-form input {
  width: 100%; min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  text-align: center;
  letter-spacing: 2px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.gate-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.gate-form .btn { width: 100%; justify-content: center; padding: 11px; font-size: 14.5px; }
.alert-strip {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}
.alert-strip:empty { display: none; }
.gate-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 13.5px;
}
.gate-hint { margin: 14px auto 0; max-width: 340px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.gate-hint code { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 11.5px; }

/* ---------- 管理后台：两栏布局（左侧边栏 + 右内容区） ---------- */
.admin-layout {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin-top: 2px;
}

/* --- 左侧边栏 --- */
.admin-sidebar {
  position: sticky;
  top: 84px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
}
.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.admin-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #000));
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}
.admin-brand-text {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
}
.admin-sidebar-ver {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}
.admin-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.admin-nav-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 10px 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.9px;
  color: var(--muted);
  text-transform: uppercase;
}
.admin-nav-group svg { opacity: 0.7; }
.admin-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--fg);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.admin-nav-item > svg { flex-shrink: 0; color: var(--muted); }
.admin-nav-item:hover { background: var(--bg-soft); color: var(--accent); text-decoration: none; }
.admin-nav-item:hover > svg { color: var(--accent); }
.admin-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.admin-nav-item.active > svg { color: var(--accent); }
.admin-nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 3px;
  background: var(--accent);
}
.admin-nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
}
.admin-nav-item.active .admin-nav-count {
  background: var(--card);
  color: var(--accent);
  border-color: var(--accent);
}
.admin-sidebar-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.admin-sidebar-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
}
.admin-sidebar-mode svg { color: var(--accent); }
.admin-sidebar-footer .btn-logout { width: 100%; justify-content: center; }

.admin-content { min-width: 0; }

/* --- 内容区页头（文章列表） --- */
.admin-posts-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.admin-head-titles h2 {
  margin: 0 0 4px;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.admin-head-titles h2 svg { color: var(--accent); }
.admin-head-sub { margin: 0; color: var(--muted); font-size: 13px; }
.btn-new-post { white-space: nowrap; }

/* --- 统计行 --- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.admin-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 13px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.admin-stat-num { font-size: 22px; font-weight: 700; color: var(--accent); line-height: 1; }
.admin-stat-label { font-size: 12.5px; color: var(--muted); }

/* --- 文章表格 --- */
.admin-posts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 14px;
  box-shadow: var(--shadow);
}
.admin-posts-table th,
.admin-posts-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-posts-table th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.5px;
}
.admin-posts-table tr:last-child td { border-bottom: none; }
.admin-posts-table tbody tr { transition: background 0.12s ease; }
.admin-posts-table tbody tr:hover { background: var(--bg-soft); }

.post-title-cell { max-width: 380px; }
.post-title-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg);
  font-weight: 500;
}
.post-title-link svg {
  opacity: 0;
  color: var(--muted);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.post-title-link:hover svg { opacity: 1; transform: translate(2px, -2px); }
.admin-posts-table .post-title-link:hover { color: var(--accent); text-decoration: none; }
.post-date-cell { color: var(--muted); font-size: 13px; white-space: nowrap; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status-badge svg { flex-shrink: 0; }
.status-badge.pinned {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.post-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* 列表操作按钮激活态：置顶/加密已开启时高亮（accent 描边 + 浅底） */
.post-actions .btn-on {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-state { color: var(--muted); font-size: 14px; padding: 22px 0; }
.empty-state a { color: var(--accent); }

/* --- 写作台内容增强：层次与间距 --- */
.write-page .write-head { margin-bottom: 20px; }
.write-page .write-head .page-title { font-size: 21px; }
.editor-meta { border-radius: 12px; box-shadow: var(--shadow); }
.editor-grid { row-gap: 14px; }
.actions-bar { border-radius: 12px; padding: 12px 16px; gap: 8px; }


/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  main { padding: 22px 0 46px; }
  .page-title { font-size: 22px; }
  .post-header h1 { font-size: 22px; }
  .editor-grid { grid-template-columns: 1fr; }
  .edit-split .edit-cols { grid-template-columns: 1fr; }
  /* 写作台：编辑/预览上下堆叠，操作条整行换行 */
  .editor-wrap { grid-template-columns: 1fr; gap: 14px; }
  .md-input, .preview-body { min-height: 320px; }
  .action-sep { display: none; }
  .actions-right { margin-left: 0; width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .gate-card { margin-top: 28px; padding: 34px 22px 22px; }
  .container { padding: 0 14px; }
  .pn-nav { grid-template-columns: 1fr; }
  .brand { font-size: 17px; letter-spacing: 0.3px; }
  .main-nav { gap: 0; }
  .main-nav .nav-link { padding: 6px 9px; font-size: 14px; }
  /* 分类标签在手机上改为单行横向滑动，可滑出更多标签 */
  .home-tags {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 14px;
  }
  .home-tags::-webkit-scrollbar { display: none; }
  .home-tag { flex: 0 0 auto; }
  .article-footer { justify-content: center; }
  .af-actions { margin-left: 0; width: 100%; justify-content: center; flex-wrap: wrap; }
  .like-bar { margin-top: 22px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .archive-month li { gap: 10px; }
  /* 管理后台：移动端侧边栏变顶部横向导航，内容区单列 */
  .admin-layout { grid-template-columns: 1fr; gap: 14px; }
  .admin-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 12px;
  }
  .admin-sidebar-brand {
    flex: 1 1 100%;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    padding: 0 4px 10px;
  }
  .admin-sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .admin-nav-group { display: none; }
  .admin-nav-item { padding: 7px 12px; font-size: 13.5px; }
  .admin-nav-item.active::before { display: none; }
  .admin-nav-count { padding: 0 6px; }
  .admin-sidebar-mode { display: none; }
  .admin-sidebar-footer {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    margin-left: auto;
  }
  .admin-sidebar-footer .btn-logout { width: auto; }
  .admin-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .admin-stat { padding: 10px 12px; }
  .admin-stat-num { font-size: 18px; }
  .admin-posts-table { display: block; overflow-x: auto; }
  .field-protect { flex-wrap: wrap; }
  .field-protect .protect-pwd { width: 100%; margin-left: 0; }
  .post-card { gap: 14px; padding: 14px; min-height: 160px; }
  .post-card-main { padding: 0; }
  .post-thumb { width: 180px; height: 120px; border-radius: 10px; }
  .post-thumb-ph svg { width: 22px; height: 22px; }
}

/* ---------- 移动端布局（≤768px） ---------- */
/* 桌面端隐藏的东西 */
.mobile-only { display: none; }
@media (max-width: 768px) {
  /* 移动端隐藏桌面元素 */
  .main-nav { display: none; }
  .topbar-actions .lang-switch,
  .topbar-actions .icon-btn:not(.search-toggle) { display: none; }
  /* 汉堡按钮显示 */
  .hamburger-btn { display: flex; }
  /* 顶栏三栏：汉堡+品牌 | 搜索 */
  .topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .brand { font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .icon-btn { width: 30px; height: 30px; font-size: 13px; }
  /* 精选卡片标题限制2行 */
  .featured-card-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: calc(1.5em * 2);
  }
}

/* iPhone 17（约 393px）/ iPhone 17 Pro Max（约 440px）等窄屏：
   缩略图圆角固定尺寸，同时保证左侧内容区有足够宽度（标题/摘要不被挤爆） */
@media (max-width: 480px) {
  .post-card { gap: 12px; padding: 12px; min-height: 140px; }
  .post-card-main { padding: 0; }
  .post-thumb { width: 150px; height: 100px; border-radius: 10px; }
  .post-thumb-ph svg { width: 20px; height: 20px; }
  .post-card h2 { font-size: 17px; }
  .post-card .excerpt { font-size: 13.5px; }
  /* 顶栏：品牌英文名缩小，保证单行不溢出 */
  .brand { font-size: 16px; letter-spacing: 0.2px; }
  .main-nav .nav-link { padding: 6px 8px; font-size: 13.5px; }
  .topbar-actions { gap: 6px; }
  .featured-card-title {
    -webkit-line-clamp: 2;
    max-height: calc(1.5em * 2);
  }
}

/* 主流安卓窄屏（OPPO / 小米 / vivo / 华为，约 360-400px）：继续压缩顶栏，防品牌/导航换行竖排 */
@media (max-width: 400px) {
  .topbar-inner { height: 54px; }
  .brand { font-size: 15px; letter-spacing: 0; }
  .main-nav .nav-link { padding: 5px 6px; font-size: 13px; }
  .topbar-actions { gap: 4px; }
}

/* 极小屏（约 320-360px，含 360px 安卓旧机型） */
@media (max-width: 360px) {
  .brand { font-size: 14px; }
  .main-nav .nav-link { padding: 5px 5px; font-size: 12.5px; }
}
/* 侧栏品牌名旁边的主题切换按钮 */
.sidebar-theme {
  background: none;
  border: 1px solid var(--border);
  margin-left: auto;
  width: 32px; height: 32px;
}