/* ==========================================================================
   林深 · 个人博客  样式表
   --------------------------------------------------------------------------
   设计取向：现代、克制、有质感。
   - 配色：米白纸感底色 + 深墨绿主色，点缀暖铜色
   - 字体：中文优先的系统字体栈，标题用衬线体营造编辑／杂志感
   - 主题：<html data-theme="light|dark">，所有颜色走 CSS 变量
   结构：1 变量 → 2 基础 → 3 布局壳 → 4 页头 → 5 首页 Hero → 6 工具栏
         → 7 卡片网格 → 8 骨架屏/空状态 → 9 文章详情 → 10 后台
         → 11 通用组件 → 12 动效与响应式
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 设计令牌（Design Tokens）
   -------------------------------------------------------------------------- */
:root {
  /* —— 主色：深墨绿 —— */
  --brand-50: #eef5f1;
  --brand-100: #dbeae2;
  --brand-200: #b9d5c7;
  --brand-300: #8dbba6;
  --brand-400: #5d9c81;
  --brand-500: #3c7f66;
  --brand-600: #2b6551;
  --brand-700: #1f4f40;
  --brand-800: #173d32;
  --brand-900: #112e26;

  /* —— 点缀：暖铜 —— */
  --accent-100: #f6e9dd;
  --accent-300: #e0b189;
  --accent-500: #c07f4a;
  --accent-600: #a5643a;

  /* —— 中性色（暖灰） —— */
  --ink-900: #16181a;
  --ink-800: #23272a;
  --ink-700: #333a3d;
  --ink-600: #4b5457;
  --ink-500: #6a7377;
  --ink-400: #8e9799;
  --ink-300: #b9c0c1;
  --ink-200: #d9dedd;
  --ink-100: #e9ecea;
  --ink-50: #f4f5f3;

  /* —— 语义变量：浅色主题 —— */
  --bg: #faf8f3;
  --bg-elevated: #ffffff;
  --bg-subtle: #f2efe8;
  --bg-code: #f6f3ec;
  --bg-code-block: #12211c;
  --bg-hover: rgba(31, 79, 64, 0.06);
  --bg-glass: rgba(250, 248, 243, 0.78);

  --text: var(--ink-900);
  --text-secondary: var(--ink-600);
  --text-muted: var(--ink-500);
  --text-on-brand: #f7fbf9;
  --code-text: #d7e6dd;

  --brand: var(--brand-600);
  --brand-strong: var(--brand-700);
  --brand-soft: var(--brand-50);
  --brand-border: var(--brand-200);
  --accent: var(--accent-600);

  --border: #e4e0d6;
  --border-strong: #d3cdbe;
  --border-input: #d8d3c6;

  --shadow-xs: 0 1px 2px rgba(22, 24, 26, 0.05);
  --shadow-sm: 0 1px 3px rgba(22, 24, 26, 0.06), 0 1px 2px rgba(22, 24, 26, 0.04);
  --shadow-md: 0 6px 16px -6px rgba(22, 45, 38, 0.16), 0 2px 6px -2px rgba(22, 24, 26, 0.06);
  --shadow-lg: 0 20px 42px -22px rgba(22, 45, 38, 0.32), 0 8px 18px -12px rgba(22, 24, 26, 0.12);
  --ring: 0 0 0 3px rgba(43, 101, 81, 0.22);

  /* —— 字体 —— */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC",
    "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong",
    "SimSun", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
    Menlo, Consolas, "Liberation Mono", "Courier New", monospace;

  /* —— 尺度 —— */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --container: 1180px;
  --container-narrow: 760px;
  --gutter: clamp(18px, 4vw, 40px);

  --header-h: 68px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --t-fast: 140ms;
  --t-base: 240ms;
  --t-slow: 420ms;

  color-scheme: light;
}

/* —— 深色主题：覆盖语义变量即可 —— */
html[data-theme="dark"] {
  --bg: #101413;
  --bg-elevated: #171d1b;
  --bg-subtle: #1c2321;
  --bg-code: #1b2321;
  --bg-code-block: #0b100e;
  --bg-hover: rgba(141, 187, 166, 0.09);
  --bg-glass: rgba(16, 20, 19, 0.76);

  --text: #e9eeeb;
  --text-secondary: #a9b5b0;
  --text-muted: #85908c;
  --text-on-brand: #0d1613;
  --code-text: #cfdcd6;

  --brand: #7fb89f;
  --brand-strong: #a3cdb9;
  --brand-soft: rgba(127, 184, 159, 0.12);
  --brand-border: rgba(127, 184, 159, 0.3);
  --accent: #d3a377;

  --border: #26302d;
  --border-strong: #33403c;
  --border-input: #303a37;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.6), 0 2px 8px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 48px -24px rgba(0, 0, 0, 0.75), 0 10px 22px -14px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 3px rgba(127, 184, 159, 0.3);

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. 基础重置与排版
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* 极淡的纸纹与光晕，避免纯色背景的扁平感 */
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(60, 127, 102, 0.07), transparent 62%),
    radial-gradient(900px 480px at 92% 2%, rgba(192, 127, 74, 0.055), transparent 60%);
  background-repeat: no-repeat;
  transition: background-color var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out);
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(1100px 520px at 12% -8%, rgba(127, 184, 159, 0.07), transparent 62%),
    radial-gradient(900px 480px at 92% 2%, rgba(211, 163, 119, 0.04), transparent 60%);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 0.5em;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}

p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

