:root {
  --sans: "Sora", -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --serif: "Source Serif 4", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #fbfaf7;
  --fg: #1c1b19;
  --muted: #74716a;
  --faint: #bdb9b0;
  --rule: #e6e2d9;
  --code-bg: #f2f0eb;

  --body-font: var(--serif);
  --body-size: 1.125rem;
  --body-weight: 400;
  --leading: 1.75;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --fg: #dcd8cf;
    --muted: #9a968d;
    --faint: #57544e;
    --rule: #2b2a27;
    --code-bg: #1f1e1b;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body-font);
  font-size: var(--body-size);
  font-weight: var(--body-weight);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--rule); }

.wrap {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header and footer */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.5rem 0 4rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}

.site-name {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
}

.site-nav { display: flex; gap: 1.25rem; }

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

.site-nav a:hover,
.site-nav a[aria-current],
.site-footer a:hover { color: var(--fg); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 6rem 0 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}

.site-footer span { margin-right: auto; }

/* Text */

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--faint);
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.15s ease;
}

a:hover { text-decoration-color: currentColor; }

h1, h2, h3, h4 {
  font-family: var(--sans);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 2.5em 0 0.75em;
  text-wrap: balance;
}

h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p, ul, ol, dl, table, blockquote, pre, figure { margin: 0 0 1.25em; }

ul, ol { padding-left: 1.25em; }
li { margin: 0.3em 0; }
li::marker { color: var(--muted); }

strong { font-weight: 600; }

blockquote {
  margin-left: 0;
  margin-right: 0;
  padding-left: 1.25em;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

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

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

img, video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 2rem auto;
  border-radius: 4px;
}

table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  font-variant-numeric: lining-nums tabular-nums;
}

th, td {
  padding: 0.5em 0.9em 0.5em 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

th { font-family: var(--sans); font-weight: 600; font-size: 0.9em; }

/* Code */

code, pre, kbd {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

:not(pre) > code {
  padding: 0.15em 0.35em;
  border-radius: 4px;
  background: var(--code-bg);
  font-size: 0.85em;
}

.prose pre,
pre {
  overflow-x: auto;
  padding: 1rem 1.25rem;
  border-radius: 6px;
  background: var(--code-bg);
  font-size: 0.8125rem;
  line-height: 1.65;
  tab-size: 4;
}

pre code { font-size: inherit; }

/* Pages */

.page-title { margin-bottom: 2rem; }

.muted { color: var(--muted); }

.home > h1 { font-size: 2.25rem; margin-bottom: 0.5rem; }

.home > h1 + p {
  margin-bottom: 2.5rem;
  font-family: var(--sans);
  color: var(--muted);
}

.home > blockquote { margin: 0 0 1rem; font-style: italic; }

.home > h2,
.year {
  margin: 3.5rem 0 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.year { margin-top: 2.5rem; letter-spacing: 0.06em; }

.home > ul:not(.post-list) { list-style: none; padding: 0; }

.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin: 0;
  padding: 0.4rem 0;
}

.post-list time {
  flex: none;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.post-list a { text-decoration-color: transparent; }
.post-list a:hover { text-decoration-color: currentColor; }

.more { font-family: var(--sans); font-size: 0.875rem; }
.more a { color: var(--muted); }

/* Posts */

.post-header { margin-bottom: 2.5rem; }
.post-header h1 { margin-bottom: 0.6rem; }

.meta {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
}

.prose h2, .prose h3, .prose h4 { scroll-margin-top: 1.5rem; }

/* CJK glyphs are already tightly set; negative tracking crowds them. */
:lang(zh) :is(h1, h2, h3, h4) { letter-spacing: 0; }

/* KaTeX, loaded only on posts with `math = true` */
.prose .katex { font-size: 1.1em; }

.prose .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 0 1.25em;
  padding: 0.25em 0;
}

.anchor {
  margin-left: 0.35em;
  color: var(--faint);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

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

.footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875em;
  color: var(--muted);
}

.footnote-reference a, .footnotes a { text-decoration: none; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 4rem;
  font-family: var(--sans);
  font-size: 0.875rem;
}

.post-nav a { text-decoration: none; max-width: 50%; }
.post-nav .newer { text-align: right; margin-left: auto; }

.post-nav span {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 40rem) {
  :root { --body-size: 1.0625rem; }

  .site-header { padding: 1.75rem 0 3rem; }

  .prose pre {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    border-radius: 0;
  }

  .post-list li { gap: 1rem; }
}
