:root {
  color-scheme: light;
  --color-primary: #2c5530;
  --color-primary-dark: #1e3d22;
  --color-secondary: #8b4f32;
  --color-accent: #a86538;
  --text-primary: #202833;
  --text-secondary: #566270;
  --text-muted: #7c8793;
  --background-primary: #fffefa;
  --background-panel: #fffefa;
  --background-soft: #f5efe0;
  --background-code: #f2ecdc;
  --border-light: #e6dfc9;
  --border-medium: #d6cab0;
  --font-family-sans: "Source Sans 3", "Helvetica Neue", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-family-serif: "Fraunces", Georgia, serif;
  --font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #bfdac5;
  --color-primary-dark: #d9ebdd;
  --color-secondary: #f0b08b;
  --color-accent: #ffc6a8;
  --text-primary: #e8edf3;
  --text-secondary: #bdc7d3;
  --text-muted: #8b98a7;
  --background-primary: #11161d;
  --background-panel: #11161d;
  --background-soft: #1b2430;
  --background-code: #161f29;
  --border-light: #2a3442;
  --border-medium: #3a495c;
}

html {
  font-size: 16px;
  overflow-x: hidden;
  background-color: var(--background-primary);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 1.5rem;
  font-family: var(--font-family-sans);
  font-size: 1.05rem;
  line-height: 1.72;
  color: var(--text-primary);
  background-color: var(--background-primary);
  overflow-x: hidden;
}

body.lightbox-open {
  overflow: hidden;
}

article {
  width: 100%;
  padding: 1.25rem 0 3rem;
}

section {
  width: 100%;
  padding: 0.5rem 0;
}

.content {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--background-panel);
}

.content > :first-child {
  margin-top: 1.25rem;
}

p {
  margin: 1rem 0;
  max-width: 70ch;
  overflow-wrap: anywhere;
}

ul,
ol {
  padding-left: 1.5rem;
  max-width: 70ch;
}

li {
  margin-top: 0.3rem;
  overflow-wrap: anywhere;
}

.content ul li::marker,
.content ol li::marker {
  color: var(--color-secondary);
}

header h1,
h1,
h2 {
  font-family: var(--font-family-serif);
}

header h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(2rem, 4.8vw, 3rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--color-primary);
  font-weight: 500;
}

section h1,
.content h1,
h1 {
  margin: 1.6rem 0 0.7rem;
  font-size: 1.5rem;
  color: var(--color-primary);
  font-weight: 500;
  letter-spacing: -0.01em;
}

h2 {
  margin: 2rem 0 0.65rem;
  padding-top: 0.4rem;
  font-size: 1.28rem;
  color: var(--color-primary);
  font-weight: 500;
  border-top: 1px solid var(--border-light);
}

h3 {
  margin: 1.15rem 0 0.35rem;
  color: var(--color-primary);
  font-size: 1.05rem;
  font-weight: 600;
}

h4,
h5,
h6 {
  color: var(--text-secondary);
}

blockquote {
  margin: 1.4rem 0;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 2px solid var(--border-medium);
  color: var(--text-secondary);
  font-style: italic;
}

table {
  width: 100%;
  margin: 1.4rem 0;
  border-collapse: collapse;
}

th,
td {
  padding: 0.65rem;
  border: 1px solid var(--border-light);
  text-align: left;
}

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

hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--border-light);
}

img {
  max-width: 100%;
  height: auto;
}

.zoomable-image {
  cursor: zoom-in;
}

.zoomable-image:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 3px;
}

pre,
.codehilite,
.highlight {
  margin: 1.4rem 0;
  background: var(--background-code);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow-x: auto;
}

pre {
  padding: 1rem;
}

.codehilite pre,
.highlight pre {
  margin: 0;
  padding: 1rem;
  background: none;
}

code {
  font-family: var(--font-family-mono);
  font-size: 0.92em;
}