a {
  color: var(--brand);
  text-decoration-color: color-mix(in srgb, var(--brand) 35%, transparent);
  text-underline-offset: 3px;
  transition: color var(--t-fast) var(--ease-out),
    text-decoration-color var(--t-fast) var(--ease-out);
}

a:hover {
  color: var(--brand-strong);
  text-decoration-color: currentColor;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 2.5rem 0;
}

::selection {
  background: color-mix(in srgb, var(--brand) 26%, transparent);
  color: var(--text);
}

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

/* 隐藏工具类：!important 确保覆盖组件的 display:flex */
[hidden] {
  display: none !important;
}

/* 仅供读屏使用 */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 跳转到主内容 */
.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -120%);
  z-index: 200;
  padding: 10px 18px;
  background: var(--brand-strong);
  color: var(--text-on-brand);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 14px;
  text-decoration: none;
  transition: transform var(--t-base) var(--ease-out);
}

.skip-link:focus {
  transform: translate(-50%, 0);
  color: var(--text-on-brand);
}

/* 通用容器 */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: var(--container-narrow);
}

/* --------------------------------------------------------------------------
   3. 页面壳
   -------------------------------------------------------------------------- */
.site-main {
  display: block;
  padding-bottom: clamp(48px, 8vw, 96px);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
  padding: 34px 0 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.site-footer .footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.site-footer p {
  margin: 0;
}

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

.site-footer a:hover {
  color: var(--brand);
}

.footer-links {
  display: flex;
  gap: 20px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* 阅读进度条（贴顶细线） */
#readingProgress {
  position: fixed;
  inset: 0 auto auto 0;
  width: 0;
  height: 3px;
  z-index: 120;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-300) 55%, var(--accent-300));
  border-radius: 0 2px 2px 0;
  transform-origin: left center;
  transition: width 90ms linear, opacity var(--t-base) var(--ease-out);
  pointer-events: none;
}

html[data-theme="dark"] #readingProgress {
  background: linear-gradient(90deg, var(--brand), var(--brand-300) 55%, var(--accent));
}

/* 回到顶部 */
#backToTop {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 110;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.96);
  transition: opacity var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out), visibility var(--t-base),
    color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out), background-color var(--t-base) var(--ease-out);
}

#backToTop.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

#backToTop:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px) scale(1.02);
}

#backToTop svg {
  width: 20px;
  height: 20px;
}

/* --------------------------------------------------------------------------
   4. 页头与导航
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--bg-glass);
  border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  transition: border-color var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out), background-color var(--t-base) var(--ease-out);
}

/* JS 滚动后加 .is-scrolled */
.site-header.is-scrolled {
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-brand:hover {
  color: var(--brand);
}

/* 品牌小方块标记 */
.site-brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(140deg, var(--brand-500), var(--brand-700));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
  transition: transform var(--t-base) var(--ease-out);
}

.site-brand:hover::before {
  transform: rotate(45deg);
}

.site-brand small {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* —— 导航 —— */
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.site-nav a {
  position: relative;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out);
}

.site-nav a:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.site-nav a.is-active,
.site-nav a[aria-current="page"] {
  color: var(--brand-strong);
  font-weight: 600;
}

/* 下划线小指示条 */
.site-nav a.is-active::after,
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 13px;
  right: 13px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: var(--brand);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 图标按钮：主题切换 / 汉堡 */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out);
}

.icon-btn:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  background: var(--bg-hover);
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
  pointer-events: none;
}

/* 切换图标：浅色显示月亮、深色显示太阳 */
#themeToggle .icon-moon,
#themeToggle .icon-sun {
  display: none;
}

html[data-theme="light"] #themeToggle .icon-moon,
html:not([data-theme]) #themeToggle .icon-moon {
  display: block;
}

html[data-theme="dark"] #themeToggle .icon-sun {
  display: block;
}

/* 汉堡按钮：默认隐藏（手机上由媒体查询显示），
   菜单打开时把汉堡图标换成关闭图标。
   不假设 .site-nav 与 #navToggle 的兄弟顺序，只依赖 aria-expanded（JS 会同步该属性）。 */
#navToggle {
  display: none;
}

#navToggle .icon-close {
  display: none;
}

#navToggle[aria-expanded="true"] .icon-menu {
  display: none;
}

#navToggle[aria-expanded="true"] .icon-close {
  display: block;
}

/* --------------------------------------------------------------------------
   5. 首页 Hero / 个人介绍
   -------------------------------------------------------------------------- */
.hero {
  padding: clamp(44px, 8vw, 88px) 0 clamp(30px, 5vw, 52px);
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 64px);
  align-items: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow-xs);
}

.hero-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--brand-400);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
  animation: pulse-dot 2.6s var(--ease-in-out) infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

.hero-title {
  margin: 0 0 20px;
  font-family: var(--font-serif);
  font-size: clamp(34px, 5.4vw, 58px);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.015em;
}

/* 标题里的一处墨绿色强调 */
.hero-title em {
  font-style: normal;
  color: var(--brand);
  position: relative;
  white-space: nowrap;
}

.hero-title em::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 0.08em;
  height: 0.34em;
  background: color-mix(in srgb, var(--brand) 15%, transparent);
  border-radius: 2px;
  z-index: -1;
}

