/* Variables */
:root {
  --bg: #ffffff;
  --bg-alt: #f6f8fa;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --link: #0969da;
  --code-bg: #f6f8fa;
  --inline-code: #cf222e;
  --max-width: 760px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-alt: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #7d8590;
    --link: #58a6ff;
    --code-bg: #161b22;
    --inline-code: #ff7b72;
  }
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { font-size: 17px; scrollbar-gutter: stable; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; }

/* Layout */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* Header */
.site-header { border-bottom: 1px solid var(--border); }
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.site-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.site-title:hover { color: var(--link); text-decoration: none; }
.site-nav a {
  font-size: 0.875rem;
  color: var(--muted);
  margin-left: 20px;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }

/* Main */
main.container { padding-top: 48px; padding-bottom: 80px; flex: 1; }

/* Post list */
.post-list { list-style: none; padding: 0; }
.post-list-item {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.post-list-item:first-child { border-top: 1px solid var(--border); }
.post-list-date {
  flex-shrink: 0;
  font-size: 0.825rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 90px;
}
.post-list-link {
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
}
.post-list-link:hover { color: var(--link); text-decoration: none; }

/* Post page */
.post-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.post-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}
.post-meta { font-size: 0.875rem; color: var(--muted); }

/* Post content */
.post-content p,
.post-content ul,
.post-content ol,
.post-content blockquote,
.post-content pre,
.post-content table,
.post-content hr { margin-top: 1.25em; }

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 { margin-top: 2em; margin-bottom: 0.5em; }

.post-content :first-child { margin-top: 0; }

.post-content h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.post-content h2 {
  font-size: 1.3rem;
  font-weight: 600;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}
.post-content h3 { font-size: 1.1rem; font-weight: 600; }
.post-content h4 { font-size: 1rem; font-weight: 600; }
.post-content ul, .post-content ol { padding-left: 1.75em; }
.post-content li { margin-top: 0.3em; }
.post-content strong { font-weight: 600; }
.post-content hr { border: none; border-top: 1px solid var(--border); }

/* Inline code */
.post-content :not(pre) > code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85em;
  color: var(--inline-code);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
}

/* Code blocks */
.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  line-height: 1.6;
}
.post-content pre code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

/* Blockquote */
.post-content blockquote {
  padding-left: 1em;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
}
.post-content th,
.post-content td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.post-content th { background: var(--bg-alt); font-weight: 600; }
.post-content tr:nth-child(even) td { background: var(--bg-alt); }

/* Images in posts */
.post-content img {
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}

/* Giscus comments */
.giscus-wrapper {
  max-width: var(--max-width);
  margin: 48px auto 0;
  padding: 40px 24px 0;
  border-top: 1px solid var(--border);
}

/* Page layout (about, etc.) */
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.page-content {
  font-size: 1rem;
  line-height: 1.75;
}
.page-content > * + * { margin-top: 1.25em; }
.page-content a { color: var(--link); }

/* 404 */
.error-page { text-align: center; padding: 80px 0; }
.error-page h1 {
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}
.error-page p { color: var(--muted); margin-top: 8px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 20px 0; }
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-footer span,
.site-footer a {
  font-size: 0.825rem;
  color: var(--muted);
}
.site-footer a:hover { color: var(--text); }

/* ── Syntax highlighting: Rouge GitHub theme ── */
.highlight { background: var(--code-bg); }

