:root {
  --bg: #0B0F1A;
  --surface: #131929;
  --border: #1E2D4A;
  --text: #C8D4EC;
  --text-dim: #6B7FA8;
  --accent: #4F8EF7;
  --accent-dim: #1E3560;
  --heading: #E8EEFA;
  --tag-bg: #0F1E3A;
  --tag-text: #5B8DEF;
  --mono: 'DM Mono', 'Courier New', monospace;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --max: 740px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F0F4FF;
    --surface: #FFFFFF;
    --border: #C8D4EC;
    --text: #1C2A4A;
    --text-dim: #5A6A8A;
    --accent: #2563EB;
    --accent-dim: #DBEAFE;
    --heading: #0B1630;
    --tag-bg: #EBF2FF;
    --tag-text: #1D4ED8;
  }
}

:root[data-theme="dark"] {
  --bg: #0B0F1A; --surface: #131929; --border: #1E2D4A;
  --text: #C8D4EC; --text-dim: #6B7FA8; --accent: #4F8EF7;
  --accent-dim: #1E3560; --heading: #E8EEFA;
  --tag-bg: #0F1E3A; --tag-text: #5B8DEF;
}

:root[data-theme="light"] {
  --bg: #F0F4FF; --surface: #FFFFFF; --border: #C8D4EC;
  --text: #1C2A4A; --text-dim: #5A6A8A; --accent: #2563EB;
  --accent-dim: #DBEAFE; --heading: #0B1630;
  --tag-bg: #EBF2FF; --tag-text: #1D4ED8;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* ── Nav ── */
.nav {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-logo {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.02em;
}
.nav-logo span { color: var(--accent); }
.nav-links {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.nav-links a { color: var(--text-dim); }
.nav-links a:hover { color: var(--heading); text-decoration: none; }

/* ── Page header ── */
.page-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-family: var(--mono);
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin-bottom: 0.5rem;
}
.page-header p {
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ── Post list ── */
.post-list {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

.post-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 0.5rem 2rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}
.post-item:last-child { border-bottom: none; }

.post-meta-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.post-tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 0.2em 0.6em;
  border-radius: 3px;
  border: 1px solid var(--accent-dim);
}
.post-read-time {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.post-title {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.02em;
  line-height: 1.4;
  margin-bottom: 0.35rem;
}
.post-title a { color: inherit; }
.post-title a:hover { color: var(--accent); text-decoration: none; }

.post-excerpt {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 55ch;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 0.1rem;
}

/* ── Article page ── */
.article-wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.article-eyebrow {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.back-link {
  font-size: 0.82rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

.article-header { margin-bottom: 2.5rem; }

.article-header h1 {
  font-family: var(--mono);
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.03em;
  text-wrap: balance;
  line-height: 1.25;
  margin-bottom: 1rem;
}

.article-byline {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.article-byline .sep { opacity: 0.4; }

/* ── Article body typography ── */
.article-body { max-width: 65ch; }

.article-body p { margin-bottom: 1.4rem; }
.article-body p:last-child { margin-bottom: 0; }

.article-body h2 {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: -0.02em;
  margin: 2.5rem 0 0.8rem;
}
.article-body h3 {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--heading);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 2rem 0 0.6rem;
}

.article-body ul, .article-body ol {
  padding-left: 1.4rem;
  margin-bottom: 1.4rem;
}
.article-body li { margin-bottom: 0.4rem; }

.article-body code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}

.article-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin-bottom: 1.4rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.2rem;
  margin: 1.8rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.article-body strong { color: var(--heading); font-weight: 600; }

.article-body a { color: var(--accent); }

hr.article-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem 0;
}

/* ── Related posts ── */
.related-posts {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.related-posts-title {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1rem;
}
.related-posts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.related-post-link {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}
.related-post-link:hover { color: var(--accent); text-decoration: none; }
.related-post-link::before {
  content: '→';
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--accent); }
.footer-nav {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
}
.footer-nav a { color: var(--text-dim); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); }
.dzen-follow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  transition: border-color 0.15s, color 0.15s;
}
.dzen-follow:hover { border-color: var(--accent); color: var(--accent); }
.dzen-follow svg { flex-shrink: 0; }

@media (max-width: 520px) {
  .post-item { grid-template-columns: 1fr; }
  .post-date { display: none; }
  .post-meta-top { flex-wrap: wrap; }
}