.hero-lead {
  margin: 0 0 28px;
  max-width: 56ch;
  color: var(--text-secondary);
  font-size: clamp(15px, 1.4vw, 17.5px);
  line-height: 1.85;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

/* 右侧头像卡片 */
.hero-side {
  display: flex;
  justify-content: center;
}

.avatar-card {
  position: relative;
  width: min(100%, 300px);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  transform: rotate(1.6deg);
  transition: transform var(--t-slow) var(--ease-out),
    box-shadow var(--t-slow) var(--ease-out);
}

.avatar-card:hover {
  transform: rotate(0deg) translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.avatar-card::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: calc(var(--radius-lg) - 8px);
  pointer-events: none;
}

.avatar {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(150deg, var(--brand-400), var(--brand-700));
  display: grid;
  place-items: center;
  color: var(--text-on-brand);
  font-family: var(--font-serif);
  font-size: 46px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 6px 4px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.avatar-caption strong {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.04em;
}

/* 首页统计条 */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: clamp(30px, 5vw, 52px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--border);
  overflow: hidden;
}

.stat {
  padding: 18px 22px;
  background: var(--bg-elevated);
  transition: background-color var(--t-base) var(--ease-out);
}

.stat:hover {
  background: var(--bg-subtle);
}

.stat-value {
  display: block;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

.stat-label {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* --------------------------------------------------------------------------
   6. 区块标题 / 工具栏（标签筛选 + 搜索）
   -------------------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.section-title {
  position: relative;
  margin: 0;
  padding-left: 14px;
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 700;
}

.section-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  bottom: 0.22em;
  width: 4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, var(--brand-500), var(--accent-300));
}

.section-desc {
  margin: 6px 0 0;
  padding-left: 14px;
  color: var(--text-muted);
  font-size: 14.5px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-elevated) 72%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* 标签列表 */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}

.tag-pill:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  background: var(--brand-soft);
  transform: translateY(-1px);
}

.tag-pill:active {
  transform: translateY(0) scale(0.97);
}

.tag-pill.is-active,
.tag-pill.active {
  color: var(--text-on-brand);
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--brand) 70%, transparent);
}

.tag-pill .tag-count {
  font-size: 11.5px;
  opacity: 0.62;
  font-variant-numeric: tabular-nums;
}

/* 搜索框 */
.search-wrap {
  position: relative;
  flex: 0 1 300px;
  min-width: 180px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--t-fast) var(--ease-out);
}

.search-wrap:focus-within .search-icon {
  color: var(--brand);
}

#searchInput,
.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  transition: border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out), background-color var(--t-base) var(--ease-out);
}

#searchInput::placeholder,
.search-input::placeholder {
  color: var(--text-muted);
}

#searchInput:hover,
.search-input:hover {
  border-color: var(--border-strong);
}

#searchInput:focus,
.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

/* 清除搜索框原生装饰，保持简洁 */
#searchInput::-webkit-search-decoration,
#searchInput::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

/* --------------------------------------------------------------------------
   7. 文章卡片网格 —— 桌面 3 栏 / 平板 2 栏 / 手机 1 栏
   -------------------------------------------------------------------------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(18px, 2.4vw, 28px);
  align-items: stretch;
}

.post-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: transform var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out),
    background-color var(--t-base) var(--ease-out);
}

/* 顶部主色细线：悬浮时展开 */
.post-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-500), var(--accent-300));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--t-slow) var(--ease-out);
  z-index: 2;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-border);
}

.post-card:hover::before {
  transform: scaleX(1);
}

/* 置顶角标 */
.post-card.is-pinned {
  border-color: color-mix(in srgb, var(--accent-500) 42%, var(--border));
}

.post-pin {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, var(--accent-500) 35%, var(--border));
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.post-pin svg {
  width: 12px;
  height: 12px;
}

/* 封面：16:9，悬浮轻微放大 */
.post-cover {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(150deg, var(--brand-200), var(--brand-500));
}

.post-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease-out), filter var(--t-base) var(--ease-out);
}

.post-card:hover .post-cover img {
  transform: scale(1.045);
}

/* 封面为空时的纹理占位（JS 不渲染空封面，这里作为兜底） */
.post-cover--placeholder {
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(255, 255, 255, 0.34), transparent 55%),
    linear-gradient(150deg, var(--brand-400), var(--brand-700));
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

/* 卡片内容 */
.post-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 10px;
  padding: 20px 22px 22px;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out);
}

a.post-tag:hover {
  background: var(--brand-strong);
  color: var(--text-on-brand);
  border-color: var(--brand-strong);
}

/* 卡片标题：链接铺满整卡（用 ::after 覆盖，保证整卡可点） */
.post-card h3,
.post-title-card {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19.5px;
  font-weight: 700;
  line-height: 1.45;
  letter-spacing: -0.005em;
}

.post-card h3 a,
.post-title-card a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out);
  /* 背景渐变下划线，悬浮出现 */
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1.5px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: color var(--t-fast) var(--ease-out),
    background-size var(--t-base) var(--ease-out);
}

.post-card:hover h3 a,
.post-card h3 a:hover {
  color: var(--brand-strong);
  background-size: 100% 1.5px;
}

/* 让整个卡片可点击 */
.post-card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* 但标签/置顶等内部可点元素要浮在链接覆盖层之上。
   这里只提升层级，不能写 position: relative —— 否则会把 .post-pin 的绝对定位改成相对定位。
   选择器用 .post-card .post-pin 以保证优先级高于 .post-pin 本身，定位规则不会被覆盖。 */
.post-card .post-tag {
  position: relative;
  z-index: 2;
}

.post-card .post-pin {
  position: absolute;
  z-index: 3;
}

.post-summary {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.75;
  /* 摘要限制 3 行 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  color: var(--text-muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.post-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: currentColor;
  opacity: 0.5;
}

.post-meta time {
  font-variant-numeric: tabular-nums;
}

.read-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* flex 子项默认 stretch，SVG 会被拉成小方块并显得像加粗，
   这里固定尺寸并禁止收缩 */
.read-time svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  opacity: 0.8;
}