.highlight .c  { color: #6e7781 }
.highlight .err { color: #82071e; background-color: #ffebe9 }
.highlight .k  { color: #cf222e }
.highlight .l  { color: #0550ae }
.highlight .n  { color: #24292f }
.highlight .o  { color: #24292f }
.highlight .p  { color: #24292f }
.highlight .cm { color: #6e7781 }
.highlight .cp { color: #6e7781 }
.highlight .c1 { color: #6e7781 }
.highlight .cs { color: #6e7781 }
.highlight .gd { color: #82071e; background-color: #ffebe9 }
.highlight .ge { font-style: italic }
.highlight .gh { font-weight: bold }
.highlight .gi { color: #116329; background-color: #dafbe1 }
.highlight .gp { color: #57606a; font-weight: bold }
.highlight .gs { font-weight: bold }
.highlight .gu { color: #6f42c1; font-weight: bold }
.highlight .kc { color: #cf222e }
.highlight .kd { color: #cf222e }
.highlight .kn { color: #cf222e }
.highlight .kp { color: #cf222e }
.highlight .kr { color: #cf222e }
.highlight .kt { color: #953800 }
.highlight .ld { color: #0a3069 }
.highlight .m  { color: #0550ae }
.highlight .s  { color: #0a3069 }
.highlight .na { color: #116329 }
.highlight .nb { color: #953800 }
.highlight .nc { color: #953800 }
.highlight .no { color: #0550ae }
.highlight .nd { color: #8250df }
.highlight .ni { color: #24292f }
.highlight .ne { color: #cf222e; font-weight: bold }
.highlight .nf { color: #8250df }
.highlight .nl { color: #1f2328 }
.highlight .nn { color: #953800 }
.highlight .nx { color: #24292f }
.highlight .nt { color: #116329 }
.highlight .nv { color: #953800 }
.highlight .ow { color: #cf222e }
.highlight .w  { color: #24292f }
.highlight .mf { color: #0550ae }
.highlight .mh { color: #0550ae }
.highlight .mi { color: #0550ae }
.highlight .mo { color: #0550ae }
.highlight .sb { color: #0a3069 }
.highlight .sc { color: #0a3069 }
.highlight .sd { color: #0a3069 }
.highlight .s2 { color: #0a3069 }
.highlight .se { color: #cf222e }
.highlight .sh { color: #0a3069 }
.highlight .si { color: #0a3069 }
.highlight .sx { color: #0a3069 }
.highlight .sr { color: #116329 }
.highlight .s1 { color: #0a3069 }
.highlight .ss { color: #0a3069 }
.highlight .bp { color: #953800 }
.highlight .vc { color: #953800 }
.highlight .vg { color: #953800 }
.highlight .vi { color: #953800 }
.highlight .il { color: #0550ae }

@media (prefers-color-scheme: dark) {
  .highlight .c  { color: #8b949e }
  .highlight .err { color: #f85149; background-color: transparent }
  .highlight .k  { color: #ff7b72 }
  .highlight .n  { color: #e6edf3 }
  .highlight .o  { color: #e6edf3 }
  .highlight .p  { color: #e6edf3 }
  .highlight .cm { color: #8b949e }
  .highlight .cp { color: #8b949e }
  .highlight .c1 { color: #8b949e }
  .highlight .cs { color: #8b949e }
  .highlight .gd { color: #ffa198; background-color: #490202 }
  .highlight .gi { color: #56d364; background-color: #0f5323 }
  .highlight .gp { color: #8b949e; font-weight: bold }
  .highlight .kc { color: #ff7b72 }
  .highlight .kd { color: #ff7b72 }
  .highlight .kn { color: #ff7b72 }
  .highlight .kp { color: #ff7b72 }
  .highlight .kr { color: #ff7b72 }
  .highlight .kt { color: #ffa657 }
  .highlight .m  { color: #79c0ff }
  .highlight .s  { color: #a5d6ff }
  .highlight .na { color: #7ee787 }
  .highlight .nb { color: #ffa657 }
  .highlight .nc { color: #ffa657 }
  .highlight .no { color: #79c0ff }
  .highlight .nd { color: #d2a8ff }
  .highlight .ne { color: #ff7b72 }
  .highlight .nf { color: #d2a8ff }
  .highlight .nn { color: #ffa657 }
  .highlight .nt { color: #7ee787 }
  .highlight .nv { color: #ffa657 }
  .highlight .ow { color: #ff7b72 }
  .highlight .mf { color: #79c0ff }
  .highlight .mh { color: #79c0ff }
  .highlight .mi { color: #79c0ff }
  .highlight .mo { color: #79c0ff }
  .highlight .s2 { color: #a5d6ff }
  .highlight .se { color: #ff7b72 }
  .highlight .sh { color: #a5d6ff }
  .highlight .si { color: #a5d6ff }
  .highlight .sr { color: #7ee787 }
  .highlight .s1 { color: #a5d6ff }
  .highlight .ss { color: #a5d6ff }
  .highlight .bp { color: #ffa657 }
  .highlight .il { color: #79c0ff }
}

/* Responsive */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .post-title, .page-title { font-size: 1.4rem; }
  .post-list-item { flex-direction: column; gap: 3px; }
  .post-list-date { min-width: auto; }
  .post-content pre {
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-left: -24px;
    margin-right: -24px;
    padding: 14px 24px;
  }
  .site-footer .container { flex-direction: column; align-items: flex-start; gap: 4px; }
}
