:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --text: #111827;
  --body: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #111827;
  --code-bg: #f6f8fa;
  --code-text: #24292f;
  --quote-bg: #f9fafb;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0f17;
    --surface: #0f1520;
    --surface-muted: #111827;
    --text: #f9fafb;
    --body: #d1d5db;
    --muted: #9ca3af;
    --border: #253041;
    --border-strong: #374151;
    --accent: #f9fafb;
    --code-bg: #111827;
    --code-text: #e5e7eb;
    --quote-bg: #111827;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  opacity: 0.72;
}

.site-container {
  width: min(1300px, calc(100% - 48px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

.site-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.site-nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: opacity 180ms ease, color 180ms ease;
}

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

.main-content {
  padding: 72px 0 88px;
}

.page-heading {
  max-width: 760px;
  padding-bottom: 44px;
}

.page-heading h1,
.article-header h1 {
  margin: 0;
  color: var(--text);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: 0;
}

.page-intro {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
}

.stats,
.post-meta,
.search-count {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 18px 0 0;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 80px;
  align-items: start;
}

.post-list {
  display: grid;
  gap: 0;
}

.post-card {
  padding: 30px 0;
  border-top: 1px solid var(--border);
  transition: opacity 180ms ease;
}

.post-card:hover {
  opacity: 0.86;
}

.post-card:first-child {
  padding-top: 0;
  border-top: 0;
}

.post-card h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0;
}

.post-card p {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--body);
  font-size: 16px;
  line-height: 1.8;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.post-meta time,
.post-meta span {
  color: var(--muted);
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  transition: opacity 180ms ease, border-color 180ms ease, color 180ms ease;
}

.meta-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.meta-pill-category {
  color: var(--body);
}

.home-sidebar {
  position: sticky;
  top: 104px;
  display: grid;
  gap: 34px;
  color: var(--muted);
}

.sidebar-section {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.sidebar-section h2 {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.term-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 14px;
  transition: opacity 180ms ease;
}

.term-row strong {
  color: var(--text);
  font-size: 12px;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sidebar-empty,
.empty-state {
  color: var(--muted);
}

.post-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 920px) 220px;
  justify-content: center;
  align-items: start;
  gap: 32px;
}

.article {
  width: 100%;
  min-width: 0;
}

.post-toc {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 128px);
  overflow: auto;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.post-toc h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
}

.post-toc ol {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.post-toc li {
  min-width: 0;
}

.post-toc a {
  display: block;
  overflow: hidden;
  padding: 5px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 180ms ease, color 180ms ease;
}

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

.post-toc .toc-level-2 {
  padding-left: 12px;
}

.post-toc .toc-level-3 {
  padding-left: 24px;
}

.post-toc .toc-level-4 {
  padding-left: 36px;
}

.post-toc-empty {
  visibility: hidden;
}

.article-header {
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 38px;
}

.article-header .post-meta {
  margin-top: 18px;
}

.markdown-body {
  color: var(--body);
  font-size: 17px;
  line-height: 1.82;
  overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  scroll-margin-top: 112px;
  margin: 34px 0 14px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: 0;
}

.markdown-body h1 {
  font-size: 32px;
}

.markdown-body h2 {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 26px;
}

.markdown-body h3 {
  font-size: 21px;
}

.markdown-body h4 {
  font-size: 18px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body pre,
.markdown-body table {
  margin-top: 0;
  margin-bottom: 20px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.45em;
}

.markdown-body li + li {
  margin-top: 6px;
}

.markdown-body blockquote {
  padding: 16px 20px;
  border-left: 3px solid var(--text);
  border-radius: 0 6px 6px 0;
  background: var(--quote-bg);
  color: var(--body);
}

.markdown-body code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 86%;
}

.markdown-body pre {
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  box-shadow: var(--shadow);
}

.markdown-body pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 14px;
  line-height: 1.7;
}

.hljs {
  background: transparent;
  color: var(--code-text);
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
  color: #8250df;
}

.hljs-string,
.hljs-attr,
.hljs-title {
  color: #0a3069;
}

.hljs-comment {
  color: #6e7781;
}

@media (prefers-color-scheme: dark) {
  .hljs-keyword,
  .hljs-selector-tag,
  .hljs-built_in {
    color: #c084fc;
  }

  .hljs-string,
  .hljs-attr,
  .hljs-title {
    color: #93c5fd;
  }

  .hljs-comment {
    color: #9ca3af;
  }
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.markdown-body table {
  display: block;
  width: 100%;
  overflow: auto;
  border-collapse: collapse;
  font-size: 15px;
}

.markdown-body th,
.markdown-body td {
  padding: 10px 13px;
  border: 1px solid var(--border);
}

.markdown-body th {
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 700;
}

.markdown-body tr:nth-child(2n) {
  background: var(--surface-muted);
}

.related-posts {
  position: sticky;
  top: 104px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
}

.related-list {
  display: grid;
  gap: 0;
}

.related-item {
  display: grid;
  gap: 5px;
  padding: 13px 0;
  border-top: 1px solid var(--border);
  color: var(--body);
  transition: opacity 180ms ease;
}

.related-item:first-child {
  border-top: 0;
}

.related-item:hover {
  opacity: 0.72;
}

.related-item span {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
}

.related-item time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.search-panel {
  width: min(800px, 100%);
  display: grid;
  gap: 14px;
}

.search-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.search-input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 8%, transparent);
  outline: none;
}

.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 1280px) {
  .site-container {
    width: min(100% - 40px, 900px);
  }

  .post-layout {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .related-posts {
    position: static;
    margin-top: 8px;
    padding-top: 28px;
  }

  .post-toc {
    position: static;
    max-height: none;
    margin-top: 0;
    padding-bottom: 22px;
  }

  .post-toc-empty {
    display: none;
  }

  .post-toc ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
  }
}

@media (max-width: 900px) {
  .site-container {
    width: min(100% - 32px, 760px);
  }

  .main-content {
    padding: 48px 0 72px;
  }

  .home-grid {
    grid-template-columns: 1fr;
    gap: 44px;
  }

  .home-sidebar {
    position: static;
  }

  .page-heading h1,
  .article-header h1 {
    font-size: 34px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .site-container {
    width: min(100% - 24px, 760px);
  }

  .header-inner {
    min-height: 60px;
    gap: 18px;
  }

  .site-nav {
    gap: 16px;
  }

  .page-heading {
    padding-bottom: 34px;
  }

  .page-heading h1,
  .article-header h1 {
    font-size: 30px;
  }

  .post-card {
    padding: 24px 0;
  }

  .post-card h2 {
    font-size: 22px;
  }

  .markdown-body {
    font-size: 16px;
  }

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

}
