:root {
  color-scheme: light;
  --bg: #f9faf9;
  --surface: #f9faf9;
  --surface-raised: #ffffff;
  --surface-soft: #eef1ef;
  --text: #1f2421;
  --muted: #646b66;
  --line: #d8dedb;
  --line-strong: #bac4bf;
  --accent: #4f7174;
  --accent-strong: #35575b;
  --accent-warm: #875f73;
  --code-bg: #eef1ef;
  --shadow: 0 18px 42px rgba(48, 55, 51, 0.1);
  --measure: 740px;
  --wide: 1120px;
  --radius: 8px;
  --serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #333333;
  --surface: #3b3b3b;
  --surface-soft: #454545;
  --surface-raised: #404040;
  --text: #f4f1f3;
  --muted: #c8c1c6;
  --line: #555555;
  --line-strong: #6b6b6b;
  --accent: #9cc7c9;
  --accent-strong: #c3e3e4;
  --accent-warm: #e4b6cb;
  --code-bg: #2b2b2b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  line-height: 1.68;
  scroll-padding-top: 5rem;
  text-rendering: optimizeLegibility;
}

body {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 64%, transparent) 0, transparent 24rem),
    var(--bg);
  margin: 0;
  min-width: 320px;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-warm);
  outline-offset: 3px;
}

img,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
input {
  font: inherit;
}

button,
input,
.nav,
.button,
.post-meta,
.tag,
.eyebrow,
.toc,
.aside-box,
.site-footer {
  font-family: var(--sans);
}

.skip-link {
  background: var(--surface);
  color: var(--text);
  left: 1rem;
  padding: 0.5rem 0.75rem;
  position: absolute;
  top: -3rem;
  z-index: 10;
}

.skip-link:focus {
  top: 1rem;
}

.site-header {
  backdrop-filter: blur(14px);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-inner {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--wide);
  min-height: 4.25rem;
  padding: 0.75rem 1rem;
}

.brand {
  color: var(--text);
  display: inline-flex;
  font-family: var(--serif);
  font-size: 1.06rem;
  font-weight: 700;
  gap: 0.6rem;
  line-height: 1.1;
  text-decoration: none;
}

.nav {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.nav a,
.theme-toggle {
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.92rem;
  padding: 0.45rem 0.7rem;
  text-decoration: none;
}

.nav a:hover,
.theme-toggle:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.theme-toggle {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  min-width: 2.2rem;
}

.wrap {
  margin: 0 auto;
  max-width: var(--wide);
  padding: 0 1rem;
}

.hero {
  display: grid;
  gap: 3rem;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.82fr);
  min-height: min(610px, calc(100vh - 4.25rem));
  padding: 4.75rem 1rem 2.75rem;
}

.hero-copy {
  align-self: center;
  max-width: 680px;
}

.eyebrow {
  color: var(--accent-warm);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 0.75rem;
  text-transform: uppercase;
}

.hero h1,
.page-title {
  font-family: var(--serif);
  font-size: 4.8rem;
  font-weight: 620;
  letter-spacing: 0;
  line-height: 1;
  margin: 0;
}

