:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --text-meta: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #e2e8f0;
  --header-bg: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  --header-text: #f1f5f9;
  --header-link: #93c5fd;
  --code-bg: #f1f5f9;
  --code-border: #e2e8f0;
  --blockquote-border: #93c5fd;
  --blockquote-text: #64748b;
  --table-border: #e2e8f0;
  --table-stripe: #f8fafc;
  --highlight-bg: #fff;
  --rouge-bg: #f1f5f9;
  --link-visited: #7c3aed;
  --focus-ring: rgba(37, 99, 235, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --text: #e2e8f0;
    --text-light: #94a3b8;
    --text-meta: #64748b;
    --primary: #60a5fa;
    --primary-hover: #93bbfc;
    --border: #334155;
    --header-bg: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    --header-text: #f1f5f9;
    --header-link: #93c5fd;
    --code-bg: #1e293b;
    --code-border: #334155;
    --blockquote-border: #3b82f6;
    --blockquote-text: #94a3b8;
    --table-border: #334155;
    --table-stripe: #1e293b;
    --highlight-bg: #1e293b;
    --rouge-bg: #1e293b;
    --link-visited: #a78bfa;
    --focus-ring: rgba(96, 165, 250, 0.3);
  }
}

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

body, h1, h2, h3, h4, h5, h6,
p, blockquote, pre, hr,
dl, dd, ol, ul, figure {
  margin: 0;
  padding: 0;
}

body {
  font: 400 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  -webkit-text-size-adjust: 100%;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
p, blockquote, pre,
ul, ol, dl, figure,
.highlight {
  margin-bottom: 1rem;
}

main {
  display: block;
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
}

figure > img {
  display: block;
}

figcaption {
  font-size: 0.875rem;
  color: var(--text-light);
}

ul, ol {
  margin-left: 1.875rem;
}

li > ul,
li > ol {
  margin-bottom: 0;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; margin-top: 2rem; }
h3 { font-size: 1.25rem; margin-top: 1.5rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

a {
  color: var(--primary);
  text-decoration: none;
}

a:visited {
  color: var(--link-visited);
}

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

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

blockquote {
  color: var(--blockquote-text);
  border-left: 4px solid var(--blockquote-border);
  padding-left: 1rem;
  font-style: italic;
}

blockquote > :last-child {
  margin-bottom: 0;
}

pre, code {
  font-size: 0.875rem;
  border: 1px solid var(--code-border);
  border-radius: 4px;
  background-color: var(--code-bg);
}

code {
  padding: 0.125rem 0.375rem;
}

pre {
  padding: 0.75rem 1rem;
  overflow-x: auto;
  line-height: 1.45;
}

pre > code {
  border: 0;
  padding: 0;
  background: none;
}

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

.wrapper {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media screen and (max-width: 600px) {
  .wrapper {
    padding: 0 1rem;
  }
}

table {
  margin-bottom: 1.5rem;
  width: 100%;
  text-align: left;
  color: var(--text);
  border-collapse: collapse;
  border: 1px solid var(--table-border);
}

table tr:nth-child(even) {
  background-color: var(--table-stripe);
}

table th, table td {
  padding: 0.5rem 1rem;
  border: 1px solid var(--table-border);
}

table th {
  font-weight: 600;
  background-color: var(--code-bg);
}

/* Header */

.site-header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0.75rem 0;
}

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

.site-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--header-text);
  letter-spacing: -0.5px;
}

.site-title:hover {
  color: var(--header-link);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
}

.nav-trigger {
  display: none;
}

.menu-icon {
  display: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--header-text);
  line-height: 1;
  user-select: none;
}

.trigger {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.page-link {
  color: var(--header-link);
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
}

.page-link:hover {
  color: #ffffff;
  text-decoration: none;
}

@media screen and (max-width: 600px) {
  .site-header .wrapper {
    flex-wrap: wrap;
  }

  .menu-icon {
    display: block;
  }

  .trigger {
    display: none;
    flex-direction: column;
    width: 100%;
    padding: 0.75rem 0 0.25rem;
    gap: 0.5rem;
  }

  .nav-trigger:checked ~ .trigger {
    display: flex;
  }

  .page-link {
    display: block;
    padding: 0.25rem 0;
  }
}

/* Footer */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  background: var(--bg-card);
}

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

