:root {
  --bg: #f5f7fb;
  --bg-elevate: #ffffff;
  --card: #ffffff;
  --text: #26303f;
  --text-soft: #5b6675;
  --text-faint: #8a93a2;
  --border: #e3e7ef;
  --primary: #4b6cf0;
  --primary-dark: #3452d6;
  --primary-soft: rgba(75, 108, 240, 0.1);
  --hero-a: #4b6cf0;
  --hero-b: #7f5af0;
  --shadow: 0 10px 30px rgba(31, 45, 74, 0.08);
  --shadow-hover: 0 16px 40px rgba(31, 45, 74, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --code-bg: #f4f5f7;
  --mark-bg: #ffe9a8;
}

html[data-theme='dark'] {
  --bg: #14181f;
  --bg-elevate: #1b2129;
  --card: #1b2129;
  --text: #e6eaf2;
  --text-soft: #a9b2c0;
  --text-faint: #7e8794;
  --border: #2a323d;
  --primary: #7f9bff;
  --primary-dark: #a5b8ff;
  --primary-soft: rgba(127, 155, 255, 0.16);
  --hero-a: #2f3f8f;
  --hero-b: #4b2f8f;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 16px 40px rgba(0, 0, 0, 0.5);
  --code-bg: #222831;
  --mark-bg: #6b5b1e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Source Han Sans SC', sans-serif;
  font-size: 15.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; display: block; }
mark { background: var(--mark-bg); color: inherit; border-radius: 3px; padding: 0 2px; }

.shell { width: min(1180px, 100% - 40px); margin-inline: auto; }

/* ---------- header ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg-elevate) 88%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.head-inner { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; flex: none; }
.brand-mark, .brand-avatar {
  width: 32px; height: 32px; border-radius: 9px; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: #fff; font-size: 15px;
}
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-item { padding: 7px 12px; border-radius: var(--radius-sm); color: var(--text-soft); font-size: 14.5px; white-space: nowrap; }
.nav-item:hover { color: var(--primary); background: var(--primary-soft); }
.nav-item.is-active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.head-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.head-search { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 14px; }
.head-search input { width: 150px; border: 0; background: none; color: var(--text); font-size: 14px; outline: none; }
.head-search button { border: 0; background: none; color: var(--text-faint); cursor: pointer; display: grid; place-items: center; padding: 4px; }
.head-search button:hover { color: var(--primary); }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elevate); color: var(--text-soft); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.menu-toggle { display: none; }

/* ---------- hero ---------- */
.hero { background: linear-gradient(120deg, var(--hero-a), var(--hero-b)); color: #fff; overflow: hidden; position: relative; }
.hero::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.28), transparent 42%),
              radial-gradient(circle at 12% 88%, rgba(255, 255, 255, 0.14), transparent 46%);
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; padding: 58px 0 52px; }
.hero-title { margin: 0; font-size: clamp(26px, 4.2vw, 40px); line-height: 1.25; letter-spacing: 0.5px; }
.hero-sub { margin: 12px 0 0; opacity: 0.9; font-size: 16px; max-width: 46em; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 24px; font-size: 14px; opacity: 0.95; }
.hero-stats b { font-size: 19px; font-weight: 700; margin-right: 4px; }

/* ---------- layout ---------- */
main.shell { padding: 30px 0 56px; }
.layout-side .grid { display: grid; grid-template-columns: minmax(0, 1fr) 306px; gap: 26px; align-items: start; }
.col-main { min-width: 0; }
.col-side { position: sticky; top: 84px; display: grid; gap: 16px; }
.layout-wide .grid, .layout-wide main.shell { max-width: 760px; margin-inline: auto; }

