/* ==========================================================================
   小勋 · 个人站
   零依赖静态站点 · 样式表
   配色参考 Docusaurus / Infima，支持浅色、深色与跟随系统
   ========================================================================== */

/* ---------- 1. 设计变量 ---------- */
:root {
  color-scheme: light;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --navbar-h: 3.75rem;
  --shell-max: 1440px;
  --sidebar-w: 300px;
  --toc-w: 236px;

  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --text: #1c1e21;
  --text-soft: #4a5058;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d0d7de;

  --primary: #2e8555;
  --primary-hover: #29784c;
  --primary-soft: rgba(46, 133, 85, 0.1);
  --primary-contrast: #ffffff;

  --info: #2563eb;
  --info-soft: rgba(37, 99, 235, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.1);

  --code-bg: #f6f8fa;
  --code-border: #e5e7eb;
  --mark-bg: #fff3bf;
  --mark-text: #1c1e21;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 8px 24px -8px rgba(16, 24, 40, 0.18);
  --shadow-lg: 0 24px 64px -20px rgba(16, 24, 40, 0.4);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #1b1b1d;
  --bg-subtle: #151516;
  --surface: #242526;
  --surface-2: #2c2d2f;
  --text: #e3e3e3;
  --text-soft: #c6c7c9;
  --text-muted: #9a9ca1;
  --border: #333436;
  --border-strong: #444950;

  --primary: #25c2a0;
  --primary-hover: #4ad8b9;
  --primary-soft: rgba(37, 194, 160, 0.14);
  --primary-contrast: #08221c;

  --info: #7aa2ff;
  --info-soft: rgba(122, 162, 255, 0.14);
  --warn: #f0b429;
  --warn-soft: rgba(240, 180, 41, 0.14);

  --code-bg: #161617;
  --code-border: #2f3032;
  --mark-bg: #5a4a00;
  --mark-text: #fff8d6;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 28px -10px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 28px 70px -24px rgba(0, 0, 0, 0.85);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--navbar-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 300;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 600;
  transform: translateY(-150%);
  transition: transform 0.15s ease;
}

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

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

/* ---------- 3. 顶部导航 ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 160;
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .navbar {
    background: var(--bg);
  }
}

.navbar__inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

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

.brand__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #1f6b45);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

html[data-theme="dark"] .brand__mark {
  background: linear-gradient(135deg, #25c2a0, #12876f);
  color: #06231d;
}

.brand__name {
  font-size: 1.05rem;
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.navbar__links a {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 500;
}

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

.navbar__links a[aria-current="page"] {
  color: var(--primary);
  background: var(--primary-soft);
}

.navbar__spacer {
  flex: 1;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

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

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

.menu-toggle {
  display: none;
}

.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.3rem;
  padding: 0 0.5rem 0 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

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

.search-btn svg {
  width: 16px;
  height: 16px;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1;
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
}

/* 主题菜单 */
.theme-wrap {
  position: relative;
}

.theme-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 200;
  min-width: 10.5rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  display: none;
}

.theme-menu[data-open="true"] {
  display: block;
  animation: pop 0.14s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.theme-menu button:hover {
  background: var(--surface-2);
}

.theme-menu button[aria-checked="true"] {
  color: var(--primary);
  font-weight: 600;
}

.theme-menu button svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.theme-menu .check {
  margin-left: auto;
  opacity: 0;
  font-size: 0.85rem;
}

.theme-menu button[aria-checked="true"] .check {
  opacity: 1;
}

html[data-theme="light"] .only-dark,
html[data-theme="dark"] .only-light {
  display: none;
}

/* ---------- 4. 布局骨架 ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  flex: 1;
}

.sidebar {
  position: sticky;
  top: var(--navbar-h);
  align-self: start;
  height: calc(100vh - var(--navbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.5rem 1rem 3rem 1.25rem;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}

.main {
  min-width: 0;
  padding: 2.25rem 2.5rem 4rem;
}

.doc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 3rem;
  max-width: 1180px;
}

.doc--wide {
  grid-template-columns: minmax(0, 1fr);
  max-width: 1080px;
}

/* ---------- 5. 侧边栏菜单 ---------- */
.menu {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.92rem;
}

.menu__link {
  display: block;
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  color: var(--text-soft);
  line-height: 1.5;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.menu__link.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.menu__group {
  margin: 0.15rem 0;
}

.menu__group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

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

.menu__group > summary:hover {
  background: var(--surface-2);
}

.menu__group > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
}

.menu__group[open] > summary::after {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.menu__group-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.15rem 0 0.35rem 0.85rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--border);
}

