:root {
  --color-bg: #fafafa;
  --color-text: #1a1a1a;
  --color-muted: #666;
  --color-border: #e0e0e0;
  --color-link: #0366d6;
  --color-code-bg: #f4f4f4;
  --color-tag-bg: #eef;
  --max-width: 720px;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a1a;
    --color-text: #e0e0e0;
    --color-muted: #999;
    --color-border: #333;
    --color-link: #58a6ff;
    --color-code-bg: #2a2a2a;
    --color-tag-bg: #1a1a3a;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

header {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

nav { max-width: var(--max-width); margin: 0 auto; }

.logo {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
}

main {
  max-width: var(--max-width);
  margin: 3rem auto;
  padding: 0 1.5rem;
}

h1 { font-size: 1.8rem; font-weight: 600; margin-bottom: 1.5rem; }
h2 { font-size: 1.4rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin: 1rem 0 0.5rem; }

p { margin-bottom: 1rem; }

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

ul { list-style: none; }

.collection-list ul li,
.post-list ul li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}
.collection-list ul li:last-child,
.post-list ul li:last-child {
  border-bottom: none;
}
.collection-list ul a,
.post-list ul a {
  font-size: 1.05rem;
  font-weight: 500;
}

.post-list time,
.post-list .desc {
  display: block;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-top: 0.2rem;
}

.collection-desc {
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

article {
  line-height: 1.75;
}

.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}
.post-header h1 { margin-bottom: 0.5rem; }
.post-header time {
  display: block;
  color: var(--color-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.tags { margin-top: 0.5rem; }
.tags span {
  display: inline-block;
  background: var(--color-tag-bg);
  color: var(--color-muted);
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-right: 0.4rem;
}

.post-body h1 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.post-body h2 { font-size: 1.3rem; }
.post-body h3 { font-size: 1.1rem; }

.post-body pre {
  background: var(--color-code-bg);
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

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

.post-body img {
  max-width: 100%;
  border-radius: 4px;
  display: block;
  margin: 1rem 0;
}

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

.post-body ul, .post-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}
.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }

.post-body li { margin-bottom: 0.25rem; }

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.post-body th, .post-body td {
  border: 1px solid var(--color-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.post-body th { background: var(--color-code-bg); }

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

.back {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}
.back.top {
  margin-top: -1rem;
  margin-bottom: 1.5rem;
  padding-top: 0;
  border-top: none;
}

.empty {
  text-align: center;
  color: var(--color-muted);
  margin: 3rem 0;
}

.katex { font-size: 1.05em !important; }
.katex-display { overflow-x: auto; overflow-y: hidden; }
.katex-display > .katex { white-space: nowrap; }
