:root {
  --bg: #fff;
  --text: #333;
  --text-secondary: #666;
  --link: #0366d6;
  --border: #e1e4e8;
  --code-bg: #f6f8fa;
  --tag-bg: #f0f0f0;
  --max-width: 720px;
}

[data-theme="dark"] {
  --bg: #1a1a2e;
  --text: #e0e0e0;
  --text-secondary: #aaa;
  --link: #58a6ff;
  --border: #2a2a4a;
  --code-bg: #16213e;
  --tag-bg: #2a2a4a;
}

[data-theme="dark"] .katex { color: #e0e0e0; }
[data-theme="dark"] .katex .mord { color: #e0e0e0; }
.katex .tag { background: none !important; border: none !important; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.2s, color 0.2s;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.25rem; }

.site-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.5rem 0; border-bottom: 1px solid var(--border);
}
.site-title { font-size: 1.4rem; font-weight: 700; color: var(--text); text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 1rem; }
.site-nav a { color: var(--text-secondary); text-decoration: none; font-size: 0.95rem; }
.site-nav a:hover { color: var(--link); }

#theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; font-size: 1rem; line-height: 1;
}

main { min-height: 70vh; padding: 2rem 0; }

.post-list { margin-top: 1.5rem; }
.post-item { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: none; }
.post-title a { color: var(--text); text-decoration: none; font-size: 1.25rem; }
.post-title a:hover { color: var(--link); }
.post-meta { font-size: 0.85rem; color: var(--text-secondary); margin: 0.3rem 0; display: flex; gap: 0.75rem; align-items: center; }
.post-desc { color: var(--text-secondary); font-size: 0.95rem; margin-top: 0.4rem; }

.post-tags { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.post-tags .tag {
  display: inline-block; background: var(--tag-bg); color: var(--text-secondary);
  padding: 0 8px; border-radius: 3px; font-size: 0.8rem; text-decoration: none;
}
.post-tags .tag:hover { color: var(--link); }

.post-header { margin-bottom: 1.5rem; }
.post-header h1 { font-size: 1.8rem; }
.post-content { font-size: 1.05rem; }
.post-content h2 { margin-top: 2rem; margin-bottom: 0.6rem; }
.post-content h3 { margin-top: 1.5rem; margin-bottom: 0.5rem; }
.post-content p { margin-bottom: 1rem; }
.post-content ul, .post-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.post-content li { margin-bottom: 0.3rem; }
.post-content a { color: var(--link); }
.post-content blockquote {
  border-left: 4px solid var(--link); padding: 0.5rem 1rem;
  margin: 1rem 0; background: var(--code-bg); border-radius: 0 4px 4px 0;
}
.post-content code {
  background: var(--code-bg); padding: 2px 6px; border-radius: 3px;
  font-size: 0.9em; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.post-content pre {
  background: #272822 !important; color: #f8f8f2;
  padding: 1rem; border-radius: 6px;
  overflow-x: auto; margin-bottom: 1rem; border: 1px solid #3c3d38;
}
.post-content pre code { background: none !important; padding: 0; color: #f8f8f2; }
.highlight pre { background: #272822 !important; }
.post-content img { max-width: 100%; border-radius: 6px; }
.post-content img.center { display: block; margin: 1rem auto; }
.post-content img.right { float: right; margin: 0 0 1rem 1rem; }
.post-content img.left { float: left; margin: 0 1rem 1rem 0; }
.post-content table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.post-content th, .post-content td {
  border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left;
}
.post-content th { background: var(--code-bg); }

.post-nav { display: flex; justify-content: space-between; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.post-nav a { color: var(--link); text-decoration: none; max-width: 48%; }
.post-nav a:hover { text-decoration: underline; }

.site-footer {
  display: flex; justify-content: space-between; padding: 1.5rem 0;
  border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-secondary);
}
.site-footer a { color: var(--link); text-decoration: none; }

@media (max-width: 600px) {
  .site-header { flex-direction: column; gap: 0.5rem; }
  .post-nav { flex-direction: column; gap: 0.5rem; }
  .post-nav a { max-width: 100%; }
}