.menu__group-body .menu__link {
  font-size: 0.88rem;
  padding: 0.34rem 0.6rem;
}

.sidebar__note {
  margin: 1.75rem 0.25rem 0;
  padding: 0.85rem 0.9rem;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.sidebar__note strong {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--text-soft);
  font-size: 0.8rem;
}

/* ---------- 6. 正文排版 ---------- */
.prose {
  min-width: 0;
  font-size: 1rem;
  line-height: 1.78;
}

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

.prose h1 {
  margin: 0 0 0.75rem;
  font-size: 2.1rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.prose h2 {
  position: relative;
  margin: 3rem 0 1rem;
  font-size: 1.5rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.prose h3 {
  position: relative;
  margin: 2rem 0 0.6rem;
  font-size: 1.18rem;
  font-weight: 700;
}

.prose h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.prose p {
  margin: 0 0 1.15rem;
}

.prose strong {
  font-weight: 700;
}

.prose ul,
.prose ol {
  margin: 0 0 1.15rem;
  padding-left: 1.4rem;
}

.prose li {
  margin: 0.3rem 0;
}

.prose li > ul,
.prose li > ol {
  margin: 0.3rem 0;
}

.prose hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.anchor {
  margin-left: 0.4rem;
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

h2:hover .anchor,
h3:hover .anchor,
.anchor:focus {
  opacity: 1;
}

.anchor:hover {
  color: var(--primary);
  text-decoration: none;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.9rem 1.15rem;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-subtle);
  color: var(--text-soft);
}

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

.prose table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.prose th,
.prose td {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.prose tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--bg-subtle) 55%, transparent);
}

/* 行内代码与代码块 */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.36em;
  border: 1px solid var(--code-border);
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--text);
  word-break: break-word;
}

.prose pre {
  position: relative;
  margin: 1.5rem 0;
  padding: 1.1rem 1.15rem;
  overflow-x: auto;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  font-size: 0.86rem;
  line-height: 1.65;
  tab-size: 2;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  color: inherit;
  word-break: normal;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--code-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

pre:hover .copy-btn,
.copy-btn:focus {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--primary);
}

.copy-btn[data-copied="true"] {
  color: var(--primary);
  opacity: 1;
}

/* 提示块 */
.callout {
  display: flex;
  gap: 0.7rem;
  margin: 1.5rem 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  font-size: 0.94rem;
}

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

.callout__icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.6;
}

.callout--info {
  border-color: var(--info-soft);
  border-left-color: var(--info);
  background: var(--info-soft);
}

.callout--warn {
  border-color: var(--warn-soft);
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

/* ---------- 7. 面包屑 / 页脚信息 ---------- */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.breadcrumbs a:hover {
  color: var(--primary);
}

.breadcrumbs span[aria-hidden="true"] {
  opacity: 0.55;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.page-updated {
  margin: 3rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- 8. 首页 hero ---------- */
.hero {
  position: relative;
  padding: 1.5rem 0 0.5rem;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -3rem 0 auto 0;
  height: 17rem;
  background: radial-gradient(70% 100% at 12% 0%, var(--primary-soft), transparent 72%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero__top {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.1rem;
}

.avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--border);
  flex-shrink: 0;
  background: var(--surface-2);
}

.eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
}

.hero__title {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 800;
}

.hero__subtitle {
  max-width: 52ch;
  margin: 0 0 1.4rem;
  font-size: 1.06rem;
  color: var(--text-soft);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2.25rem;
}

/* ---------- 9. 按钮 ---------- */
.button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease,
    transform 0.15s ease, box-shadow 0.15s ease;
}

.button:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.button--primary {
  border-color: transparent;
  background: var(--primary);
  color: var(--primary-contrast);
}

.button--primary:hover {
  border-color: transparent;
  background: var(--primary-hover);
  color: var(--primary-contrast);
}

.button--ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
}