/* --------------------------------------------------------------------------
   8. 骨架屏与空状态
   -------------------------------------------------------------------------- */
.skeleton {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(18px, 2.4vw, 28px);
}

.skeleton-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  overflow: hidden;
  padding: 0 0 22px;
}

.skeleton-block {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 25%,
    color-mix(in srgb, var(--bg-subtle) 40%, var(--bg-elevated)) 37%,
    var(--bg-subtle) 63%
  );
  background-size: 400% 100%;
  animation: skeleton-shine 1.4s ease-in-out infinite;
}

.skeleton-cover {
  aspect-ratio: 16 / 9;
  margin-bottom: 20px;
}

.skeleton-line {
  height: 12px;
  margin: 0 22px 12px;
  border-radius: var(--radius-pill);
}

.skeleton-line.is-title {
  height: 18px;
  width: 62%;
}

.skeleton-line.is-short {
  width: 38%;
}

@keyframes skeleton-shine {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: clamp(40px, 7vw, 76px) 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-subtle) 45%, transparent);
  text-align: center;
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  box-shadow: var(--shadow-xs);
}

.empty-state .empty-icon svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
}

.empty-state p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14.5px;
  max-width: 40ch;
}

/* --------------------------------------------------------------------------
   9. 文章详情页
   -------------------------------------------------------------------------- */
.post-page {
  padding-top: clamp(28px, 5vw, 56px);
}

.article-shell {
  max-width: var(--container-narrow);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* 顶部返回链接 */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 14px;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out);
}

.back-link:hover {
  color: var(--brand);
  transform: translateX(-3px);
}

.back-link svg {
  width: 15px;
  height: 15px;
}

.post-header {
  padding-bottom: 26px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.post-title {
  margin: 14px 0 16px;
  font-family: var(--font-serif);
  font-size: clamp(27px, 4.4vw, 42px);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -0.015em;
  color: var(--text);
}

.post-lead {
  margin: 0 0 18px;
  color: var(--text-secondary);
  font-size: 16.5px;
  line-height: 1.8;
}

.post-tags--header {
  margin-bottom: 16px;
}

/* 元信息：日期 / 阅读时长 / 作者 */
.post-meta-detail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.post-meta-detail .avatar-xs {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: linear-gradient(150deg, var(--brand-400), var(--brand-700));
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
}

.post-meta-detail .avatar-xs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 文章封面 */
.post-hero-cover {
  margin: 0 0 34px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  aspect-ratio: 16 / 8;
  background: var(--bg-subtle);
}

.post-hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* —— 正文排版（prose） —— */
.prose {
  color: var(--text);
  font-size: 17px;
  line-height: 1.92;
  letter-spacing: 0.01em;
  overflow-wrap: break-word;
}

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

.prose > *:last-child {
  margin-bottom: 0;
}

.prose p {
  margin: 0 0 1.35em;
}

.prose h2 {
  position: relative;
  margin: 2.4em 0 0.85em;
  padding-bottom: 0.4em;
  font-family: var(--font-serif);
  font-size: 1.5em;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.prose h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 34px;
  height: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand-500), var(--accent-300));
}

.prose h3 {
  margin: 1.9em 0 0.7em;
  font-size: 1.22em;
  font-weight: 700;
}

.prose h4 {
  margin: 1.6em 0 0.6em;
  font-size: 1.06em;
  font-weight: 700;
  color: var(--text-secondary);
}

.prose ul,
.prose ol {
  margin: 0 0 1.35em;
  padding-left: 1.5em;
}

.prose li {
  margin-bottom: 0.5em;
}

.prose li::marker {
  color: var(--brand);
  font-weight: 600;
}

.prose ul ul,
.prose ol ol,
.prose ul ol,
.prose ol ul {
  margin: 0.5em 0 0.5em;
}

.prose a {
  color: var(--brand);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent);
  text-underline-offset: 3px;
  border-radius: 2px;
  transition: background-color var(--t-fast) var(--ease-out),
    text-decoration-color var(--t-fast) var(--ease-out);
}

.prose a:hover {
  background: var(--brand-soft);
  text-decoration-color: currentColor;
}

.prose strong {
  font-weight: 700;
  color: var(--text);
}

.prose em {
  font-style: italic;
}

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

/* 行内代码 */
.prose :not(pre) > code {
  padding: 0.16em 0.44em;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-code);
  color: var(--brand-strong);
  font-family: var(--font-mono);
  font-size: 0.875em;
  white-space: break-spaces;
  transition: background-color var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out);
}

/* 代码块容器（markdown.js 可能输出 <pre><code>，也可能包一层 .code-block） */
.prose pre,
.prose .code-block {
  position: relative;
  margin: 0 0 1.6em;
  padding: 20px 22px;
  border-radius: var(--radius-md);
  background: var(--bg-code-block);
  color: var(--code-text);
  border: 1px solid color-mix(in srgb, var(--brand-700) 45%, transparent);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.prose pre code,
.prose .code-block code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre;
  overflow-wrap: normal;
}

/* 代码块语言标签 */
.prose pre[data-lang]::before,
.prose .code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(215, 230, 221, 0.42);
  pointer-events: none;
}

.prose pre::-webkit-scrollbar {
  height: 8px;
}

.prose pre::-webkit-scrollbar-track {
  background: transparent;
}

.prose pre::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-pill);
}

