:root {
  --bg: #ffffff;
  --bg-elev: #f6f7f9;
  --border: #e5e7eb;
  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --accent: #2f5bd1;
  --accent-hover: #1e44b0;
  --accent-soft: rgba(47, 91, 209, 0.10);
  --shadow-strong: 0 10px 30px rgba(15, 23, 42, 0.12);
  --brand-elastix: #2ba557;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Monaco,
               "Cascadia Mono", "Roboto Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #18181b;
  --bg-elev: #232327;
  --border: #2e2e33;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --accent: #7aa2ff;
  --accent-hover: #a3bdff;
  --accent-soft: rgba(122, 162, 255, 0.12);
  --shadow-strong: 0 10px 30px rgba(0, 0, 0, 0.55);
  --brand-elastix: #4cce75;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

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

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

h1, h2, h3 {
  margin: 0 0 0.5em;
  line-height: 1.25;
  letter-spacing: -0.015em;
  font-weight: 700;
}

p { margin: 0 0 1em; }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

main { padding-bottom: 96px; }

section { padding: 64px 0 16px; }
#news { padding-top: 36px; }

section h2 {
  font-size: 1.5rem;
  margin-bottom: 28px;
  position: relative;
  padding-bottom: 14px;
}
section h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40px;
  height: 3px;
  background: var(--accent);
}

.bio a,
.news-list a,
.pub-authors a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.15s ease, color 0.15s ease;
}
.bio a:hover,
.news-list a:hover,
.pub-authors a:hover {
  text-decoration-color: currentColor;
}

.brand-elastix,
.brand-elastix:hover {
  color: var(--brand-elastix);
  font-weight: 600;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-brand {
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
  letter-spacing: -0.005em;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.nav.is-scrolled .nav-brand {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.nav-links {
  display: flex;
  gap: 4px;
  margin-left: auto;
  align-items: center;
}
.nav-links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 6px 10px;
  font-weight: 500;
  transition: color 0.15s ease;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); font-weight: 600; }

.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  z-index: 50;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease,
              background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.back-to-top.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.back-to-top svg { width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: opacity 0.25s ease; transform: none; }
}

.theme-toggle {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 6px;
  padding: 0;
  transition: color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.intro { padding-top: 64px; }
.intro::after {
  content: "";
  display: block;
  clear: both;
}
.intro h1 {
  font-size: 2.5rem;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}
.intro .role {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 0 0 2px;
}
.intro .affiliation {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.company-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}
.hero-photo {
  float: right;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-strong);
  border: 3px solid var(--bg);
  outline: 1px solid var(--border);
  margin: 4px 0 16px 32px;
  shape-outside: circle(50%);
}
.bio { margin-top: 32px; }
.bio p {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.socials {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.social-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  position: relative;
  transition: color 0.15s ease;
}
.social-btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s ease;
}
.social-btn:hover { color: var(--accent); }
.social-btn:hover::after { transform: scaleX(1); }
.social-btn svg { width: 14px; height: 14px; }

.callout {
  clear: both;
  position: relative;
  margin-top: 40px;
  padding: 28px 32px;
  background: transparent;
  color: var(--text);
  font-size: 0.98rem;
}
.callout::before,
.callout::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}
.callout::before {
  top: 0; left: 0;
  border-top-width: 1.5px;
  border-left-width: 1.5px;
}
.callout::after {
  bottom: 0; right: 0;
  border-bottom-width: 1.5px;
  border-right-width: 1.5px;
}
.callout strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.news-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.news-list li {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  align-items: baseline;
  font-size: 0.95rem;
}
.news-list .date {
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.news-list .pre_news_item { display: none; }
.news-list .pre_news_item.is-visible { display: grid; }

.toggle-news {
  margin-top: 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s ease;
}
.toggle-news::before { content: "+"; font-size: 1em; }
.toggle-news:hover { color: var(--accent); }

.pub-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pub {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 32px;
  padding: 28px 0;
  border-top: 1px solid var(--border);
  transition: none;
}
.pub:first-child {
  border-top: none;
  padding-top: 4px;
}
.pub:hover .pub-title { color: var(--accent); }

.pub-figure {
  margin: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-elev);
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pub-figure img {
  width: 100%;
  height: 100%;
  /* Always show the whole figure, letterboxed within the container,
     regardless of how the container is resized. */
  object-fit: contain;
}
/* White-backed figures (e.g. generated charts) that should blend with a white canvas */
.pub-figure.white-bg {
  background: #ffffff;
}

/* Scroll-reveal: fade + rise. Only active when JS is present (.js),
   so no-JS visitors always see content. Honors reduced-motion. */
.js .reveal-on-scroll {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
.js .reveal-on-scroll.in-view {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal-on-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.pub-media {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pub-venue {
  align-self: flex-start;
  background: var(--bg-elev);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 3px 7px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pub-venue:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.pub-body { display: flex; flex-direction: column; gap: 8px; }
.pub-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin: 0;
  transition: color 0.15s ease;
}
.pub-authors { font-size: 0.9rem; color: var(--text-muted); margin: 0; }
.pub-authors .me { color: var(--text); font-weight: 600; }
.pub-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-subtle);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0;
}
.pub-links { margin-top: 8px; display: flex; gap: 20px; flex-wrap: wrap; }
.pub-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.15s ease;
}
.pub-link::after {
  content: "↗";
  font-size: 0.95em;
  transition: transform 0.2s ease;
}
.pub-link:hover { color: var(--accent); }
.pub-link:hover::after { transform: translate(2px, -2px); }
.pub-link svg { width: 13px; height: 13px; }

.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  color: var(--text-subtle);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

@media (max-width: 720px) {
  .intro { padding-top: 40px; }
  .intro h1 { font-size: 1.85rem; }
  .hero-photo {
    float: none;
    width: 112px;
    height: 112px;
    margin: 0 0 20px 0;
    shape-outside: none;
  }
  .bio p { text-align: left; hyphens: none; }

  .pub { grid-template-columns: 1fr; gap: 16px; padding: 24px 0; }
  .pub-figure { aspect-ratio: 16 / 9; max-height: 220px; }

  .news-list li { grid-template-columns: 90px 1fr; gap: 10px; }

  section { padding: 48px 0 8px; }
  section h2 { font-size: 1.25rem; }

  .nav-inner { padding: 10px 16px; }
  .nav-links a { padding: 6px 8px; font-size: 0.85rem; }
  .container { padding: 0 20px; }

  .callout { padding: 24px; }
}

@media (max-width: 420px) {
  .intro h1 { font-size: 1.65rem; }
  .news-list li { grid-template-columns: 1fr; gap: 2px; }
  .news-list .date { font-size: 0.7rem; }
  .socials { gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