.button svg {
  width: 16px;
  height: 16px;
}

/* ---------- 10. 卡片与列表 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.75rem 0 1rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.section-head a {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.post-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.post-item {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s ease;
}

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

.post-item__main {
  min-width: 0;
  flex: 1;
}

.post-item__title {
  display: block;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.post-item:hover .post-item__title {
  color: var(--primary);
}

.post-item__excerpt {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.post-item__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 0.15rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.7;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0;
}

.card {
  padding: 1.2rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.card h3 {
  margin: 0.55rem 0 0.35rem;
  font-size: 1.02rem;
  font-weight: 700;
}

.card p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.card__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
}

.card__icon svg {
  width: 20px;
  height: 20px;
}

/* 项目卡片 */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1.1rem;
  margin: 1.5rem 0 2rem;
}

.project {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.project:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.project__thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 8.5;
  color: #fff;
  background: linear-gradient(135deg, #2e8555, #14532d);
  overflow: hidden;
}

.project__thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 0.55;
}

.project__thumb svg {
  width: 42px;
  height: 42px;
  position: relative;
  z-index: 1;
  opacity: 0.95;
}

.project:nth-child(2) .project__thumb {
  background: linear-gradient(135deg, #2563eb, #1e3a8a);
}

.project:nth-child(3) .project__thumb {
  background: linear-gradient(135deg, #b45309, #7c2d12);
}

.project:nth-child(4) .project__thumb {
  background: linear-gradient(135deg, #7c3aed, #4c1d95);
}

.project__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.1rem 1.2rem 1.25rem;
}

.project__body h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.project__body p {
  margin: 0 0 0.9rem;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: auto;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ---------- 11. 关于页 ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.75rem 0 1.5rem;
  padding: 0;
  list-style: none;
}

.chip {
  padding: 0.22rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.83rem;
}

.timeline {
  margin: 1.5rem 0;
  padding: 0 0 0 1.4rem;
  list-style: none;
  border-left: 2px solid var(--border);
}

.timeline li {
  position: relative;
  padding-bottom: 1.4rem;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -1.4rem;
  top: 0.42rem;
  width: 11px;
  height: 11px;
  margin-left: -6.5px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.timeline__when {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--primary);
}

.timeline__what {
  display: block;
  font-weight: 600;
}

.timeline__desc {
  display: block;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin: 1.5rem 0;
}

.contact-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.contact-card:hover {
  border-color: var(--primary);
  text-decoration: none;
  transform: translateY(-2px);
}

.contact-card__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  flex-shrink: 0;
}

.contact-card__icon svg {
  width: 18px;
  height: 18px;
}

.contact-card__label {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.contact-card__value {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  word-break: break-all;
}

/* ---------- 12. 目录 ---------- */
.toc {
  position: sticky;
  top: calc(var(--navbar-h) + 1.75rem);
  align-self: start;
  max-height: calc(100vh - var(--navbar-h) - 3.5rem);
  overflow-y: auto;
  padding-top: 0.25rem;
  font-size: 0.85rem;
}

.toc__title {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.8rem;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  line-height: 1.45;
}

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

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

.toc a.toc--h3 {
  padding-left: 1.5rem;
  font-size: 0.8rem;
}

/* ---------- 13. 上一篇 / 下一篇 ---------- */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
}

.pager__link {
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pager__link:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.pager__link--next {
  grid-column: 2;
  text-align: right;
}

.pager__dir {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.pager__title {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--primary);
}

/* ---------- 14. 页脚 ---------- */
.footer {
  margin-top: auto;
  padding: 2.5rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.86rem;
}

.footer__inner {
  display: grid;
  grid-template-columns: 1.6fr repeat(2, minmax(120px, 1fr));
  gap: 2rem;
  max-width: var(--shell-max);
  margin: 0 auto;
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: var(--text);
}

.footer__desc {
  max-width: 34ch;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.footer h4 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.footer ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer li {
  margin: 0.3rem 0;
}

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

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

.footer__bottom {
  max-width: var(--shell-max);
  margin: 2rem auto 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ---------- 15. 搜索弹层 ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 9vh 1rem 2rem;
  background: rgba(10, 12, 14, 0.55);
  backdrop-filter: blur(3px);
  animation: fade 0.15s ease;
}

/* display:flex 会覆盖 [hidden] 的默认 display:none，必须显式声明 */
.search-overlay[hidden] {
  display: none;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.search-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: 72vh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.search-panel__head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.search-panel__head svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-panel__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  outline: none;
}

.search-panel__input::placeholder {
  color: var(--text-muted);
}

.search-panel__input::-webkit-search-cancel-button,
.search-panel__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

.search-panel__esc {
  font-size: 0.7rem;
}

button.search-panel__esc {
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--text-muted);
}

button.search-panel__esc:hover {
  border-color: var(--primary);
  color: var(--primary);
}

button.search-panel__esc:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.search-results {
  flex: 1;
  margin: 0;
  padding: 0.4rem;
  overflow-y: auto;
  list-style: none;
}

.search-result a {
  display: block;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  color: inherit;
}

.search-result a:hover,
.search-result a[data-active="true"] {
  background: var(--surface-2);
  text-decoration: none;
}

.search-result__group {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.search-result__title {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.search-result__snippet {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result mark {
  padding: 0 0.1em;
  border-radius: 3px;
  background: var(--mark-bg);
  color: var(--mark-text);
}

.search-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.search-foot {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.74rem;
}

.search-foot .kbd {
  margin-right: 0.25rem;
}

/* ---------- 16. 404 ---------- */
.notfound {
  display: grid;
  place-items: center;
  min-height: 55vh;
  text-align: center;
}

.notfound__code {
  margin: 0;
  font-size: clamp(4rem, 14vw, 7rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- 17. 遮罩 ---------- */
.scrim {
  display: none;
}

/* ---------- 18. 响应式 ---------- */
@media (max-width: 1200px) {
  .doc {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .toc {
    display: none;
  }
}

@media (max-width: 996px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    top: var(--navbar-h);
    left: 0;
    bottom: 0;
    z-index: 170;
    width: min(84vw, 320px);
    height: auto;
    padding: 1.25rem 1rem 3rem 1.1rem;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform 0.25s ease;
  }

  body.sidebar-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .scrim {
    position: fixed;
    inset: var(--navbar-h) 0 0;
    z-index: 165;
    background: rgba(0, 0, 0, 0.45);
  }

  body.sidebar-open .scrim {
    display: block;
  }

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

  .navbar__links {
    display: none;
  }

  .main {
    padding: 1.75rem 1.25rem 3rem;
  }

  .brand {
    margin-right: auto;
  }
}

@media (max-width: 720px) {
  .search-btn span:not(.kbd) {
    display: none;
  }

  .search-btn .kbd {
    display: none;
  }

  .search-btn {
    padding: 0 0.55rem;
  }

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

  .footer__brand-col {
    grid-column: 1 / -1;
  }

  .post-item {
    flex-direction: column;
    gap: 0.3rem;
  }

  .post-item__meta {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

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

  .pager__link--next {
    grid-column: 1;
  }

  .prose h1 {
    font-size: 1.75rem;
  }

  .prose h2 {
    font-size: 1.3rem;
    margin-top: 2.25rem;
  }

  .hero__top {
    align-items: flex-start;
  }

  .avatar {
    width: 64px;
    height: 64px;
  }

  .search-overlay {
    padding-top: 4vh;
  }
}

@media (max-width: 460px) {
  .main {
    padding: 1.5rem 1rem 2.5rem;
  }

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

/* ---------- 19. 动效与打印 ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .navbar,
  .sidebar,
  .toc,
  .footer,
  .pager,
  .copy-btn,
  .scrim {
    display: none !important;
  }

  .main {
    padding: 0;
  }

  .shell,
  .doc {
    display: block;
    max-width: none;
  }

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

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