:root {
  --bg: #ffffff;
  --text: #1b1d21;
  --muted: #5d6470;
  --rule: #e4e6ea;
  --panel: #f5f6f8;
  --accent: #1f3a5f;   /* same navy as the CV */
  --ok: #1d7a52;
  --bad: #b23a31;
  --warm: #e8862a;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101317;
    --text: #e7e9ec;
    --muted: #9aa3af;
    --rule: #272c34;
    --panel: #171b21;
    --accent: #a9c4ee;
    --ok: #6fd3a3;
    --bad: #f19087;
    --warm: #f2a14e;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 820px; margin: 0 auto; padding: 0 24px; }

a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* Top navigation */
.nav { display: flex; align-items: baseline; justify-content: space-between; padding: 22px 0; border-bottom: 1px solid var(--rule); }
.nav a { text-decoration: none; }
.nav .home { color: var(--text); font-weight: 600; }
.nav ul { display: flex; gap: 26px; list-style: none; margin: 0; padding: 0; font-size: 0.94rem; }
.nav ul a { color: var(--muted); }
.nav ul a:hover, .nav ul a[aria-current] { color: var(--text); }

/* Home: intro */
.intro { display: grid; grid-template-columns: 132px 1fr; gap: 32px; align-items: start; padding: 56px 0 48px; }
.intro img { width: 132px; height: 132px; border-radius: 50%; object-fit: cover; display: block; }
h1 { font: 600 2.6rem/1.1 var(--serif); letter-spacing: -0.01em; margin: 0 0 6px; }
.role { color: var(--muted); margin: 0 0 18px; }
.intro p { margin: 0 0 14px; }
.links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 22px; font-size: 0.94rem; font-weight: 500; }

/* Home: research directions */
#research { scroll-margin-top: 20px; }
.section-title { font: 600 0.8rem/1 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 0; padding-bottom: 14px; }
.area { border-top: 1px solid var(--rule); padding: 32px 0 36px; }
.area h3 { font: 600 1.6rem/1.22 var(--serif); letter-spacing: -0.005em; margin: 0 0 14px; text-wrap: balance; }
.area .body { display: grid; grid-template-columns: 1fr 320px; gap: 40px; align-items: start; }
.summary { margin: 0; font-size: 1.08rem; line-height: 1.5; text-wrap: pretty; }
.try { margin: 12px 0 0; font-size: 0.94rem; font-weight: 500; }

/* Home: one compact visual per direction */
.fig { margin: 0; }
.panel { border-radius: 10px; background: var(--panel); padding: 14px; min-height: 176px; align-content: center; }
figcaption { color: var(--muted); font-size: 0.8rem; line-height: 1.45; margin-top: 8px; }