/* 引用块 */
.prose blockquote {
  position: relative;
  margin: 0 0 1.6em;
  padding: 18px 22px 18px 24px;
  border-left: 3px solid var(--brand-400);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: color-mix(in srgb, var(--brand-soft) 70%, transparent);
  color: var(--text-secondary);
  font-size: 0.98em;
}

.prose blockquote::before {
  content: "\201C";
  position: absolute;
  right: 16px;
  top: -6px;
  font-family: var(--font-serif);
  font-size: 56px;
  line-height: 1;
  color: color-mix(in srgb, var(--brand) 20%, transparent);
  pointer-events: none;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

/* 表格 */
.prose table {
  width: 100%;
  margin: 0 0 1.6em;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 14.5px;
}

.prose thead {
  background: var(--bg-subtle);
}

.prose th,
.prose td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.prose th {
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}

.prose tbody tr:last-child td {
  border-bottom: 0;
}

.prose tbody tr {
  transition: background-color var(--t-fast) var(--ease-out);
}

.prose tbody tr:hover {
  background: var(--bg-hover);
}

/* 表格在窄屏可横向滚动 */
.prose .table-wrap {
  overflow-x: auto;
}

.prose img {
  margin: 0.6em 0 1.6em;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.prose figcaption {
  margin-top: -1.1em;
  margin-bottom: 1.6em;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.prose hr {
  margin: 2.6em 0;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}

.prose kbd {
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 0.82em;
}

/* 文章底部 */
.post-footer {
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.post-footer .post-tags {
  gap: 8px;
}

/* 上一篇 / 下一篇 */
.post-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 32px;
}

.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  text-decoration: none;
  transition: border-color var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
}

.post-nav a:hover {
  border-color: var(--brand-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.post-nav .post-nav-label {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.post-nav .post-nav-title {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 650;
  color: var(--text);
  line-height: 1.5;
}

.post-nav .is-next {
  text-align: right;
}

/* --------------------------------------------------------------------------
   10. 后台编辑器
   -------------------------------------------------------------------------- */
.admin-page {
  padding-top: clamp(24px, 4vw, 44px);
}

/* —— 登录卡片 —— */
.login-wrap {
  min-height: calc(100vh - var(--header-h) - 120px);
  display: grid;
  place-items: center;
  padding: 32px var(--gutter);
}

.login-card {
  width: min(100%, 420px);
  padding: clamp(26px, 4vw, 38px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.login-card h1,
.login-card h2 {
  margin-bottom: 6px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
}

.login-card .login-desc {
  margin: 0 0 26px;
  color: var(--text-muted);
  font-size: 14px;
}

/* —— 表单控件（后台与全局共用） —— */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.field .field-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="url"],
.field input[type="search"],
.field input:not([type]),
.field select,
.field textarea,
.input,
.textarea,
.select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  transition: border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out), background-color var(--t-base) var(--ease-out);
}

.field input::placeholder,
.field textarea::placeholder,
.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.field input:hover,
.field select:hover,
.field textarea:hover,
.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--border-strong);
}

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

.field textarea,
.textarea {
  resize: vertical;
  min-height: 96px;
  font-family: inherit;
}

/* markdown 正文编辑框用等宽字体 */
#content,
.textarea--code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  min-height: 320px;
  tab-size: 2;
}

/* 下拉框箭头 */
.field select,
.select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e9799' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}

/* 复选框 */
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 2px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--text-secondary);
}

.checkbox input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  flex: none;
  margin: 0;
  border: 1.5px solid var(--border-input);
  border-radius: 5px;
  background: var(--bg-elevated);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
}

.checkbox input[type="checkbox"]:checked {
  background-color: var(--brand);
  border-color: var(--brand);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.checkbox input[type="checkbox"]:focus-visible {
  box-shadow: var(--ring);
  outline: none;
}

/* —— 按钮 —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--brand-strong);
  color: var(--text-on-brand);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease-out),
    transform var(--t-fast) var(--ease-out), box-shadow var(--t-base) var(--ease-out),
    color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out),
    opacity var(--t-fast) var(--ease-out);
}

.btn:hover {
  color: var(--text-on-brand);
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand) 80%, transparent);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.985);
}

.btn:disabled,
.btn[disabled],
.btn.is-loading {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn--primary {
  background: var(--brand-strong);
  color: var(--text-on-brand);
}

html[data-theme="dark"] .btn--primary {
  background: var(--brand);
  color: #0b1310;
}

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

.btn--ghost:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  background: var(--brand-soft);
  box-shadow: none;
}

.btn--outline {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.btn--outline:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  box-shadow: var(--shadow-sm);
}

.btn--danger {
  background: transparent;
  border-color: color-mix(in srgb, #c0392b 45%, var(--border));
  color: #b3342a;
}

.btn--danger:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(192, 57, 43, 0.8);
}

html[data-theme="dark"] .btn--danger {
  color: #e8837a;
  border-color: rgba(232, 131, 122, 0.4);
}

.btn--sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn--lg {
  padding: 13px 26px;
  font-size: 15.5px;
}

.btn--block {
  width: 100%;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* 按钮内加载转圈 */
.btn .spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-pill);
  animation: spin 640ms linear infinite;
  flex: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* —— 登录错误提示 —— */
#loginError,
.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 13px;
  border: 1px solid color-mix(in srgb, #c0392b 32%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #c0392b 8%, var(--bg-elevated));
  color: #b3342a;
  font-size: 13.5px;
  line-height: 1.6;
}

html[data-theme="dark"] #loginError,
html[data-theme="dark"] .form-error {
  color: #ee9a92;
  background: rgba(192, 57, 43, 0.12);
}

#loginError:empty {
  display: none;
}

