:root {
  --hdr-bg:     #18181b;
  --hdr-fg:     #fafafa;
  --hdr-muted:  #a1a1aa;
  --accent:     #f97316;
  --bg:         #fafafa;
  --surface:    #ffffff;
  --text:       #18181b;
  --muted:      #71717a;
  --border:     #e4e4e7;
  --link:       #2563eb;
  --code-bg:    #f4f4f5;
  --radius:     4px;
  --max-w:      740px;
  --header-h:   54px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--hdr-bg);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 1px 12px rgba(0,0,0,0.35);
}

.site-header .inner {
  max-width: calc(var(--max-w) + 3rem);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--hdr-fg);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.site-nav {
  display: flex;
  align-items: center;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.site-nav::-webkit-scrollbar { display: none; }

.site-nav a {
  color: var(--hdr-muted);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0 0.75rem;
  height: var(--header-h);
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.site-nav a:hover   { color: var(--hdr-fg); }
.site-nav a.active  { color: var(--hdr-fg); border-bottom-color: var(--accent); }

/* ── Layout ──────────────────────────────────────────────────────────────── */

main { min-height: calc(100vh - var(--header-h) - 90px); }

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

/* ── Article list ────────────────────────────────────────────────────────── */

.article-list { list-style: none; }

.article-item {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}
.article-item:first-child { padding-top: 0.25rem; }
.article-item:last-child  { border-bottom: none; }

.article-item h2 {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.35rem;
}
.article-item h2 a { color: var(--text); text-decoration: none; }
.article-item h2 a:hover { color: var(--link); }

.article-summary {
  color: #3f3f46;
  margin-bottom: 0.75rem;
  line-height: 1.65;
}

.read-more {
  font-size: 0.875rem;
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}
.read-more:hover { text-decoration: underline; }

/* ── Meta row ────────────────────────────────────────────────────────────── */

.meta {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.meta a { color: var(--muted); text-decoration: none; }
.meta a:hover { color: var(--link); }
.meta .sep { color: var(--border); }

/* ── Pill ────────────────────────────────────────────────────────────────── */

.pill {
  display: inline-block;
  background: var(--code-bg);
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.15em 0.55em;
  border-radius: 3px;
  text-decoration: none;
  border: 1px solid var(--border);
  line-height: 1.6;
}
.pill:hover { background: var(--border); color: var(--text); }

/* ── Full article ────────────────────────────────────────────────────────── */

.article-header {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
.article-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 0.6rem;
}

.article-body { font-size: 1.02rem; line-height: 1.75; }

.article-body h1 { font-size: 1.65rem; margin: 2rem 0 0.75rem; letter-spacing: -0.02em; }
.article-body h2 { font-size: 1.35rem; margin: 1.75rem 0 0.65rem; }
.article-body h3 { font-size: 1.15rem; margin: 1.5rem 0 0.55rem; }
.article-body h4 { font-size: 1rem;    margin: 1.2rem 0 0.5rem;  }

.article-body p         { margin-bottom: 1.2rem; }
.article-body ul,
.article-body ol        { margin: 0.5rem 0 1.2rem 1.5rem; }
.article-body li        { margin-bottom: 0.3rem; }

.article-body a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article-body a:hover { color: #1d4ed8; }

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 1.5rem auto;
}

.article-body figure {
  margin: 1.5rem 0;
  text-align: center;
}
.article-body figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1.25rem;
  margin: 1.5rem 0;
  color: #52525b;
  background: var(--code-bg);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.article-body blockquote p { margin: 0; }

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

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: block;
  overflow-x: auto;
}
.article-body th, .article-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}
.article-body th { background: var(--code-bg); font-weight: 600; }

/* ── Code ────────────────────────────────────────────────────────────────── */

code, kbd, samp {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
}

.article-body :not(pre) > code {
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  color: #be185d;
}

.article-body pre {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.55;
  border: none;
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ── Notebook ────────────────────────────────────────────────────────────── */

.notebook .prompt        { display: none; }
.notebook .jp-Cell       { margin-bottom: 1.25rem; }

.notebook .input_area pre,
.notebook .input_area .highlight pre,
.notebook div.highlight pre {
  background: #1e1e2e;
  color: #cdd6f4;
  border: none;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.55;
  margin: 0;
}

.notebook .output_area pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0;
}

.notebook .output_area img {
  max-width: 100%;
  display: block;
  margin: 0.5rem 0;
}

.notebook .text_cell_render { line-height: 1.75; }

.notebook .cell.border-box-sizing { margin-bottom: 1.25rem; }

/* ── Article footer ──────────────────────────────────────────────────────── */

.article-tags {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.article-tags .label { font-size: 0.82rem; color: var(--muted); }

/* ── Prev / Next ─────────────────────────────────────────────────────────── */

.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.article-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
  display: block;
}
.article-nav a:hover { border-color: var(--link); background: var(--surface); }
.article-nav .next   { text-align: right; }

.nav-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.3rem;
}
.nav-title { font-size: 0.9rem; font-weight: 500; line-height: 1.4; }

/* ── Static page ─────────────────────────────────────────────────────────── */

.page-body h1:first-child {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* ── Section heading ─────────────────────────────────────────────────────── */

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
}

.list-subtitle {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-weight: 400;
}

/* ── Archives ────────────────────────────────────────────────────────────── */

.archive-year {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
.archive-year:first-of-type { margin-top: 0; }

.archive-entry {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid transparent;
}
.archive-date {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 96px;
  flex-shrink: 0;
}
.archive-entry a { color: var(--text); text-decoration: none; font-size: 0.975rem; }
.archive-entry a:hover { color: var(--link); }

/* ── Tag cloud ───────────────────────────────────────────────────────────── */

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.tag-cloud .pill { font-size: 0.9rem; }

/* ── Footer ──────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}
footer .inner {
  max-width: calc(var(--max-w) + 3rem);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
footer p { font-size: 0.82rem; color: var(--muted); }
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .article-header h1  { font-size: 1.5rem; }
  .article-nav        { grid-template-columns: 1fr; }
  .article-nav .next  { text-align: left; }
}