a {
  color: var(--color-secondary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

.header-anchor {
  color: var(--text-muted);
  margin-left: 0.4em;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
}

h1:hover .header-anchor,
h2:hover .header-anchor,
h3:hover .header-anchor,
h4:hover .header-anchor,
h5:hover .header-anchor,
h6:hover .header-anchor {
  opacity: 1;
}

nav.top-nav {
  padding-top: 0.8rem;
  margin-bottom: 1rem;
}

.nav-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0 0.85rem;
  border-bottom: 1px solid var(--border-medium);
}

nav.top-nav .site-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-family-sans);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.005em;
  text-decoration: none;
  border-bottom: none;
  padding: 0;
}

.site-wordmark-icon {
  width: 1.3em;
  height: 1.3em;
  flex: 0 0 auto;
}

nav.top-nav .site-wordmark:hover {
  color: var(--color-secondary);
  border-bottom: none;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.9rem;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.24rem;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  background: var(--background-soft);
  color: var(--text-primary);
  padding: 0;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.nav-toggle:hover {
  background: var(--background-code);
  border-color: var(--color-secondary);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 59, 89, 0.08);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

.nav-toggle-bar {
  width: 1rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.nav-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  flex: 1 1 auto;
}

nav.top-nav a {
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.25rem 0.1rem;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.005em;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

nav.top-nav a:hover {
  color: var(--color-secondary);
  border-bottom-color: var(--color-secondary);
}

.nav-logo {
  height: 1.3em;
  width: auto;
  vertical-align: middle;
  margin: 0 0.2rem 3px 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid var(--border-medium);
  background: var(--background-soft);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 0;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.theme-toggle:hover {
  background: var(--background-code);
  border-color: var(--color-secondary);
  color: var(--color-secondary);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 59, 89, 0.08);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-dates {
  margin: 0.15rem 0 0.8rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.recent-pages {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-medium);
}

.recent-pages h2 {
  margin-bottom: 1rem;
}

.page-list {
  list-style: none;
  padding: 0;
}

.page-list li {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.25rem 0;
}

.page-date {
  width: 10ch;
  margin-left: 0.5rem;
  color: var(--text-muted);
  font-family: var(--font-family-mono);
  font-size: 0.92rem;
  text-align: right;
  flex-shrink: 0;
}

.footer-separator {
  margin: 2rem 0 1rem;
  border-top: 1px solid var(--border-light);
}

footer {
  padding: 0.75rem 0 3rem;
}

.footer-text {
  max-width: none;
  text-align: center;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.katex-display {
  margin: 1em 0;
  text-align: center;
}

.content ul,
.content ol {
  margin-top: 0.65rem;
  margin-bottom: 1rem;
}

.content > h2:first-child,
.content > p:first-child {
  margin-top: 0.9rem;
}

.content > h2 + p,
.content > h3 + p {
  margin-top: 0.45rem;
}

.author-self {
  font-weight: 400;
  text-decoration: underline;
  text-decoration-color: var(--color-secondary);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.12em;
}

.home-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin: 1rem 0 2rem;
}

.home-hero-copy {
  flex: 1 1 0;
  min-width: 0;
}

.home-hero-copy p:first-child {
  margin-top: 0;
}

.core-questions {
  max-width: 72ch;
  margin: 0.9rem 0 1.4rem;
  padding: 1rem 1.15rem 1rem 1.2rem;
  background: var(--background-soft);
  border-left: 4px solid var(--color-secondary);
  border-radius: 0 10px 10px 0;
}

.core-questions ol {
  margin: 0;
  padding-left: 1.2rem;
}

.core-questions li {
  margin: 0;
  padding-left: 0.15rem;
}

.core-questions li + li {
  margin-top: 0.95rem;
}

.core-questions strong {
  color: var(--color-primary);
}

.content img.profile-image,
.profile-image {
  flex: 0 0 auto;
  width: 180px !important;
  height: 180px !important;
  object-fit: cover;
  border-radius: 14px;
  margin: 0;
  border: 1px solid var(--border-light);
  max-width: 180px !important;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 0.9rem 0 1.75rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid var(--social-border, var(--border-light));
  border-radius: 999px;
  background: var(--social-bg, transparent);
  color: var(--social-color, var(--text-secondary)) !important;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.social-link:hover {
  transform: translateY(-1px);
  border-color: var(--social-hover-border, var(--color-secondary));
  background: var(--social-hover-bg, var(--background-soft));
  color: var(--social-hover-color, var(--color-secondary)) !important;
  box-shadow: 0 8px 18px rgba(34, 59, 89, 0.08);
}

.social-link svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: currentColor;
  flex: 0 0 auto;
  opacity: 1;
}

.social-scholar {
  --social-color: #1a73e8;
  --social-border: rgba(26, 115, 232, 0.22);
  --social-bg: rgba(26, 115, 232, 0.08);
  --social-hover-border: #1a73e8;
  --social-hover-bg: rgba(26, 115, 232, 0.14);
  --social-hover-color: #1557b0;
}

.social-orcid {
  --social-color: #a6ce39;
  --social-border: rgba(166, 206, 57, 0.28);
  --social-bg: rgba(166, 206, 57, 0.1);
  --social-hover-border: #7fb216;
  --social-hover-bg: rgba(166, 206, 57, 0.16);
  --social-hover-color: #5f8c00;
}

.social-github {
  --social-color: #24292f;
  --social-border: rgba(36, 41, 47, 0.16);
  --social-bg: rgba(36, 41, 47, 0.06);
  --social-hover-border: #24292f;
  --social-hover-bg: rgba(36, 41, 47, 0.1);
  --social-hover-color: #111827;
}

html[data-theme="dark"] .social-github {
  --social-color: #b794f4;
  --social-border: rgba(183, 148, 244, 0.3);
  --social-bg: rgba(183, 148, 244, 0.1);
  --social-hover-border: #b794f4;
  --social-hover-bg: rgba(183, 148, 244, 0.18);
  --social-hover-color: #d6bcfa;
}

.social-linkedin {
  --social-color: #0a66c2;
  --social-border: rgba(10, 102, 194, 0.22);
  --social-bg: rgba(10, 102, 194, 0.08);
  --social-hover-border: #0a66c2;
  --social-hover-bg: rgba(10, 102, 194, 0.14);
  --social-hover-color: #084b8f;
}

.social-facebook {
  --social-color: #1877f2;
  --social-border: rgba(24, 119, 242, 0.22);
  --social-bg: rgba(24, 119, 242, 0.08);
  --social-hover-border: #1877f2;
  --social-hover-bg: rgba(24, 119, 242, 0.14);
  --social-hover-color: #1257b8;
}

.image-triptych {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  align-items: start;
  margin: 1.2rem 0 1.6rem;
  max-width: 100%;
}

.image-triptych img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: var(--background-soft);
}

.video-embed {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 1.25rem 0 1.5rem;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-light);
  background: #000;
  aspect-ratio: 16 / 9;
}

.video-embed iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.project-meta {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.15rem;
  max-width: 72ch;
  background: var(--background-soft);
  border-left: 4px solid var(--color-secondary);
  border-radius: 0 10px 10px 0;
}

.gallery-carousel {
  position: relative;
  margin: 1.2rem 0 1.9rem;
}

.scroll-gallery {
  position: relative;
  margin: 0;
  padding: 0.2rem 0 0.75rem;
}

.gallery-card {
  width: 100%;
  margin: 0;
  border: 1px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--background-panel) 0%, var(--background-soft) 100%);
  box-shadow: 0 12px 28px rgba(34, 59, 89, 0.08);
}