#loginError[hidden] {
  display: none !important;
}

/* —— 后台主面板：左列表 + 右编辑器 —— */
.admin-shell {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: clamp(16px, 2.4vw, 26px);
  align-items: start;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.panel-head .admin-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.panel-head .admin-user-name {
  color: var(--text-secondary);
  font-weight: 600;
}

.panel-body {
  padding: 18px;
}

.panel--list {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 32px);
  display: flex;
  flex-direction: column;
}

.panel--list .panel-body {
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
}

/* —— 后台文章列表 —— */
.admin-post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-post-item,
.admin-post-list > li {
  border-radius: var(--radius-sm);
  transition: background-color var(--t-fast) var(--ease-out);
}

.admin-post-item:hover {
  background: var(--bg-hover);
}

.admin-post-item.is-active {
  background: var(--brand-soft);
  box-shadow: inset 2px 0 0 var(--brand);
}

.admin-post-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-post-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.admin-post-actions {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
}

/* 状态徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.8;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: currentColor;
}

.badge--published {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: var(--brand-border);
}

.badge--draft {
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-color: var(--border);
}

.badge--pinned {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-500) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent-500) 32%, transparent);
}

/* —— 编辑器表单 —— */
.editor-panel .panel-body {
  padding: clamp(18px, 2.6vw, 28px);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-actions .spacer {
  flex: 1 1 auto;
}

/* 保存状态提示（#formStatus，可选元素） */
.form-status {
  font-size: 13px;
  color: var(--text-muted);
  transition: color var(--t-fast) var(--ease-out);
}

.form-status.is-ok {
  color: var(--brand);
}

.form-status.is-error {
  color: #b3342a;
  font-weight: 600;
}

html[data-theme="dark"] .form-status.is-error {
  color: #ee9a92;
}

/* 封面选择带缩略图 */
.cover-picker {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cover-picker .input {
  flex: 1 1 auto;
  min-width: 0;
}

.cover-preview {
  margin-top: 10px;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-subtle);
}

.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 文件选择按钮：把原生 input 藏起来，用 label 触发 */
.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease-out),
    border-color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out);
}

.file-btn:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  background: var(--brand-soft);
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* 实时预览区域：复用正文排版，但字号略小、无外框感 */
.preview-pane {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--bg-subtle) 42%, transparent);
  overflow: hidden;
}

.preview-pane .preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.preview-pane .preview-body {
  padding: 22px 24px;
  max-height: 560px;
  overflow-y: auto;
  font-size: 15.5px;
  line-height: 1.85;
  scrollbar-width: thin;
}

#preview:empty::before,
.preview-body:empty::before {
  content: "在左侧文本框输入 markdown，这里会实时预览。";
  color: var(--text-muted);
  font-size: 14px;
}

/* --------------------------------------------------------------------------
   10b. 后台页兼容层
   --------------------------------------------------------------------------
   admin.html 使用了一套不带 `--` 的类名（btn-primary / admin-grid / field-grow …），
   与上面的组件类名不同。这里把两套名字映射到同一套设计令牌上，
   这样无论 HTML 用哪种写法都能得到一致的观感。
   -------------------------------------------------------------------------- */

/* —— 顶栏右侧 —— */
.admin-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}

.admin-header-right .nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast) var(--ease-out),
    background-color var(--t-fast) var(--ease-out);
}

.admin-header-right .nav-link:hover {
  color: var(--brand);
  background: var(--bg-hover);
}

.admin-user {
  color: var(--text-muted);
  font-size: 13px;
}

.admin-user:not(:empty)::before {
  content: "☺ ";
  opacity: 0.6;
}

/* —— 主区域容器 —— */
.admin-main {
  padding: clamp(20px, 3vw, 36px) 0 clamp(48px, 6vw, 80px);
  min-height: calc(100vh - var(--header-h));
}

/* —— 登录卡片 —— */
.login-wrap {
  display: grid;
  place-items: center;
  padding: clamp(24px, 6vw, 64px) 0;
}

.login-card {
  width: min(100%, 420px);
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(150deg, var(--brand-400), var(--brand-700));
  color: var(--text-on-brand);
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.login-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0 0 26px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form .field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.login-hint {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.7;
}

/* —— 后台主栅格：左列表 + 右编辑器 —— */
.admin-panel {
  animation: fade-up var(--t-slow) var(--ease-out);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(248px, 316px) minmax(0, 1fr);
  gap: clamp(16px, 2.2vw, 24px);
  align-items: start;
}

.admin-sidebar,
.admin-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.admin-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 16px);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h) - 32px);
}

.admin-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}

.admin-sidebar-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.admin-sidebar .admin-post-list {
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  scrollbar-width: thin;
}

.admin-list-placeholder {
  margin: 0;
  padding: 22px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* 编辑器头部 */
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}

.editor-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
}

.editor-head-actions {
  display: flex;
  gap: 8px;
}

/* —— 后台表单布局 —— */
.post-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(16px, 2.4vw, 24px);
}

.form-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row .field {
  flex: 0 1 auto;
  min-width: 0;
}

.form-row .field-grow {
  flex: 1 1 220px;
}

/* 表单里的 label.field 是纵向栈（label 包住 span + input） */
.post-form .field,
.admin-grid .field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.post-form .field > input,
.post-form .field > select,
.post-form .field > textarea {
  width: 100%;
}

