:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #1d4ed8;
  --code-bg: #f3f4f6;
  --pre-bg: #1e1e1e;
  --pre-text: #d4d4d4;
  --max-w: 660px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --text: #e2e2e2;
    --muted: #9ca3af;
    --border: #2a2a2a;
    --accent: #60a5fa;
    --code-bg: #1e1e1e;
    --pre-bg: #1a1a1a;
    --pre-text: #d4d4d4;
  }
}

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

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

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.75;
  transition: background 0.2s, color 0.2s;
}

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

/* Header */
header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header a.site-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

header a.site-title:hover {
  color: var(--accent);
}

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

footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.social-links {
  display: flex;
  gap: 1.25rem;
}

.social-links a {
  color: var(--muted);
  text-decoration: none;
}

.social-links a:hover {
  color: var(--accent);
}

/* Home page */
.home-bio {
  margin-bottom: 3rem;
}

.home-bio h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.home-bio p {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.975rem;
  line-height: 1.65;
}

.home-bio .bio-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
}

.home-bio .bio-links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}

.home-bio .bio-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Post list */
.post-list-heading {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

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

.post-list li {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

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

.post-date {
  flex-shrink: 0;
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  width: 6.5rem;
}

.post-list a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9375rem;
  line-height: 1.4;
}

.post-list a:hover {
  color: var(--accent);
}

/* Post page */
.post-header {
  margin-bottom: 2.5rem;
}

.back-link {
  display: inline-block;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2rem;
}

.back-link:hover {
  color: var(--accent);
}

.post-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 0.75rem;
}

.post-meta {
  font-size: 0.875rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.post-tag {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--code-bg);
  padding: 0.125rem 0.5rem;
  border-radius: 3px;
  font-family: var(--font-mono);
}

/* Post content */
.post-content {
  margin-top: 2.5rem;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 2rem 0 0.75rem;
}

.post-content h1 {
  font-size: 1.5rem;
}

.post-content h2 {
  font-size: 1.25rem;
}

.post-content h3 {
  font-size: 1.1rem;
}

.post-content h4 {
  font-size: 1rem;
}

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

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

.post-content a:hover {
  opacity: 0.8;
}

.post-content strong {
  font-weight: 600;
}

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

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

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

.post-content blockquote p:last-child {
  margin-bottom: 0;
}

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

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

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

.post-content pre {
  background: var(--pre-bg);
  color: var(--pre-text);
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.post-content th,
.post-content td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.post-content th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Post nav */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
  font-size: 0.875rem;
}

.post-nav a {
  color: var(--muted);
  text-decoration: none;
  max-width: 45%;
  line-height: 1.4;
}

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

.post-nav .nav-older {
  text-align: right;
  margin-left: auto;
}

/* Syntax highlighting (Rouge) */
.highlight .c,
.highlight .c1,
.highlight .cm {
  color: #6a9955;
}

.highlight .k,
.highlight .kd,
.highlight .kn {
  color: #569cd6;
}

.highlight .s,
.highlight .s1,
.highlight .s2 {
  color: #ce9178;
}

.highlight .mi,
.highlight .mf {
  color: #b5cea8;
}

.highlight .nb {
  color: #4ec9b0;
}

.highlight .nc {
  color: #4ec9b0;
}

.highlight .nf {
  color: #dcdcaa;
}

.highlight .o,
.highlight .ow {
  color: #d4d4d4;
}

.highlight .p {
  color: #d4d4d4;
}

.highlight .nn {
  color: #4ec9b0;
}

.highlight .na {
  color: #9cdcfe;
}

/* Series — home page grouping */
.series-group {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.series-group:last-child {
  border-bottom: none;
}

.series-group-content {
  flex: 1;
}

.series-label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.series-parts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.series-parts li {
  padding-left: 0.9rem;
  border-left: 2px solid var(--border);
}

.series-parts li a {
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.series-parts li a:hover {
  color: var(--accent);
}

/* Series — in-post navigation panel */
.series-nav {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.series-nav-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6rem;
}

.series-nav-count {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.series-nav-list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.series-nav-list li {
  font-size: 0.9rem;
  margin: 0;
}

.series-nav-list a {
  color: var(--accent);
  text-decoration: none;
}

.series-nav-list a:hover {
  text-decoration: underline;
}

.series-nav-current span {
  color: var(--text);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 600px) {
  header {
    margin-bottom: 2rem;
  }

  .post-title {
    font-size: 1.4rem;
  }

  .post-list li {
    flex-direction: column;
    gap: 0.2rem;
  }

  .post-date {
    width: auto;
  }

  footer .container {
    flex-direction: column;
    align-items: flex-start;
  }
}