:root {
  --bg: #fdfcfa;
  --fg: #1d1f24;
  --muted: #5d6470;
  --accent: #1f3f73;
  --accent-soft: #e8edf6;
  --rule: #e4e2dd;
  --warm: #9a4a1c;
  --warm-soft: #f6e9df;
  --code-bg: #f2f0eb;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e6e6e3;
    --muted: #9aa1ab;
    --accent: #8fb3ec;
    --accent-soft: #1f2836;
    --rule: #2a2d33;
    --warm: #e8a77c;
    --warm-soft: #33261d;
    --code-bg: #1d2025;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: currentColor; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; height: 3.5rem; font-family: var(--sans); }
.brand { font-weight: 600; color: var(--fg); font-size: 1rem; }
.nav ul { list-style: none; display: flex; gap: 1.25rem; margin: 0; padding: 0; font-size: 0.9rem; }
.nav ul a { color: var(--muted); white-space: nowrap; }
.brand { white-space: nowrap; }
.nav ul a:hover { color: var(--accent); }

/* Hero */
.hero { padding: 3.5rem 0 1rem; }
h1 { font-size: 2.6rem; line-height: 1.1; margin: 0 0 0.3rem; font-weight: 600; letter-spacing: -0.01em; }
.tagline { font-family: var(--sans); color: var(--muted); margin: 0 0 1.5rem; font-size: 1rem; }
.links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.btn {
  font-family: var(--sans); font-size: 0.88rem; font-weight: 500;
  padding: 0.4rem 0.9rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.btn:hover { border-color: var(--accent); }

/* Sections */
section { padding: 1.5rem 0; }
h2 {
  font-family: var(--sans); font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent);
  margin: 1rem 0 1.25rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--rule);
}
h3 { font-size: 1.08rem; font-weight: 600; margin: 0; }
.note { color: var(--muted); font-size: 0.9rem; margin-top: -0.5rem; }

/* News */
.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; padding: 0.3rem 0; }
.date { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); padding-top: 0.15rem; }

/* Publications */
.pubs { padding-left: 1.5rem; margin: 0; }
.pubs li { margin-bottom: 1.1rem; padding-left: 0.3rem; }
.pubs li::marker { color: var(--muted); font-family: var(--sans); font-size: 0.85rem; }
.pubs span { display: block; }
.pubs .title { font-weight: 600; }
.pubs .authors { color: var(--muted); font-size: 0.97rem; }
.pubs .venue { font-style: italic; font-size: 0.97rem; }

/* Entries */
.entry { margin-bottom: 1.4rem; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.when { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.role { margin: 0.1rem 0 0.3rem; color: var(--muted); font-style: italic; }
.entry p:not(.role) { margin: 0.2rem 0; }
.entry ul, .awards { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.entry li, .awards li { margin-bottom: 0.3rem; }

.footer { border-top: 1px solid var(--rule); margin-top: 2rem; padding-top: 1rem; padding-bottom: 2rem; color: var(--muted); font-family: var(--sans); font-size: 0.85rem; }

@media (max-width: 640px) {
  body { font-size: 1rem; }
  h1 { font-size: 2.1rem; }
  .hero { padding-top: 2.25rem; }
  .nav ul { gap: 0.8rem; font-size: 0.82rem; }
  .nav ul li.opt { display: none; }
  .news li { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- Blog ---------- */
.nav ul a.active, .filters a.active { color: var(--accent); }
.more { font-family: var(--sans); font-size: 0.9rem; margin-top: 0.5rem; }
.empty { color: var(--muted); font-style: italic; }

.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--rule); }
.post-list li:last-child { border-bottom: 0; }
.post-list time { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); padding-top: 0.2rem; }
.post-link { font-weight: 600; color: var(--fg); }
.post-link:hover { color: var(--accent); }
.post-excerpt { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.97rem; }

.tag {
  display: inline-block; font-family: var(--sans); font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.1rem 0.5rem; border-radius: 999px; margin-left: 0.4rem; vertical-align: 0.15em;
  background: var(--accent-soft); color: var(--accent); border: 0;
}
.tag-personal { background: var(--warm-soft); color: var(--warm); }

.blog-head { padding: 3rem 0 0.5rem; }
.filters { display: flex; gap: 0.5rem; font-family: var(--sans); font-size: 0.88rem; }
.filters a { padding: 0.3rem 0.85rem; border-radius: 999px; color: var(--muted); border: 1px solid var(--rule); }
.filters a:hover { border-color: var(--accent); color: var(--accent); }
.filters a.active { background: var(--accent-soft); border-color: transparent; }

/* Single post */
.post-header { padding: 3rem 0 1rem; }
.post-header h1 { font-size: 2.2rem; }
.post-meta { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); margin: 0 0 0.6rem; }
.post-meta .tag { margin-left: 0.5rem; }
.post-subtitle { color: var(--muted); font-size: 1.15rem; margin: 0.4rem 0 0; font-style: italic; }
.post-body h2 { font-family: var(--serif); font-size: 1.45rem; text-transform: none; letter-spacing: 0; color: var(--fg); border: 0; margin: 2rem 0 0.6rem; padding: 0; font-weight: 600; }
.post-body h3 { font-size: 1.2rem; margin: 1.6rem 0 0.4rem; }
.post-body img { max-width: 100%; height: auto; border-radius: 6px; }
.post-body blockquote { margin: 1.2rem 0; padding: 0.1rem 1.1rem; border-left: 3px solid var(--rule); color: var(--muted); }
.post-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; }
code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 0.86em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 0.9rem 1.1rem; border-radius: 8px; overflow-x: auto; line-height: 1.5; font-size: 0.95rem; }
pre code { background: none; padding: 0; }
.highlight .c, .highlight .c1, .highlight .cm { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kc, .highlight .ow { color: var(--accent); font-weight: 600; }
.highlight .s, .highlight .s1, .highlight .s2 { color: var(--warm); }
.highlight .mi, .highlight .mf { color: var(--warm); }
.highlight .nf, .highlight .nc { color: var(--fg); font-weight: 600; }

@media (max-width: 640px) {
  .post-list li { grid-template-columns: 1fr; gap: 0.1rem; }
  .post-header h1 { font-size: 1.75rem; }
}
.pubs .title a { color: var(--fg); }
.pubs .title a:hover { color: var(--accent); }


/* Portrait */
.hero-grid { display: grid; grid-template-columns: 1fr 250px; gap: 2.5rem; align-items: start; }
.portrait { width: 100%; height: auto; border-radius: 10px; display: block; margin-top: 0.6rem; }
@media (max-width: 720px) {
  .hero-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .portrait { order: -1; width: 180px; margin-top: 0; }
}

/* Key terms in the intro */
.hero strong { font-weight: 700; color: var(--fg); }
@media (prefers-color-scheme: dark) { .hero strong { color: #ffffff; } }
.nav ul { margin-left: auto; }