/* 复选框字段：横向 */
.admin-grid .field-check {
  flex-direction: row;
  align-items: center;
  gap: 9px;
  align-self: flex-end;
  min-height: 44px;
  padding: 0 4px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.admin-grid .field-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* 必填星号 */
.req {
  color: var(--accent-600);
  font-style: normal;
  font-weight: 700;
}

.field-label .field-hint {
  display: block;
  margin-top: 2px;
}

/* 封面上传行 */
.cover-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.cover-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.upload-btn {
  position: relative;
  flex: none;
  cursor: pointer;
}

.cover-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.cover-preview img {
  width: 132px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
}

/* —— 正文 编辑 + 预览 双栏 —— */
.editor-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.md-input {
  width: 100%;
  min-height: 460px;
  padding: 14px 16px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.75;
  resize: vertical;
  tab-size: 2;
  transition: border-color var(--t-fast) var(--ease-out),
    box-shadow var(--t-fast) var(--ease-out);
}

.md-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.md-preview-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-subtle) 42%, transparent);
  overflow: hidden;
}

.md-preview-label {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex: none;
}

.md-preview {
  flex: 1 1 auto;
  max-height: 460px;
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.8;
  scrollbar-width: thin;
}

.md-preview:empty::before {
  content: "在左侧输入 Markdown，这里会实时预览。";
  color: var(--text-muted);
  font-size: 13.5px;
}

/* 预览里的标题字号缩一档，避免在窄栏里过大 */
.md-preview h1 { font-size: 1.5em; }
.md-preview h2 { font-size: 1.3em; margin-top: 1.6em; }
.md-preview h3 { font-size: 1.12em; margin-top: 1.3em; }

/* —— 按钮兼容名：btn-primary / btn-ghost / btn-danger / btn-sm / btn-block —— */
.btn-primary {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: var(--text-on-brand);
}

html[data-theme="dark"] .btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #0b1310;
}

.btn-primary:hover {
  color: var(--text-on-brand);
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--brand) 80%, transparent);
}

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

.btn-ghost:hover {
  color: var(--brand);
  border-color: var(--brand-border);
  background: var(--brand-soft);
  box-shadow: none;
}

.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, #c0392b 45%, var(--border));
  color: #b3342a;
}

.btn-danger:hover {
  background: #c0392b;
  border-color: #c0392b;
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(192, 57, 43, 0.8);
}

html[data-theme="dark"] .btn-danger {
  color: #e8837a;
  border-color: rgba(232, 131, 122, 0.4);
}

.btn-sm {
  padding: 6px 13px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* 文件选择器在 upload-btn 里是 display:none 的隐藏 input，
   由父 label 承担点击，不需要再撑满 */

/* —— 后台响应式 —— */
@media (max-width: 1024px) {
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-sidebar {
    position: static;
    max-height: none;
  }

  .admin-sidebar .admin-post-list {
    max-height: 320px;
  }

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

  .md-preview {
    max-height: 360px;
  }
}

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

  .post-form {
    padding: 14px;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-grid .field-check {
    align-self: flex-start;
  }

  .cover-row {
    flex-wrap: wrap;
  }

  .cover-preview {
    flex-wrap: wrap;
  }

  .cover-preview img {
    width: 100%;
  }

  .form-actions .btn {
    flex: 1 1 auto;
  }
}

/* --------------------------------------------------------------------------
   11. 通用组件：Toast / 关于区块 / 归档
   -------------------------------------------------------------------------- */
#toast {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  right: clamp(12px, 2.4vw, 24px);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  /* 入场：JS 先加 .is-entering 再切到默认态 */
  transform: translateX(0) scale(1);
  opacity: 1;
  transition: opacity var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out);
}

.toast.is-entering {
  opacity: 0;
  transform: translateX(14px) scale(0.97);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateX(18px) scale(0.96);
}

.toast .toast-icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
}

.toast .toast-icon svg {
  width: 49%;
  height: 49%;
  color: #fff;
}

.toast .toast-body {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast .toast-close {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease-out),
    color var(--t-fast) var(--ease-out);
}

.toast .toast-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* 成功（默认） */
.toast .toast-icon {
  background: var(--brand);
}

/* 错误 */
.toast.is-error {
  border-color: color-mix(in srgb, #c0392b 38%, var(--border));
}

.toast.is-error .toast-icon {
  background: #c0392b;
}

/* 提示 */
.toast.is-info .toast-icon {
  background: var(--accent-500);
}

/* —— 关于区块 —— */
.about-section {
  margin-top: clamp(48px, 8vw, 96px);
  padding-top: clamp(30px, 5vw, 52px);
  border-top: 1px solid var(--border);
}

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: start;
}

.about-bio {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.95;
  margin: 0;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

/* —— 归档（时间线） —— */
.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.archive-list::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--border);
}

.archive-item {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 0 0 18px 30px;
}

.archive-item::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 11px;
  height: 11px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--brand);
  background: var(--bg);
  transition: transform var(--t-base) var(--ease-out),
    background-color var(--t-base) var(--ease-out);
}

.archive-item:hover::before {
  transform: scale(1.25);
  background: var(--brand);
}

.archive-date {
  flex: none;
  width: 88px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
  padding-top: 2px;
}

.archive-title {
  color: var(--text);
  font-size: 15px;
  text-decoration: none;
  transition: color var(--t-fast) var(--ease-out);
}

.archive-title:hover {
  color: var(--brand);
}

/* --------------------------------------------------------------------------
   12. 入场动画与响应式
   -------------------------------------------------------------------------- */

/* 入场淡入：由 IntersectionObserver 加 .is-visible */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--t-slow) var(--ease-out),
    transform var(--t-slow) var(--ease-out);
  will-change: opacity, transform;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* 没有 JS 时不能把内容藏死：html.no-js 由 app.js 在最早移除，
   同时也用 .js-enabled 兜底：只有脚本确认自己能跑才允许隐藏 */
