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

:root {
  --bg: #fff;
  --fg: #111;
  --muted: #666;
  --border: #e0e0e0;
  --link: #111;
  --link-hover: #555;
  --code-bg: #f5f5f5;
  --max: 680px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0f;
    --fg: #e8e8e8;
    --muted: #888;
    --border: #2a2a2a;
    --link: #e8e8e8;
    --link-hover: #aaa;
    --code-bg: #1a1a1a;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--fg);
  padding: 2rem 1.25rem;
}

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

/* Nav */
nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
nav .site-name { font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--fg); }
nav ul { list-style: none; display: flex; gap: 1.5rem; }
nav ul a { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
nav ul a:hover { color: var(--fg); }

/* Links */
a { color: var(--link); }
a:hover { color: var(--link-hover); }

/* Home — post list */
.month-group { margin-bottom: 2.5rem; }
.month-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.post-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}
.post-item:last-child { border-bottom: none; }
.post-title { text-decoration: none; color: var(--fg); font-size: 1rem; }
.post-title:hover { color: var(--link-hover); text-decoration: underline; }
.post-date { font-size: 0.8rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

/* Post page */
.post-header { margin-bottom: 2rem; }
.post-header h1 { font-size: 1.75rem; line-height: 1.3; margin-bottom: 0.4rem; }
.post-header .meta { color: var(--muted); font-size: 0.85rem; }

.post-body h1, .post-body h2, .post-body h3,
.post-body h4, .post-body h5, .post-body h6 {
  margin: 2rem 0 0.6rem;
  line-height: 1.3;
}
.post-body h1 { font-size: 1.5rem; }
.post-body h2 { font-size: 1.25rem; }
.post-body h3 { font-size: 1.05rem; }
.post-body p { margin: 0.9rem 0; }
.post-body ul, .post-body ol { margin: 0.9rem 0 0.9rem 1.5rem; }
.post-body li { margin: 0.25rem 0; }
.post-body blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
  margin: 1rem 0;
}
.post-body code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 3px;
}
.post-body pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1rem 0;
  position: relative;
}
.post-body pre code { background: none; padding: 0; font-size: 0.82em; }

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--border);
  color: var(--muted);
  border: none;
  border-radius: 3px;
  padding: 0.2rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.post-body pre:hover .copy-btn { opacity: 1; }
.copy-btn.copied { color: var(--fg); }
.post-body img { max-width: 100%; border-radius: 4px; margin: 1rem 0; }
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }
.post-body a { text-decoration: underline; }
.post-body table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.post-body th, .post-body td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.post-body th { background: var(--code-bg); }

/* About */
.about-body h2 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
.about-body p { margin: 0.75rem 0; }
.about-body a { text-decoration: underline; }

/* Back link */
.back { display: inline-block; color: var(--muted); font-size: 0.85rem; text-decoration: none; margin-bottom: 2rem; }
.back:hover { color: var(--fg); }

/* Footer */
footer { margin-top: 4rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; }