.hero p {
  color: var(--muted);
  font-size: 1.12rem;
  margin: 1.2rem 0 0;
  max-width: 62ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: inline-flex;
  font-weight: 700;
  gap: 0.4rem;
  justify-content: center;
  min-height: 2.7rem;
  padding: 0.65rem 1rem;
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.button.secondary {
  background: var(--surface-raised);
  color: var(--text);
}

.button.secondary:hover {
  border-color: var(--line-strong);
  color: var(--accent-strong);
}

.hero-media {
  align-self: center;
}

.hero-media img {
  aspect-ratio: 1;
  margin: 0 auto;
  object-fit: contain;
  width: min(100%, 520px);
}

.section {
  border-top: 1px solid var(--line);
  padding: 2.75rem 0;
}

.section-header {
  align-items: end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2,
.listing-title {
  font-family: var(--serif);
  font-size: 2.15rem;
  font-weight: 620;
  line-height: 1.12;
  margin: 0;
}

.section-header p,
.muted {
  color: var(--muted);
}

.post-grid {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(67, 58, 35, 0.05);
  padding: 1.15rem;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.post-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.post-card h3 {
  font-family: var(--serif);
  font-size: 1.32rem;
  font-weight: 620;
  line-height: 1.22;
  margin: 0.45rem 0 0.6rem;
}

.post-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-card h3 a:hover {
  color: var(--accent-strong);
}

.post-card p {
  color: var(--muted);
  margin: 0;
}

.post-meta {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.88rem;
  gap: 0.45rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.tag {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0.2rem 0.55rem;
  text-decoration: none;
}

.page-cv {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.35fr);
  max-width: var(--wide);
}

.page-cv .article {
  max-width: none;
}

.page-cv .article-header {
  display: none;
}

.page-cv .prose {
  display: grid;
  gap: 2rem;
  line-height: 1.72;
}

.page-cv .prose h2 {
  border-top: 1px solid var(--line);
  font-size: 1.95rem;
  margin: 0;
  padding-top: 2rem;
}

.cv-profile {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2rem;
  grid-template-columns: 190px minmax(0, 1fr);
  padding: clamp(1.1rem, 3vw, 2rem);
}

.cv-photo-wrap {
  align-self: start;
}

.cv-photo {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
  width: 100%;
}

.cv-profile h1 {
  font-family: var(--serif);
  font-size: 1.95rem;
  font-weight: 620;
  line-height: 1.04;
  margin: 0;
  white-space: nowrap;
}

.cv-role {
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0.8rem 0 0;
}

.cv-affiliation {
  color: var(--muted);
  font-family: var(--sans);
  margin: 0.25rem 0 0;
}

.cv-link-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.2rem;
}

.cv-link {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  display: inline-flex;
  font-family: var(--sans);
  font-size: 0.92rem;
  gap: 0.45rem;
  min-height: 2.45rem;
  padding: 0.35rem 0.65rem 0.35rem 0.4rem;
  text-decoration: none;
}

.cv-link::before {
  align-items: center;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--accent-strong);
  content: attr(data-initial);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  height: 1.55rem;
  justify-content: center;
  width: 1.55rem;
}

.cv-actions {
  margin: 0;
}

.cv-education-card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(67, 58, 35, 0.05);
  padding: 1.1rem;
}

.cv-education-card + .cv-education-card {
  margin-top: -1rem;
}

.page-cv .cv-education-card h3 {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 620;
  margin: 0.1rem 0 0.35rem;
}

.cv-card-meta {
  align-items: start;
  color: var(--accent-warm);
  display: flex;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 800;
  gap: 1rem;
  justify-content: space-between;
  margin: 0;
  text-transform: uppercase;
}

.cv-card-meta span:last-child {
  text-align: right;
  white-space: nowrap;
}

.page-cv .cv-school {
  color: var(--text);
  font-family: var(--sans);
  font-weight: 700;
  margin: 0.25rem 0;
}

.cv-education-details {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.6rem;
}

.page-cv .cv-education-details p {
  margin: 0;
}

.cv-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.cv-chip {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  display: inline-flex;
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.38rem 0.68rem;
}

.article-shell {
  display: grid;
  gap: 3rem;
  grid-template-columns: minmax(0, var(--measure)) minmax(220px, 1fr);
  margin: 0 auto;
  max-width: var(--wide);
  padding: 3rem 1rem 4.5rem;
}

.article {
  min-width: 0;
}

.article-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.25rem;
  padding-bottom: 1.65rem;
}

.article-header .page-title {
  font-size: 3.55rem;
  line-height: 1.04;
}

.summary {
  color: var(--muted);
  font-size: 1.13rem;
  margin: 1rem 0 0;
}

.prose {
  font-size: 1.08rem;
  line-height: 1.76;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  color: var(--text);
  line-height: 1.18;
  margin: 2.3rem 0 0.8rem;
}

.prose h2 {
  font-family: var(--serif);
  font-size: 1.8rem;
  font-weight: 620;
}

.prose h3 {
  font-family: var(--serif);
  font-size: 1.32rem;
  font-weight: 620;
}

.heading-anchor {
  color: var(--muted);
  font-size: 0.8em;
  margin-left: 0.35rem;
  opacity: 0;
  text-decoration: none;
}

