:root {
  --bg: #ffffff;
  --fg: #1b1d21;
  --muted: #5c6169;
  --accent: #1a56b8;
  --border: #e2e5ea;
  --code-bg: #f5f6f8;
  --measure: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e4e6ea;
    --muted: #9aa1ab;
    --accent: #6aa9ff;
    --border: #262a31;
    --code-bg: #171a20;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

.wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 8px; top: 8px;
  background: var(--bg);
  padding: 8px 12px;
  border: 1px solid var(--border);
  z-index: 10;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.site-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--fg);
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.site-nav a { color: var(--muted); font-size: 0.95rem; }
.site-nav a:hover { color: var(--accent); }
.icon-link { display: inline-flex; align-items: center; }

/* Typography */
h1, h2, h3, h4 { line-height: 1.25; margin: 2rem 0 0.75rem; font-weight: 650; }
.page-title { margin-top: 0; font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p, ul, ol { margin: 0 0 1rem; }
ul, ol { padding-left: 1.3rem; }
li { margin-bottom: 0.35rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }
blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
small, .muted { color: var(--muted); }

/* Code */
code, pre, kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}
code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

/* Media + tables */
img { max-width: 100%; height: auto; display: block; }
figure { margin: 1.75rem 0; }
figcaption { color: var(--muted); font-size: 0.88rem; margin-top: 0.6rem; }

.table-scroll { overflow-x: auto; margin: 1.25rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { border-bottom: 1px solid var(--border); padding: 0.5rem 0.7rem; text-align: left; }
th { font-weight: 600; }
td.num, th.num { text-align: right; }

/* Posts */
.post-meta { color: var(--muted); font-size: 0.9rem; margin-top: -0.4rem; }
.post-tags { margin-top: 0.4rem; }
.tag {
  display: inline-block;
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin-right: 0.35rem;
}
.post-content { margin-top: 1.75rem; }
.share {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--muted);
}
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.92rem;
  margin-top: 1rem;
}

/* Post lists */
.post-list { list-style: none; padding: 0; }
.post-list li { margin-bottom: 1.35rem; }
.post-list .post-link { font-weight: 600; font-size: 1.05rem; }
.post-list time { display: block; color: var(--muted); font-size: 0.85rem; }
.post-list .excerpt { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.95rem; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.site-footer p { margin: 0; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .page-title { font-size: 1.55rem; }
  .header-inner { justify-content: flex-start; }
}

/* math: never let a long formula widen the page */
.kdmath, .katex-display { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
