:root {
  --font-body:
    BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

  --c-bg: #fafaf8;
  --c-text: #1a1a1a;
  --c-text-muted: #6b6b6b;
  --c-accent: #c23b22;
  --c-border: #e0ddd8;
  --c-code-bg: #f0eeea;
  --c-link: #1a1a1a;
  --c-link-hover: var(--c-accent);

  --w-content: 800px;
  --s-base: 1.125rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg: #141413;
    --c-text: #e0ddd8;
    --c-text-muted: #8a8a8a;
    --c-accent: #e8634a;
    --c-border: #2a2a28;
    --c-code-bg: #1e1e1c;
    --c-link: #e0ddd8;
  }
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--s-base);
  line-height: 1.7;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main.content {
  width: 100%;
  flex: 1;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: 1rem;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* --- Layout --- */
.content {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* --- Navigation --- */
.site-header {
  border-bottom: 1px solid var(--c-border);
}

.nav {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  color: var(--c-text);
  letter-spacing: -0.01em;
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 400;
  text-decoration: none;
  color: var(--c-text-muted);
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--c-text);
}

/* --- Homepage --- */
.home h2 {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-muted);
  margin-bottom: 1rem;
}

/* --- Post list --- */
.post-list {
  list-style: none;
}

.post-item {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--c-border);
}

.post-item:last-child {
  border-bottom: none;
}

.post-item time {
  display: block;
  font-size: 0.8rem;
  color: var(--c-text-muted);
}

.post-item a {
  color: var(--c-link);
  text-decoration: none;
  font-weight: 400;
}

.post-item a:hover {
  color: var(--c-link-hover);
}

/* --- Single post --- */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--c-border);
}

.post-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.post-meta {
  font-size: 0.85rem;
  color: var(--c-text-muted);
}

.tag {
  color: var(--c-accent);
  text-decoration: none;
  font-weight: 500;
}

.tag:hover {
  text-decoration: underline;
}

/* --- Post content --- */
.post-content h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.02em;
}

.post-content h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
  letter-spacing: -0.01em;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content a {
  color: var(--c-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.post-content a:hover {
  text-decoration-thickness: 2px;
}

.post-content ul,
.post-content ol {
  margin: 0 0 1.25rem 1.5rem;
}

.post-content li {
  margin-bottom: 0.35rem;
}

.post-content blockquote {
  border-left: 3px solid var(--c-accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--c-text-muted);
  font-style: italic;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

/* --- Code --- */
.post-content code {
  font-size: 0.85em;
  background: var(--c-code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--c-code-bg);
  padding: 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--c-border);
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* --- KaTeX overrides --- */
.katex-display {
  margin: 1.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.katex {
  font-size: 1.05em;
}

/* --- Footnotes --- */
.post-content .footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--c-border);
  font-size: 0.85rem;
  color: var(--c-text-muted);
}

.post-content .footnotes ol {
  margin-left: 1.25rem;
}

.post-content .footnotes li {
  margin-bottom: 0.5rem;
}

.post-content .footnotes li p {
  margin-bottom: 0.25rem;
}

.post-content sup a.footnote-ref {
  font-size: 0.75em;
  text-decoration: none;
  color: var(--c-accent);
  font-weight: 600;
  padding: 0 0.1em;
}

.post-content sup a.footnote-ref:hover {
  text-decoration: underline;
}

.post-content .footnotes .footnote-backref {
  text-decoration: none;
  color: var(--c-accent);
  margin-left: 0.25em;
}

/* --- Post footer --- */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--c-border);
}

.post-author {
  font-size: 0.9rem;
  color: var(--c-text-muted);
  margin-bottom: 1.5rem;
}

.post-author strong {
  color: var(--c-text);
}

.post-nav {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--c-text-muted);
  text-decoration: none;
  margin-right: 1.5rem;
}

.post-nav:hover {
  color: var(--c-accent);
}

/* --- Footer --- */
.site-footer {
  font-size: 0.8rem;
  border-top: 1px solid var(--c-border);
  color: var(--c-text-muted);
}

.site-footer a {
  color: var(--c-text-muted);
}

.site-footer a:hover {
  color: var(--c-accent);
}

.site-footer-content {
  max-width: var(--w-content);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .post-item {
    flex-direction: column;
    gap: 0.15rem;
  }
  .post-header h1 {
    font-size: 1.5rem;
  }
}