.prose h2:hover .heading-anchor,
.prose h3:hover .heading-anchor,
.prose h4:hover .heading-anchor {
  opacity: 1;
}

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose table,
.prose figure {
  margin: 1rem 0;
}

.prose li + li {
  margin-top: 0.25rem;
}

.prose code {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 0.35rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  padding: 0.08rem 0.25rem;
}

.code-block {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  padding: 1rem;
}

.code-block code {
  background: transparent;
  border: 0;
  padding: 0;
}

.prose blockquote {
  border-left: 4px solid var(--accent);
  color: var(--muted);
  padding-left: 1rem;
}

.callout {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent-warm);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.callout-title {
  color: var(--text);
  font-weight: 760;
  margin-bottom: 0.35rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  min-width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-soft);
}

.media-block {
  margin: 1.4rem 0;
}

.media-block img,
.media-block video,
.lite-video {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
}

figcaption {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.45rem;
}

.lite-video {
  cursor: pointer;
  display: grid;
  min-height: 220px;
  overflow: hidden;
  padding: 0;
  place-items: center;
  position: relative;
}

.lite-video img,
.lite-video iframe {
  border: 0;
  height: 100%;
  inset: 0;
  object-fit: cover;
  position: absolute;
  width: 100%;
}

.play-badge {
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-weight: 760;
  padding: 0.55rem 0.85rem;
  position: relative;
  z-index: 1;
}

.citation,
.footnote-ref {
  font-size: 0.82em;
  font-weight: 680;
}

.references,
.footnotes,
.backlinks {
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding-top: 1.25rem;
}

.references h2,
.footnotes h2,
.backlinks h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 0 0 0.75rem;
}

.references ol,
.footnotes ol,
.backlinks ul {
  margin: 0;
  padding-left: 1.4rem;
}

.bibliography-list {
  margin: 0.75rem 0 0;
  padding-left: 1.4rem;
}

.bibliography-list li + li {
  margin-top: 0.6rem;
}

.side-panel {
  align-self: start;
  display: grid;
  gap: 1rem;
  position: sticky;
  top: 5.5rem;
}

.toc,
.aside-box {
  border-left: 1px solid var(--line);
  padding-left: 1rem;
}

.toc h2,
.aside-box h2 {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0;
  margin: 0 0 0.55rem;
  text-transform: uppercase;
}

.toc ol,
.aside-box ul {
  display: grid;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc a,
.aside-box a {
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover,
.aside-box a:hover {
  color: var(--text);
}

.listing {
  margin: 0 auto;
  max-width: var(--wide);
  padding: 3rem 1rem 4.5rem;
}

.listing-header {
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.65rem;
  padding-bottom: 1.35rem;
}

.post-list {
  display: grid;
  gap: 1rem;
}

.search-box {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(67, 58, 35, 0.05);
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
  padding: 1rem;
}

.search-box input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  min-height: 2.65rem;
  padding: 0.55rem 0.85rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 2.15rem 1rem;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: var(--wide);
}

.math-display {
  overflow-x: auto;
  padding: 0.2rem 0;
}

@media (max-width: 860px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    justify-content: flex-start;
  }

  .hero,
  .article-shell {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 3rem;
  }

  .hero h1,
  .page-title {
    font-size: 3.25rem;
  }

  .article-header .page-title {
    font-size: 2.75rem;
  }

  .hero-media {
    order: -1;
  }

  .post-grid,
  .post-list {
    grid-template-columns: 1fr;
  }

  .cv-profile {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .side-panel {
    position: static;
  }

  .toc,
  .aside-box {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 1rem;
  }
}

@media (max-width: 520px) {
  .header-inner,
  .wrap,
  .hero,
  .article-shell,
  .listing {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .nav a,
  .theme-toggle {
    padding: 0.35rem 0.5rem;
  }

  .hero h1,
  .page-title {
    font-size: 2.55rem;
  }

  .article-header .page-title {
    font-size: 2.25rem;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-header h2,
  .listing-title {
    font-size: 1.9rem;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

  .cv-profile {
    grid-template-columns: 1fr;
  }

  .cv-profile h1 {
    white-space: normal;
  }

  .cv-photo {
    width: min(100%, 220px);
  }

  .cv-link-grid,
  .cv-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .cv-link {
    width: 100%;
  }

}