/* ---------- list ---------- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.list-title { margin: 0; font-size: 21px; }
.list-count { color: var(--text-faint); font-size: 13.5px; white-space: nowrap; }
.page-title { margin: 4px 0 20px; font-size: 24px; }
.page-title small { color: var(--text-faint); font-size: 15px; font-weight: 500; margin-left: 6px; }

.card {
  display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.card-cover { position: relative; display: block; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); aspect-ratio: 16 / 10; }
.card-cover-img { width: 100%; height: 100%; object-fit: cover; }
.card-cover-ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 44px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, hsl(var(--hue) 70% 58%), hsl(calc(var(--hue) + 40) 72% 50%));
}
.card-flag { position: absolute; top: 8px; left: 8px; background: var(--primary); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.card-body { min-width: 0; display: flex; flex-direction: column; }
.card-title { margin: 0 0 8px; font-size: 19px; line-height: 1.45; }
.card-title a { display: block; overflow-wrap: anywhere; }
.card-summary { margin: 0 0 12px; color: var(--text-soft); font-size: 14.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: auto; color: var(--text-faint); font-size: 13px; }
.card-meta a:hover { color: var(--primary); }
.card-meta .dot { opacity: 0.6; }
.card-meta-tags { display: inline-flex; gap: 6px; flex-wrap: wrap; margin-left: 4px; }
.card-slim { grid-template-columns: minmax(0, 1fr); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 13px; line-height: 1.6; }
.chip:hover { background: var(--primary); color: #fff; }
.chip-xs { font-size: 12px; padding: 2px 8px; }
.chip-sm { font-size: 12.5px; padding: 3px 9px; }
.chip i { font-style: normal; opacity: 0.7; font-size: 11px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 30px 0 4px; flex-wrap: wrap; }
.page-btn { min-width: 36px; height: 36px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); color: var(--text-soft); font-size: 14px; }
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-gap { color: var(--text-faint); }

.empty-box { background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); padding: 34px 20px; text-align: center; }
.empty-text { margin: 0; color: var(--text-soft); }
.empty-hint { margin: 8px 0 0; color: var(--text-faint); font-size: 13.5px; }

/* ---------- sidebar ---------- */
.side-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.side-title { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.side-title::before { content: ''; width: 3px; height: 14px; border-radius: 2px; background: var(--primary); }
.side-author { display: flex; gap: 14px; align-items: center; }
.side-avatar { width: 54px; height: 54px; border-radius: 14px; object-fit: cover; flex: none; }
.side-avatar-text { display: grid; place-items: center; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: #fff; font-size: 22px; font-weight: 700; }
.side-author-meta strong { font-size: 16px; }
.side-author-meta p { margin: 4px 0 0; font-size: 13px; color: var(--text-soft); }
.stat-grid { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; padding: 0; text-align: center; }
.stat-grid b { display: block; font-size: 18px; color: var(--primary); }
.stat-grid span { font-size: 12px; color: var(--text-faint); }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.link-list a { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--text-soft); }
.link-list a:hover { color: var(--primary); }
.link-list .count { background: var(--bg); border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--text-faint); flex: none; }
.link-list-recent a { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.link-list-recent time { font-size: 12px; color: var(--text-faint); }
.muted { color: var(--text-faint); }
.side-notice { font-size: 14px; color: var(--text-soft); }
.side-notice p:first-child { margin-top: 0; }
.side-notice p:last-child { margin-bottom: 0; }

.toc-card { max-height: calc(100vh - 120px); overflow: auto; }
.toc { list-style: none; margin: 0; padding: 0; font-size: 13.5px; display: grid; gap: 2px; }
.toc li a { display: block; padding: 4px 8px; border-left: 2px solid var(--border); color: var(--text-soft); border-radius: 0 6px 6px 0; }
.toc li a:hover, .toc li.is-active a { color: var(--primary); border-left-color: var(--primary); background: var(--primary-soft); }
.toc-l3 { padding-left: 12px; }
.toc-l4 { padding-left: 24px; }

/* ---------- post ---------- */
.post { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: clamp(18px, 3vw, 34px); box-shadow: var(--shadow); }
.post-head { padding-bottom: 18px; border-bottom: 1px dashed var(--border); margin-bottom: 22px; }
.post-title { margin: 0 0 12px; font-size: clamp(23px, 3.4vw, 32px); line-height: 1.35; overflow-wrap: anywhere; }
.post-meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--text-faint); font-size: 13.5px; align-items: center; }
.post-meta .dot { opacity: 0.6; }
.post-tags { margin-top: 14px; }
.post-cover { margin: 0 0 24px; border-radius: var(--radius-sm); overflow: hidden; }
.post-cover img { width: 100%; }
.post-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 30px; padding-top: 22px; border-top: 1px dashed var(--border); }
.post-nav-item span { display: block; font-size: 12.5px; color: var(--text-faint); margin-bottom: 4px; }
.post-nav-item b { font-weight: 600; font-size: 14.5px; line-height: 1.5; }
.post-nav-next { text-align: right; }

