@import url("https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600&family=Source+Serif+4:opsz,wght@8..60,400..700&display=swap");

:root {
  --bg: #fdf9f3;
  --text: #2c2420;
  --muted: #7a6d63;
  --border: rgba(35, 92, 176, 0.28);
  --accent: #235cb0;
  --accent-soft: #e6eefb;
  --max-width: 740px;
  --gutter: clamp(20px, 5vw, 52px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Serif 4", "Times New Roman", serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.85;
  font-size: 17px;
}

.bg-waves {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.35;
}

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

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

.nav a {
  text-decoration: none;
  color: var(--text);
}

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

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

.nav {
  border-bottom: 1px solid var(--border);
  background: rgba(253, 249, 243, 0.9);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 19px;
  font-weight: 500;
}

.nav-links {
  display: flex;
  gap: 18px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-family: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
}

.nav-links a[aria-current="page"] {
  color: var(--muted);
}

.main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 70px var(--gutter) 90px;
}

.home {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
}

.profile img {
  width: 250px;
  height: 250px;
  border-radius: 12px;
  object-fit: cover;
  object-position: center 70%;
  border: 1px solid var(--border);
  background: #f0e6dc;
}

.name {
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: clamp(30px, 5vw, 46px);
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.bio {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 19px;
}

.home-announcement {
  margin: 0 0 18px;
  display: block;
  color: var(--text);
  font-size: 17px;
  line-height: 1.85;
}

.new-badge {
  display: inline-block;
  font-family: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 6px;
  border: 1px solid #ad1f1f;
  background: #ad1f1f;
  color: #fff;
  border-radius: 4px;
  margin-right: 8px;
  line-height: 1.2;
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}

.icon-link svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  opacity: 0.8;
}

.icon-link span {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.section {
  margin-top: 50px;
}

.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
  margin: 0 0 18px;
  font-family: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
}

.blog-year-group + .blog-year-group {
  margin-top: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.blog-year-title {
  margin-bottom: 12px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.list-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item strong {
  display: block;
  font-size: 16px;
  margin-bottom: 6px;
}

.pub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pub-title {
  margin: 0;
  font-weight: 600;
}

.pub-authors {
  color: var(--muted);
  display: block;
}

.bibtex-btn {
  margin-top: 0;
  align-self: center;
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--text);
  font-family: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  position: relative;
}

.bibtex-btn:hover {
  color: var(--accent);
}

.confetti-burst {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  font-size: 20px;
  animation: confetti-pop 900ms ease-out forwards;
}

@keyframes confetti-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -120%) scale(1.1);
    opacity: 0;
  }
}

.meta {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-family: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
}

.author-self {
  font-weight: 600;
  color: var(--text);
}

.post-content {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-size: 18px;
  line-height: 1.9;
}

.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: "Source Serif 4", "Times New Roman", serif;
  margin: 38px 0 10px;
  color: var(--text);
}

.post-content h2 {
  font-size: 26px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.post-content h3 {
  font-size: 21px;
}

.post-content p,
.post-content ul,
.post-content ol {
  color: var(--text);
}

.post-content ul,
.post-content ol {
  padding-left: 20px;
}

.post-content code {
  font-family: "SFMono-Regular", ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft);
  padding: 2px 6px;
  border-radius: 6px;
}

.post-content pre {
  background: #1f1814;
  color: #f7efe8;
  padding: 16px;
  border-radius: 10px;
  overflow: auto;
}

.post-content pre code {
  background: transparent;
  padding: 0;
}

.post-content iframe {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.figure {
  margin: 26px 0;
}

.figure img {
  width: 100%;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f7efe8;
}

.figure figcaption {
  margin-top: 10px;
  font-size: 0.9em;
  color: var(--muted);
  text-align: center;
}

.marginnote {
  float: none;
  width: 100%;
  margin: 16px 0;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9em;
  color: var(--muted);
}

.footnotes {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9em;
  color: var(--muted);
}

.footnotes ol {
  padding-left: 20px;
}

.footnotes li {
  margin-bottom: 10px;
}

.footnote-ref {
  text-decoration: none;
  color: var(--accent);
}

.footnote-backref {
  margin-left: 6px;
  color: var(--muted);
  text-decoration: none;
}

sup {
  font-size: 0.75em;
}

.post-content blockquote {
  margin: 24px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--muted);
}

.post-content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* Center MathJax display equations */
.math-display {
  text-align: center;
  margin: 1.2em 0;
  color: var(--text);
}

.math-display .mjx-container {
  display: inline-block !important;
  color: inherit;
}

.mjx-container[jax="CHTML"][display="true"] {
  display: block;
  text-align: center;
}

/* KaTeX inline math stability */
.katex {
  font-size: 1em;
  line-height: 1;
}

.katex .vlist {
  line-height: 1;
}

.katex-display {
  margin: 1.1em 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.footer {
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px var(--gutter) 40px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}

.reveal {
  opacity: 1;
  transform: none;
}

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

  .home {
    grid-template-columns: 1fr;
  }

  .profile img {
    width: 200px;
    height: 200px;
  }

  .marginnote {
    float: none;
    width: 100%;
    margin: 12px 0;
  }
}
