:root {
  --bg: #fcfcfa;
  --fg: #1f2328;
  --muted: #6b7280;
  --line: #e6e4df;
  --accent: #0f6fbf;
  --code-bg: #f3f2ee;
  --quote-bar: #d9d6cf;
  --table-stripe: #f7f6f2;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --fg: #e4e6e9;
    --muted: #9aa1ab;
    --line: #2b2f35;
    --accent: #6cb4ee;
    --code-bg: #1d2024;
    --quote-bar: #3a3f47;
    --table-stripe: #1a1d21;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

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

/* header */

.site-header {
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--fg);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand img {
  height: 1.75rem;
  width: auto;
}

.brand .logo-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  .brand .logo-light {
    display: none;
  }
  .brand .logo-dark {
    display: inline;
  }
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
}

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

.site-nav a[aria-current="page"],
.site-nav a:hover {
  color: var(--fg);
  text-decoration: none;
}

/* index */

.page-title {
  margin: 3rem 0 2rem;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

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

.post-list li {
  padding: 1.5rem 0;
  border-top: 1px solid var(--line);
}

.post-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.post-list h2 {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
}

.post-list h2 a {
  color: var(--fg);
}

.post-list p {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.post-meta {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* article */

.post {
  padding: 3rem 0 4rem;
}

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

.post-header h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.post-body > blockquote:first-child {
  margin: 0 0 2.5rem;
  padding: 0 0 0 1.1rem;
  border-left: 3px solid var(--quote-bar);
  color: var(--muted);
  font-size: 1.02rem;
}

.post-body h2 {
  margin: 3rem 0 1rem;
  font-size: 1.45rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.post-body h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 650;
}

.post-body p,
.post-body ul,
.post-body ol {
  margin: 0 0 1.2rem;
}

.post-body li {
  margin: 0.3rem 0;
}

.post-body li > p {
  margin: 0.3rem 0;
}

.post-body blockquote {
  margin: 1.5rem 0;
  padding: 0 0 0 1.1rem;
  border-left: 3px solid var(--quote-bar);
  color: var(--muted);
}

.post-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

.post-body img {
  max-width: 100%;
}

/* code */

code,
pre,
kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
}

.post-body :not(pre) > code {
  background: var(--code-bg);
  padding: 0.12em 0.35em;
  border-radius: 4px;
}

.post-body pre {
  margin: 1.4rem -1.5rem;
  padding: 1rem 1.1rem;
  background: var(--code-bg);
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.6;
}

.post-body pre code {
  font-size: 0.82rem;
  background: none;
  padding: 0;
}

.codehilite {
  margin: 1.4rem -1.5rem;
}

.codehilite pre {
  margin: 0;
}

@media (max-width: 600px) {
  .post-body pre,
  .codehilite {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    border-radius: 0;
  }
}

/* tables */

.post-body table {
  width: 100%;
  margin: 1.4rem 0;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}

.post-body th,
.post-body td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.post-body th {
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--line);
}

.post-body tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

.post-body table code {
  white-space: nowrap;
}

/* references */

.post-body h2 + p a {
  word-break: break-all;
}

/* footer */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (max-width: 600px) {
  html {
    font-size: 16px;
  }
  .post-header h1 {
    font-size: 1.6rem;
  }
  .post-body h2 {
    font-size: 1.3rem;
  }
}

/* language switch */

.post-meta .sep {
  margin: 0 0.5rem;
}

.post-meta .langs a {
  color: var(--accent);
}