.footer-copy {
  font-size: 0.875rem;
  color: var(--text-light);
}

.footer-social {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-social a {
  font-size: 0.875rem;
  color: var(--text-light);
}

.footer-social a:hover {
  color: var(--primary);
}

@media screen and (max-width: 600px) {
  .footer-content {
    flex-direction: column;
    text-align: center;
  }
}

/* Page content */

.page-content {
  padding: 2.5rem 0;
  flex: 1;
}

.page-heading {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}

/* Post list (home) */

.post-list-heading {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.post-list > li {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

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

.post-meta {
  font-size: 0.8125rem;
  color: var(--text-meta);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.post-link {
  display: block;
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

.post-excerpt {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text-light);
  line-height: 1.6;
}

.post-excerpt p {
  margin-bottom: 0;
}

/* Single post */

.post-header {
  margin-bottom: 2rem;
}

.post-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
  color: var(--text);
}

@media screen and (max-width: 600px) {
  .post-title {
    font-size: 1.5rem;
  }
}

.post-content {
  margin-bottom: 2rem;
  line-height: 1.75;
}

/* Syntax highlighting (pygments/rouge) */

.highlight {
  background: var(--highlight-bg);
}

.highlighter-rouge .highlight {
  background: var(--rouge-bg);
}

.highlight .c  { color: #64748b; font-style: italic; }
.highlight .err { color: #ef4444; background-color: #fef2f2; }
.highlight .k  { color: #7c3aed; font-weight: 600; }
.highlight .o  { color: #64748b; font-weight: 600; }
.highlight .cm { color: #64748b; font-style: italic; }
.highlight .cp { color: #f59e0b; font-weight: 600; }
.highlight .c1 { color: #64748b; font-style: italic; }
.highlight .cs { color: #64748b; font-weight: 600; font-style: italic; }
.highlight .gd { color: #000; background-color: #fdd; }
.highlight .gd .x { color: #000; background-color: #faa; }
.highlight .ge { font-style: italic; }
.highlight .gr { color: #ef4444; }
.highlight .gh { color: #64748b; }
.highlight .gi { color: #000; background-color: #dfd; }
.highlight .gi .x { color: #000; background-color: #afa; }
.highlight .go { color: #94a3b8; }
.highlight .gp { color: #555; }
.highlight .gs { font-weight: 600; }
.highlight .gu { color: #94a3b8; }
.highlight .gt { color: #ef4444; }
.highlight .kc { color: #7c3aed; font-weight: 600; }
.highlight .kd { color: #7c3aed; font-weight: 600; }
.highlight .kp { color: #7c3aed; font-weight: 600; }
.highlight .kr { color: #7c3aed; font-weight: 600; }
.highlight .kt { color: #0891b2; font-weight: 600; }
.highlight .m  { color: #059669; }
.highlight .s  { color: #dc2626; }
.highlight .na { color: #0d9488; }
.highlight .nb { color: #2563eb; }
.highlight .nc { color: #0891b2; font-weight: 600; }
.highlight .no { color: #0d9488; }
.highlight .ni { color: #7c3aed; }
.highlight .ne { color: #ef4444; font-weight: 600; }
.highlight .nf { color: #ef4444; font-weight: 600; }
.highlight .nn { color: #64748b; }
.highlight .nt { color: #2563eb; }
.highlight .nv { color: #0d9488; }
.highlight .ow { font-weight: 600; }
.highlight .w  { color: #cbd5e1; }
.highlight .mf { color: #059669; }
.highlight .mh { color: #059669; }
.highlight .mi { color: #059669; }
.highlight .mo { color: #059669; }
.highlight .sb { color: #dc2626; }
.highlight .sc { color: #dc2626; }
.highlight .sd { color: #dc2626; }
.highlight .s2 { color: #dc2626; }
.highlight .se { color: #dc2626; }
.highlight .sh { color: #dc2626; }
.highlight .si { color: #dc2626; }
.highlight .sx { color: #dc2626; }
.highlight .sr { color: #059669; }
.highlight .s1 { color: #dc2626; }
.highlight .ss { color: #7c3aed; }
.highlight .bp { color: #64748b; }
.highlight .vc { color: #0d9488; }
.highlight .vg { color: #0d9488; }
.highlight .vi { color: #0d9488; }
.highlight .il { color: #059669; }