html:not(.js-enabled) .reveal {
  opacity: 1;
  transform: none;
}

/* —— 终极兜底：入场动画绝不能导致内容永久不可见 ——
   若 IntersectionObserver 不可用 / 观察器异常 / 脚本提前中断，
   html 会被加上 .reveal-fallback，此时强制显示全部内容。
   （由 assets/app.js 的看门狗与 assets/fallback.css 逻辑共同保证） */
html.reveal-fallback .reveal {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

/* 卡片错峰入场延迟 */
.post-grid .reveal:nth-child(2) { transition-delay: 40ms; }
.post-grid .reveal:nth-child(3) { transition-delay: 80ms; }
.post-grid .reveal:nth-child(4) { transition-delay: 120ms; }
.post-grid .reveal:nth-child(5) { transition-delay: 160ms; }
.post-grid .reveal:nth-child(6) { transition-delay: 200ms; }
.post-grid .reveal:nth-child(n + 7) { transition-delay: 240ms; }

/* —— 平板：2 栏 —— */
@media (max-width: 1024px) {
  .post-grid,
  .skeleton {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-inner {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 32px;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

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

  .panel--list {
    position: static;
    max-height: none;
  }

  .panel--list .panel-body {
    max-height: 340px;
  }
}

/* —— 移动端：1 栏 + 抽屉导航 —— */
@media (max-width: 768px) {
  :root {
    --header-h: 60px;
  }

  body {
    font-size: 15.5px;
    line-height: 1.72;
  }

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

  /* 汉堡按钮出现 */
  #navToggle {
    display: inline-flex;
  }

  /* 导航变成下拉抽屉 */
  .site-nav {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--header-h);
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 12px var(--gutter) 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    /* 收回状态 */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity var(--t-base) var(--ease-out),
      transform var(--t-base) var(--ease-out), visibility var(--t-base);
  }

  .site-nav.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .site-nav a {
    padding: 12px 14px;
    font-size: 16px;
    border-radius: var(--radius-sm);
  }

  .site-nav a.is-active::after,
  .site-nav a[aria-current="page"]::after {
    left: 14px;
    right: auto;
    bottom: 50%;
    width: 3px;
    height: 16px;
    transform: translateY(50%);
  }

  .site-nav .nav-cta {
    margin-top: 8px;
    text-align: center;
    background: var(--brand-strong);
    color: var(--text-on-brand);
    font-weight: 600;
  }

  .site-nav .nav-cta:hover {
    background: var(--brand-700);
    color: var(--text-on-brand);
  }

  /* Hero 单列 */
  .hero {
    padding-top: 32px;
  }

  .hero-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .hero-side {
    order: -1;
    justify-content: flex-start;
  }

  .avatar-card {
    width: 168px;
    transform: none;
  }

  .avatar {
    font-size: 34px;
  }

  .avatar-caption {
    padding: 10px 4px 0;
    font-size: 12.5px;
  }

  .hero-actions .btn {
    flex: 1 1 auto;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 18px;
  }

  .stat-value {
    font-size: 22px;
  }

  .stat-label {
    margin-top: 0;
  }

  /* 工具栏纵向 */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
  }

  .search-wrap {
    flex: 1 1 auto;
    width: 100%;
  }

  /* 标签横向滚动，避免换行堆高 */
  .tag-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .tag-list::-webkit-scrollbar {
    display: none;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* 详情页 */
  .post-page {
    padding-top: 24px;
  }

  .prose {
    font-size: 16px;
    line-height: 1.86;
  }

  .prose pre,
  .prose .code-block {
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-left: calc(var(--gutter) * -0.5);
    margin-right: calc(var(--gutter) * -0.5);
  }

  .prose table {
    font-size: 13.5px;
  }

  .post-nav {
    grid-template-columns: 1fr;
  }

  .post-nav .is-next {
    text-align: left;
  }

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

  /* 后台：表单单列 */
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-shell {
    gap: 14px;
  }

  .form-actions {
    gap: 8px;
  }

  .form-actions .btn {
    flex: 1 1 auto;
  }

  .form-actions .spacer {
    display: none;
  }

  /* Toast 移到顶部居中、占满宽度 */
  #toast {
    left: 12px;
    right: 12px;
    width: auto;
    top: calc(var(--header-h) + 8px);
  }

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

  #backToTop {
    width: 42px;
    height: 42px;
  }
}

/* —— 超小屏 —— */
@media (max-width: 420px) {
  .hero-title {
    font-size: 30px;
  }

  .post-body {
    padding: 16px 17px 18px;
  }

  .post-card h3 {
    font-size: 18px;
  }

  .login-card {
    padding: 24px 20px;
  }
}

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

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

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .post-card:hover {
    transform: none;
  }

  .post-card:hover .post-cover img,
  .site-brand:hover::before,
  .avatar-card:hover {
    transform: none;
  }

  #backToTop:hover {
    transform: none;
  }
}

/* —— 打印：只留正文 —— */
@media print {
  .site-header,
  .site-footer,
  #backToTop,
  #readingProgress,
  #toast,
  .post-nav,
  .toolbar,
  .hero-actions,
  .back-link {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000;
  }

  .prose {
    font-size: 12pt;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .prose pre,
  .prose .code-block {
    background: #f5f5f5 !important;
    color: #111 !important;
    border: 1px solid #ddd;
  }

  .prose pre code {
    color: #111 !important;
  }
}