.gallery-card[hidden] {
  display: none;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  object-position: center;
  background: #1d255f;
}

.gallery-card figcaption {
  padding: 0.8rem 0.95rem 0.9rem;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--color-primary);
}

.gallery-arrow {
  position: absolute;
  top: calc(50% - 1.35rem);
  z-index: 3;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid var(--border-medium);
  border-radius: 999px;
  background: rgba(251, 250, 246, 0.94);
  color: var(--color-primary);
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(34, 59, 89, 0.12);
}

.gallery-arrow:hover:not(:disabled) {
  border-color: var(--color-secondary);
  color: var(--color-secondary);
}

.gallery-arrow:disabled {
  opacity: 0.42;
  cursor: default;
}

.gallery-arrow-prev {
  left: -0.8rem;
}

.gallery-arrow-next {
  right: -0.8rem;
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.gallery-dot {
  width: 0.62rem;
  height: 0.62rem;
  border: 0;
  border-radius: 999px;
  background: var(--border-medium);
  padding: 0;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.gallery-dot[aria-pressed="true"] {
  background: var(--color-secondary);
  transform: scale(1.16);
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(12, 16, 24, 0.82);
  backdrop-filter: blur(6px);
}

.image-lightbox[hidden] {
  display: none;
}

.image-lightbox-media {
  max-width: min(92vw, 1200px);
  max-height: 84vh;
  width: auto;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.image-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(17, 22, 29, 0.72);
  color: #fff;
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.image-lightbox-nav:hover:not(:disabled) {
  background: rgba(17, 22, 29, 0.9);
}

.image-lightbox-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.image-lightbox-prev {
  left: 1.25rem;
}

.image-lightbox-next {
  right: 1.25rem;
}

.image-lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(17, 22, 29, 0.72);
  color: #fff;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  cursor: pointer;
}

.image-lightbox-close:hover {
  background: rgba(17, 22, 29, 0.9);
}

@media (max-width: 720px) {
  body {
    font-size: 1rem;
    padding: 0 1rem;
  }

  article {
    padding-top: 1rem;
  }

  .nav-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .site-wordmark {
    align-self: flex-start;
  }

  .nav-controls {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .nav-links {
    display: none;
    order: 3;
    flex-basis: 100%;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.5rem 0 0;
    margin: 0;
    border-top: 1px solid var(--border-light);
  }

  .nav-links[data-open="true"] {
    display: flex;
  }

  .nav-links a {
    width: 100%;
    padding: 0.35rem 0;
  }

  .nav-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    order: 1;
    width: 2.4rem;
    height: 2.4rem;
  }

  .nav-toggle-bar {
    width: 0.9rem;
  }

  .theme-toggle {
    order: 2;
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  .page-list li {
    flex-direction: column;
    gap: 0.2rem;
  }

  .page-date {
    width: auto;
    margin-left: 0;
    text-align: left;
  }

  .home-hero {
    flex-direction: column-reverse;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .content img.profile-image,
  .profile-image {
    display: block;
    margin: 0 auto;
    width: 140px !important;
    height: 140px !important;
    max-width: 140px !important;
  }

  .image-triptych {
    grid-template-columns: 1fr;
  }

  .social-links {
    gap: 0.6rem;
  }

  .social-link {
    width: 2.55rem;
    height: 2.55rem;
  }

  .image-lightbox {
    padding: 1rem;
  }

  .image-lightbox-close {
    top: 0.85rem;
    right: 0.85rem;
  }

  .image-lightbox-nav {
    width: 2.65rem;
    height: 2.65rem;
  }

  .image-lightbox-prev {
    left: 0.85rem;
  }

  .image-lightbox-next {
    right: 0.85rem;
  }

  .scroll-gallery {
    gap: 0.75rem;
  }

  .gallery-arrow {
    width: 2.45rem;
    height: 2.45rem;
    top: calc(50% - 1.15rem);
  }

  .gallery-arrow-prev {
    left: -0.3rem;
  }

  .gallery-arrow-next {
    right: -0.3rem;
  }
}

.paper-highlight {
  display: flex;
  align-items: flex-start;
  gap: 1.15rem;
  margin: 0.9rem 0 1.6rem;
  padding: 0.95rem 1.1rem;
  background: #ebe6d7;
  border: 1px solid #d6ceb8;
  border-radius: 10px;
}

html[data-theme="dark"] .paper-highlight {
  background: #23211c;
  border-color: #32302a;
}

.paper-highlight-figure {
  flex: 0 0 auto;
  width: 160px;
  margin: 0;
}

.paper-highlight-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  background: var(--background-panel);
}

.paper-highlight-body {
  flex: 1 1 0;
  min-width: 0;
}

.paper-highlight-body > :first-child {
  margin-top: 0;
}

.paper-highlight-body > :last-child {
  margin-bottom: 0;
}

.paper-highlight-body ul {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
}

@media (max-width: 720px) {
  .paper-highlight {
    flex-direction: column;
    gap: 0.8rem;
    padding: 0.85rem 0.95rem;
  }

  .paper-highlight-figure {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
  }
}
