:root[data-theme="light"] {
  --text: #0a0a0a;
  --text-soft: #1c1c1c;
  --muted: #555555;
  --link: #b31b1b;
  --link-hover: #8a1414;
  --border: #dcdcdc;
  --border-hover: #b4b4b4;
  --bg: #ffffff;
  --bg-alt: #f4f4f4;
  --pub-bg: #fafafa;
  --card-bg: #fbfbfb;
  --card-bg-hover: #efefef;
  --code-bg: #f1f1f1;
  --code-border: #d8d8d8;
}
:root[data-theme="dark"] {
  --text: #f3f4f6;
  --text-soft: #dfe2e7;
  --muted: #a4adc0;
  --link: #8cc1ff;
  --link-hover: #b6d5ff;
  --border: #34363b;
  --border-hover: #4d5057;
  --bg: #1d1e20;
  --bg-alt: #26272a;
  --pub-bg: #222326;
  --card-bg: #232427;
  --card-bg-hover: #2c2d31;
  --code-bg: #2a2b2e;
  --code-border: #34363b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.container { max-width: 820px; margin: 0 auto; padding: 1.25rem 1.25rem 0; }

/* Top nav: flat single row, evenly gapped, right-aligned */
nav.top {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1.6rem;
  padding: 1rem 0 2.25rem;
  font-size: 0.98rem;
}
nav.top a, nav.top button {
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  transition: color 0.15s ease;
}
nav.top a:hover, nav.top button:hover { color: var(--link); text-decoration: none; }
nav.top a.active { color: var(--text); }
nav.top i { font-size: 1.05rem; }

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

/* Profile area: name+bio on left, photo on right */
.profile-row {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 2rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
.profile-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.18);
}
h1.name {
  font-size: 2.6rem;
  font-weight: 300;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
h1.name strong { font-weight: 700; }
p.desc {
  color: var(--muted);
  font-size: 1rem;
  margin: 0 0 1.25rem;
}
h2 {
  font-size: 1.45rem;
  font-weight: 500;
  margin: 2.75rem 0 1.1rem;
  letter-spacing: -0.015em;
  color: var(--text);
}
p { margin: 0 0 1rem; color: var(--text-soft); }
ul { padding-left: 1.25rem; margin: 0 0 1rem; color: var(--text-soft); }
li { margin: 0.3rem 0; }

/* Card pattern (publications, blog posts, etc.) */
.card,
.pub {
  display: block;
  padding: 1.5rem 1.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  margin-bottom: 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.card:hover {
  border-color: var(--border-hover);
  background: var(--card-bg-hover);
  text-decoration: none;
  color: inherit;
}
.card-date,
.pub .venue {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin: 0 0 0.55rem;
  font-style: normal;
}
.pub .venue .star {
  font-size: 0.7em;
  color: #ffd700;
  text-shadow: 0 0 4px rgba(255, 215, 0, 0.8), 0 0 8px rgba(255, 215, 0, 0.5);
  letter-spacing: normal;
  text-transform: none;
}
.card-title,
.pub .title {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 0.55rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.card-excerpt {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.6;
  margin: 0 0 0.6rem;
}
.card-meta,
.pub .authors {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0 0 0.5rem;
}
.pub .authors .me { color: var(--text-soft); font-weight: 600; }

/* Publication: image on left, content on right inside the card */
.pub {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 1.4rem;
  align-items: center;
}
.pub:hover {
  border-color: var(--border-hover);
  background: var(--card-bg-hover);
}
.pub img.preview {
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: var(--pub-bg);
  padding: 4px;
  border: 1px solid var(--border);
}
.pub .pub-body { min-width: 0; }
.pub .links { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pub .links a {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-soft);
  background: transparent;
  transition: all 0.15s ease;
}
.pub .links a:hover {
  color: var(--link);
  border-color: var(--link);
  text-decoration: none;
}

/* Highlights — compact dated rows */
.highlights .row {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 1rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.96rem;
  color: var(--text-soft);
}
.highlights .row:last-child { border-bottom: 1px solid var(--border); }
.highlights .date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Single post */
article.post h1 {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.4rem;
  color: var(--text);
}
article.post .post-meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}
article.post h2 {
  font-size: 1.45rem;
  margin: 2rem 0 0.8rem;
}
article.post h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 1.6rem 0 0.6rem;
}
article.post p, article.post li { color: var(--text-soft); }
article.post blockquote {
  border-left: 3px solid var(--border);
  margin: 1rem 0;
  padding: 0.3rem 0 0.3rem 1rem;
  color: var(--muted);
  font-style: italic;
}
article.post code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 3px;
  padding: 0.08em 0.35em;
  font-size: 0.92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
article.post pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
}
article.post pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}
article.post img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 0.75rem 0;
}
article.post hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}
article.post table {
  border-collapse: collapse;
  margin: 1rem 0;
}
article.post th, article.post td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
article.post th { background: var(--bg-alt); }

/* Math paper environments */
article.post .abstract,
article.post .theorem,
article.post .lemma,
article.post .corollary,
article.post .proposition,
article.post .definition,
article.post .proof {
  border-left: 3px solid var(--border);
  padding: 0.6rem 1rem;
  margin: 1.1rem 0;
  background: var(--bg-alt);
  border-radius: 0 4px 4px 0;
}
article.post .abstract { border-left-color: var(--muted); font-size: 0.96rem; }
article.post .theorem,
article.post .corollary,
article.post .proposition { border-left-color: var(--link); }
article.post .lemma { border-left-color: #7a9cc6; }
article.post .definition { border-left-color: var(--muted); background: transparent; padding-left: 1rem; }
article.post .proof {
  background: transparent;
  border-left: none;
  padding: 0;
  margin: 1rem 0;
  font-size: 0.97rem;
}
article.post .env-label {
  font-weight: 700;
  margin-right: 0.4rem;
}
article.post .env-label::after { content: "."; }
article.post .proof::after {
  content: " \25A0";
  color: var(--muted);
}

article.post .katex-display {
  margin: 1rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}
article.post .katex { font-size: 1.02em; }

article.post .bibliography {
  font-size: 0.92rem;
  color: var(--text-soft);
}
article.post .bibliography ol { padding-left: 1.4rem; }
article.post .bibliography li { margin: 0.45rem 0; }

@media (max-width: 640px) {
  .container { padding-top: 1rem; }
  .profile-row {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
  .profile-photo {
    max-width: 200px;
    margin: 0 auto;
    display: block;
  }
  .pub {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.2rem 1.2rem;
  }
  .pub img.preview { max-width: 220px; }
  .card, .pub { padding: 1.1rem 1.2rem; }
  h1.name { font-size: 2.05rem; }
  .card-title, .pub .title { font-size: 1.1rem; }
  .highlights .row { grid-template-columns: 1fr; gap: 0.15rem; padding: 0.8rem 0; }
  .highlights .date { font-size: 0.78rem; }
  nav.top { gap: 0.9rem; font-size: 1.05rem; }
  nav.top .left { font-size: 0.9rem; gap: 0.85rem; }
  article.post h1 { font-size: 1.6rem; }
}