.decode { display: grid; gap: 6px; }
.decode .row { display: grid; grid-template-columns: 40px repeat(7, 1fr); gap: 4px; align-items: center; }
.decode .step { font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.tok { height: 28px; border-radius: 5px; font: 500 0.68rem/28px var(--sans); text-align: center; white-space: nowrap; overflow: hidden; }
.tok.mask { border: 1px dashed color-mix(in srgb, var(--muted) 55%, transparent); }
.tok.old { background: color-mix(in srgb, var(--muted) 15%, transparent); }
.tok.new { background: var(--accent); color: var(--bg); }

.relax svg { display: block; width: 100%; height: auto; }
.rx-edge { stroke: var(--muted); stroke-width: 1; opacity: 0.55; }
.rx-node { fill: var(--panel); stroke: var(--muted); stroke-width: 1.4; }
.rx-pos { fill: var(--warm); }
.rx-neg { fill: var(--text); }
.rx-sphere { fill: color-mix(in srgb, var(--accent) 9%, transparent); stroke: var(--muted); stroke-width: 1; }
.rx-eq { fill: none; stroke: var(--muted); stroke-width: 0.8; stroke-dasharray: 3 3; opacity: 0.7; }
.rx-vec { stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; }
.rx-dash { stroke-dasharray: 3.5 2.5; opacity: 0.75; }
.rx-dot { fill: var(--accent); }
.rx-dot2 { fill: var(--panel); stroke: var(--accent); stroke-width: 1.4; }
.rx-arrow { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.rx-label { fill: var(--muted); font: 500 9.4px var(--sans); text-anchor: middle; }

.chain { display: grid; gap: 4px; font-size: 0.76rem; line-height: 1.4; }
.chain .row { display: grid; grid-template-columns: 46px 1fr auto; gap: 8px; align-items: baseline; padding: 2px 9px; border-radius: 5px; background: color-mix(in srgb, var(--muted) 15%, transparent); }
.chain .given { background: none; border: 1px dashed color-mix(in srgb, var(--muted) 55%, transparent); }
.chain .lbl { font-size: 0.66rem; color: var(--muted); white-space: nowrap; }
.chain .given { display: block; padding: 4px 9px 5px; }
.chain .given .claim { display: block; text-wrap: pretty; }
.chain .nb { white-space: nowrap; }
.chain b { font-weight: 600; }
.chain .fail b { color: var(--bad); }
.chain .verdict { font-weight: 600; }
.chain .pass .verdict { color: var(--ok); }
.chain .fail { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.chain .fail .verdict { color: var(--bad); }

/* Home: representative papers */
.papers { list-style: none; margin: 24px 0 0; padding: 0; font-size: 0.94rem; }
.papers li { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 24px; padding: 10px 0; border-top: 1px solid var(--rule); }
.papers .title { font-weight: 500; color: var(--text); text-decoration-color: transparent; }
.papers a.title:hover { color: var(--accent); text-decoration-color: currentColor; }
.papers .meta { flex: none; display: flex; gap: 14px; color: var(--muted); font-size: 0.84rem; white-space: nowrap; }

.earlier { border-top: 1px solid var(--rule); padding: 30px 0 0; color: var(--muted); margin: 0; }
footer { margin-top: 64px; padding: 24px 0 40px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.84rem; }

/* Text pages (Publications, CV) */
.page { padding: 48px 0 0; }
.page-title { font-size: 2.2rem; margin: 0 0 28px; }
.prose { font-size: 0.97rem; }
.prose h2 { font: 600 1.35rem/1.25 var(--serif); margin: 40px 0 18px; padding-top: 28px; border-top: 1px solid var(--rule); }
.prose p { margin: 0 0 18px; }
.prose ul { margin: 0 0 18px; padding-left: 1.2em; }
.prose li { margin: 6px 0; }
.prose li p { margin: 0; }
.prose li > ul { margin: 4px 0 0; }

/* Research page: the full publication list, in the same voice as the Home paper rows */
.pubs h2 { font: 600 0.8rem/1 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 44px 0 22px; padding-top: 26px; }
.pubs p { color: var(--muted); line-height: 1.5; margin: 0 0 20px; }
.pubs h2 ~ p > a:first-child { color: var(--text); font-weight: 500; text-decoration-color: transparent; }
.pubs h2 ~ p > a:first-child:hover { color: var(--accent); text-decoration-color: currentColor; }
.pubs b { color: var(--text); font-weight: 600; }
.pubs i { font-style: normal; }

@media (max-width: 700px) {
  body { font-size: 16px; }
  .intro { grid-template-columns: 1fr; gap: 22px; padding: 36px 0 36px; }
  .intro img { width: 104px; height: 104px; }
  .links { gap: 8px 14px; font-size: 0.9rem; }
  h1 { font-size: 2.15rem; }
  .area h3 { font-size: 1.38rem; }
  .area .body { grid-template-columns: 1fr; gap: 20px; }
  .panel { min-height: 0; }
  .papers li { flex-direction: column; gap: 2px; }
  .page { padding-top: 32px; }
  .page-title { font-size: 1.9rem; }
}