/* ---------- prose ---------- */
.prose { font-size: 16px; line-height: 1.85; color: var(--text); overflow-wrap: anywhere; }
.prose h2, .prose h3, .prose h4 { margin: 34px 0 14px; line-height: 1.4; }
.prose h2 { font-size: 22px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.prose h3 { font-size: 19px; }
.prose h4 { font-size: 17px; }
.prose p { margin: 16px 0; }
.prose ul, .prose ol { margin: 16px 0; padding-left: 26px; }
.prose li { margin: 6px 0; }
.prose li::marker { color: var(--primary); }
.prose blockquote { margin: 20px 0; padding: 12px 18px; border-left: 3px solid var(--primary); background: var(--primary-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-soft); }
.prose blockquote p { margin: 6px 0; }
.prose code { font-family: 'JetBrains Mono', 'Cascadia Code', Consolas, 'Courier New', monospace; font-size: 0.88em; background: var(--code-bg); padding: 2px 6px; border-radius: 5px; }
.prose pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; overflow-x: auto; line-height: 1.6; }
.prose pre code { background: none; padding: 0; font-size: 13.5px; }
.prose hr { border: 0; border-top: 1px dashed var(--border); margin: 28px 0; }
.prose img { border-radius: var(--radius-sm); margin: 18px auto; height: auto; }
.prose a { color: var(--primary); border-bottom: 1px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.prose a:hover { border-bottom-color: var(--primary); }
.prose table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 14.5px; }
.table-wrap { overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.prose th { background: var(--bg); font-weight: 600; }
.prose input[type='checkbox'] { margin-right: 6px; }
.heading-anchor { opacity: 0; margin-left: 6px; font-weight: 400; color: var(--primary); border: 0 !important; }
.prose h2:hover .heading-anchor, .prose h3:hover .heading-anchor, .prose h4:hover .heading-anchor { opacity: 1; }

/* ---------- tag cloud ---------- */
.tag-cloud { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.tag-ball { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); color: var(--text-soft); transition: all 0.15s ease; }
.tag-ball:hover { background: var(--primary); border-color: var(--primary); color: #fff; transform: translateY(-2px); }
.tag-ball i { font-style: normal; font-size: 0.7em; opacity: 0.7; }
.tl-1 { font-size: 13px; }
.tl-2 { font-size: 15px; }
.tl-3 { font-size: 17px; padding: 7px 16px; }
.tl-4 { font-size: 19px; padding: 8px 18px; }
.tl-5 { font-size: 21px; padding: 9px 20px; font-weight: 600; }

/* ---------- categories ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.cat-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.cat-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.cat-name { font-weight: 600; font-size: 16px; }
.cat-count { color: var(--text-faint); font-size: 13px; }

/* ---------- archives ---------- */
.arch-group { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 20px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.arch-month { font-size: 16px; margin: 16px 0 8px; display: flex; align-items: center; gap: 10px; }
.arch-month small { color: var(--text-faint); font-weight: 400; font-size: 13px; }
.arch-list { list-style: none; margin: 0; padding: 0; }
.arch-list li { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); }
.arch-list li:last-child { border-bottom: 0; }
.arch-list time { color: var(--text-faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.arch-list a { font-size: 15px; }
.arch-views { color: var(--text-faint); font-size: 12.5px; white-space: nowrap; }

/* ---------- search ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 18px; }
.search-bar input { flex: 1; min-width: 0; padding: 11px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 15px; outline: none; }
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn, .search-bar button { padding: 10px 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font-size: 14.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.search-bar button:hover { border-color: var(--primary); color: var(--primary); }

.preview-bar { background: var(--mark-bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 16px; margin-bottom: 16px; font-size: 14px; }
.preview-bar a { text-decoration: underline; }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--border); background: var(--bg-elevate); }
.foot-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 26px 0; }
.foot-brand strong { font-size: 15px; }
.foot-brand p { margin: 4px 0 0; color: var(--text-faint); font-size: 13px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13.5px; color: var(--text-soft); }

/* ---------- 404 ---------- */
.nf { text-align: center; padding: 80px 20px; }
.nf-code { margin: 0; font-size: 76px; font-weight: 800; color: var(--primary); line-height: 1; letter-spacing: 2px; }
.nf-title { margin: 12px 0 6px; font-size: 22px; }
.nf-hint { margin: 0 0 24px; color: var(--text-soft); }
.nf-actions { display: flex; gap: 12px; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .layout-side .grid { grid-template-columns: minmax(0, 1fr); }
  .col-side { position: static; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .head-search input { width: 118px; }
}

@media (max-width: 780px) {
  body { font-size: 15px; }
  .shell { width: min(1180px, 100% - 28px); }
  .site-nav {
    position: fixed; inset: 64px 0 auto 0; flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--bg-elevate); border-bottom: 1px solid var(--border); padding: 10px 14px 14px;
    margin: 0; display: none; z-index: 39; box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; }
  .nav-item { padding: 12px; font-size: 15.5px; }
  .menu-toggle { display: grid; }
  .head-search { display: none; }
  .brand-text { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero-inner { padding: 40px 0 36px; }
  .card { grid-template-columns: minmax(0, 1fr); }
  .card-cover { aspect-ratio: 16 / 9; }
  .card-title { font-size: 17.5px; }
  .post-nav { grid-template-columns: minmax(0, 1fr); }
  .post-nav-next { text-align: left; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .arch-list li { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; }
}

@media (max-width: 420px) {
  .hero-stats { gap: 8px 14px; font-size: 13px; }
  .col-side { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- toast ---------- */
.front-toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 60; box-shadow: var(--shadow-hover); opacity: 0.95;
  animation: toast-in 0.18s ease;
}
.front-toast.is-out { opacity: 0; transition: opacity 0.3s ease; }
@keyframes toast-in { from { transform: translate(-50%, 12px); opacity: 0; } }
