@import url('https://fonts.googleapis.com/css2?family=Crimson+Pro:ital,wght@0,300;0,400;0,600;1,300;1,400&family=JetBrains+Mono:wght@400;500&family=DM+Sans:wght@300;400;500&display=swap');

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg:          #0e0e10;
  --bg-2:        #17171a;
  --bg-3:        #1e1e22;
  --border:      #2a2a30;
  --text:        #e8e6e0;
  --text-dim:    #8a8890;
  --text-faint:  #4a4858;
  --accent:      #c8a96e;
  --accent-dim:  #8a7045;
  --accent-glow: rgba(200,169,110,0.12);
  --code-bg:     #13131a;
  --font-serif:  'Crimson Pro', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
  --radius:      6px;
  --max-w:       740px;
}

[data-theme="light"] {
  --bg:          #f5f3ee;
  --bg-2:        #eceae4;
  --bg-3:        #e2e0da;
  --border:      #d0cdc6;
  --text:        #1a1916;
  --text-dim:    #5a5750;
  --text-faint:  #9a9890;
  --accent:      #7a5c2e;
  --accent-dim:  #a87c45;
  --accent-glow: rgba(122,92,46,0.10);
  --code-bg:     #e8e5de;
}

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s, color 0.25s;
}

body { min-height: 100vh; }

/* ── Layout ──────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.site-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 300;
  letter-spacing: 0.03em;
  color: var(--text);
  text-decoration: none;
}

.site-logo span {
  color: var(--accent);
}

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

nav a {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-dim);
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.15s;
}

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

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

/* ── Home ────────────────────────────────────────────── */
.hero {
  padding: 5rem 0 3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 300;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 1.25rem;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-dim);
  max-width: 520px;
  line-height: 1.7;
}

/* ── Post List ───────────────────────────────────────── */
.post-list { list-style: none; }

.post-item {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border);
}

.post-item:first-child { border-top: 1px solid var(--border); }

.post-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.post-item h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 0.4rem;
}

.post-item h2 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}

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

.post-item p {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.65;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.6rem;
  margin-right: 0.3rem;
}

/* ── Article ─────────────────────────────────────────── */
.article-header {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.article-header .post-meta { margin-bottom: 0.75rem; }

.article-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 300;
  line-height: 1.25;
  margin-bottom: 1rem;
}

.article-header .abstract {
  font-size: 1rem;
  color: var(--text-dim);
  line-height: 1.75;
  font-style: italic;
  font-family: var(--font-serif);
  border-left: 2px solid var(--accent-dim);
  padding-left: 1.25rem;
}

/* ── Prose ───────────────────────────────────────────── */
.prose {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.85;
  color: var(--text);
}

.prose h2 {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 3rem 0 1rem;
  color: var(--text);
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.prose h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text);
}

.prose p { margin-bottom: 1.4rem; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose blockquote {
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
  color: var(--text-dim);
}

.prose strong { color: var(--text); font-weight: 600; }
.prose em { font-style: italic; }

/* ── Math (KaTeX) ────────────────────────────────────── */
.math-block {
  overflow-x: auto;
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.katex { font-size: 1.1em; }
.katex-display { overflow-x: auto; }

/* ── Code blocks ─────────────────────────────────────── */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--accent);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  line-height: 1.6;
}

/* ── Pyodide Scratchpad ──────────────────────────────── */
.scratchpad {
  margin: 2.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
}

.scratchpad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.scratchpad-header .dots { display: flex; gap: 6px; }
.scratchpad-header .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.scratchpad textarea {
  width: 100%;
  min-height: 140px;
  background: var(--code-bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  border: none;
  padding: 1rem 1.25rem;
  resize: vertical;
  outline: none;
}

.scratchpad-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.run-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 5px 14px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.04em;
  font-weight: 500;
  transition: opacity 0.15s;
  white-space: nowrap;
}

.run-btn:hover { opacity: 0.85; }
.run-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.py-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
}

.scratchpad-output {
  min-height: 2rem;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  background: var(--code-bg);
}

.scratchpad-output.error { color: #e06c6c; }
.scratchpad-output.has-plot { padding: 0; }
.scratchpad-output canvas,
.scratchpad-output img { max-width: 100%; display: block; }

/* ── Plot container ──────────────────────────────────── */
.plot-container {
  margin: 2rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  margin-top: 6rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-align: center;
}
