:root {
  --bg: #f8f7f4;
  --ink: #1f1e1c;
  --muted: #6b6860;
  --line: #e4e1da;
  --accent: #b5532f;
  --serif: "Newsreader", "Songti SC", "Noto Serif SC", Georgia, serif;
  --sans: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --maxw: 940px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.nav-name { font-family: var(--serif); font-size: 19px; text-decoration: none; }
.nav nav { display: flex; gap: 22px; font-size: 14px; }
.nav nav a { text-decoration: none; color: var(--muted); }
.nav nav a:hover { color: var(--ink); }

/* ---------- hero ---------- */
.hero { padding-top: 12vh; padding-bottom: 2vh; display: flex; flex-direction: row-reverse; align-items: center; gap: 40px; }
.hero-text { flex: 1; min-width: 0; }
.hero-photo {
  flex: none; width: 220px; height: 220px; object-fit: cover; object-position: 50% 50%;
  border-radius: 24px; box-shadow: 0 22px 44px -24px rgba(40, 30, 20, .5);
}
.eyebrow { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
h1 { font: 500 clamp(44px, 7vw, 76px)/1.05 var(--serif); margin: 12px 0 18px; letter-spacing: -0.02em; }
.lede { font: 400 21px/1.55 var(--serif); margin: 0; max-width: 620px; }
.links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 22px; font-size: 14px; }

/* ---------- gallery ---------- */
.gallery { position: relative; }
.gallery-stage {
  position: relative;
  height: min(84vh, 820px);
  min-height: 440px;
  overflow: hidden;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  /* soft fade into the page on all four edges */
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 10%, #000 90%, transparent),
    linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, #000 10%, #000 90%, transparent),
    linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  mask-composite: intersect;
}
.gallery-stage.dragging { cursor: grabbing; }
/* Cards are laid out at their largest on-screen size and scaled down by JS, so the
   sizes below are what the focused (centred, zoomed) card shows at ~0.9×. */
.g-card {
  position: absolute; left: 50%; top: 50%;
  padding: 0; border: 0; margin: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #e9e6df;
  box-shadow: 0 30px 60px -30px rgba(40, 30, 20, .4);
  cursor: pointer;
  will-change: transform, filter, opacity;
  backface-visibility: hidden;
}
.g-card img, .g-card video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; background: #fff; }
.g-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 16px 12px;
  font-size: 15px; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  opacity: 0; transition: opacity .25s;
}
.g-video::after {
  content: ""; position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%;
  background: rgba(20,18,15,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l8 5-8 5z' fill='white'/%3E%3C/svg%3E") center/24px no-repeat;
}
.g-card.is-focused .g-cap, .g-card:focus-visible .g-cap { opacity: 1; }
.g-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.gallery-hint { text-align: center; font-size: 12px; color: var(--muted); margin: -8px 0 0; }

/* ---------- sections ---------- */
.section { padding-top: 72px; }
h2 { font: 500 30px/1.2 var(--serif); margin: 0 0 20px; }
.prose { max-width: 720px; }
.prose p { margin: 0 0 14px; }

.cv { display: grid; gap: 22px; margin-top: 28px; max-width: 720px; }
.cv h3 { font: 500 13px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 14.5px; line-height: 1.5; }
.timeline li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13.5px; padding-top: 1px; }
.timeline b { font-weight: 600; }
.timeline .muted { font-size: 13.5px; }

.pubs { list-style: none; padding: 0; margin: 0; }
.pub { display: grid; grid-template-columns: 240px 1fr; gap: 24px; padding: 20px 0; border-top: 1px solid var(--line); align-items: start; }
.pub-toc {
  display: flex; align-items: center; justify-content: center;
  width: 240px; height: 150px; padding: 8px; margin: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: zoom-in;
  transition: box-shadow .2s, transform .2s;
}
.pub-toc:hover { box-shadow: 0 14px 30px -18px rgba(40, 30, 20, .45); transform: translateY(-1px); }
.pub-toc img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.pub-badge {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  padding: 12px; border-radius: 8px; background: #efece5;
  font: italic 500 14px/1.25 var(--serif); color: var(--ink); align-self: start;
}
.pub-badge span:last-child { font: 500 12px var(--sans); font-style: normal; color: var(--muted); }
.pub h3 { font: 500 18px/1.35 var(--serif); margin: 0 0 6px; }
.pub h3 a, .pub-title { text-decoration: none; }
.pub p { margin: 0 0 3px; font-size: 14px; }
.authors { color: var(--muted); font-size: 14px; }
.authors b { color: var(--ink); font-weight: 600; }
.authors sup { line-height: 0; font-size: .8em; margin-left: 1px; }
.venue { font-size: 14px; }
.venue b { font-weight: 600; }
.tag { font: 500 11px var(--sans); color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 4px; white-space: nowrap; vertical-align: 1px; }

.pub-links { display: inline-flex; gap: 8px; vertical-align: 1px; }
.pub-links a, .pub-links .cite {
  font: 500 12px var(--sans); text-decoration: none; color: var(--accent); background: none; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 999px; padding: 1px 10px;
}
.pub-links .cif-toggle {
  font: 500 12px var(--sans); color: #fff; background: var(--accent); cursor: pointer;
  border: 1px solid var(--accent); border-radius: 999px; padding: 1px 10px;
}
.pub-links .cif-toggle[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); }
.pub-links a:hover, .pub-links .cite:hover, .pub-links .cite.done { background: var(--accent); color: #fff; border-color: var(--accent); }
.pub .pub-links { margin-top: 6px; }
.pub-all { margin: 28px 0 12px; border-top: 1px solid var(--line); }
.pub-all summary {
  cursor: pointer; padding: 14px 0; font: 500 18px var(--serif); list-style: none;
}
.pub-all summary::-webkit-details-marker { display: none; }
.pub-all summary::before { content: "+"; display: inline-block; width: 1.2em; color: var(--accent); }
.pub-all[open] summary::before { content: "−"; }
.pub-year { font: 500 15px var(--sans); color: var(--muted); margin: 18px 0 6px; }
.pub-list { margin: 0; padding-left: 2.2em; }
.pub-list li { padding: 7px 0; }
.pub-list li::marker { color: var(--muted); font-size: 13px; }
.pub-title { font: 500 16px/1.4 var(--serif); }
h1 .cn { font-size: .42em; color: var(--muted); font-weight: 400; margin-left: .25em; letter-spacing: 0; }

/* ---------- structures (3D viewer cards) ---------- */
.st-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.st-card {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden;
}
.st-card.expanded { grid-column: 1 / -1; }
.st-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 12px 14px 8px; }
.st-head h3 { font: 500 16px/1.25 var(--serif); margin: 0; }
.st-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.st-expand {
  flex: none; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 15px; line-height: 1; color: var(--muted);
}
.st-expand:hover { color: var(--ink); border-color: var(--ink); }
.st-views { display: flex; gap: 4px; padding: 0 14px 6px; }
.st-views button {
  font: 500 12px var(--sans); color: var(--muted); background: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
}
.st-views button[aria-selected="true"] { color: #fff; background: var(--ink); border-color: var(--ink); }
.st-views button:disabled { opacity: .4; cursor: not-allowed; }
/* per-paper CIF panel spans the whole publication row */
.cif-panel { grid-column: 1 / -1; padding: 4px 0 6px; }
.pub[data-doi] { scroll-margin-top: 64px; } /* clear the sticky nav when scrolled to */
.cif-panel .st-grid { margin-top: 8px; }
.cif-note { margin: 0; font-size: 12.5px; color: var(--muted); }
.st-viewer { position: relative; width: 100%; height: 280px; touch-action: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.st-viewer > .st-canvas { position: absolute; inset: 0; }
.st-card.expanded .st-viewer { height: min(68vh, 560px); }
.st-card.loading .st-viewer { opacity: .5; transition: opacity .2s; }
.st-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px 4px; font-size: 12.5px; }
.st-controls label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.st-controls label[hidden] { display: none; }
.st-controls select { font: inherit; padding: 3px 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.st-controls input { accent-color: var(--accent); margin: 0; }
.st-caption { margin: 0; padding: 6px 14px 14px; font-size: 12.5px; line-height: 1.5; color: var(--muted); margin-top: auto; }
.st-papers { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.st-papers a {
  font: 500 11.5px var(--sans); text-decoration: none; color: var(--accent); white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 999px; padding: 1px 9px;
}
.st-papers a:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- tools ---------- */
.tool { margin-top: 20px; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: #fbfaf8; }
.tool-head { display: flex; gap: 16px; align-items: center; }
.tool-icon { width: 56px; height: 56px; border-radius: 13px; flex: none; }
.tool h3 { font: 500 24px/1.2 var(--serif); margin: 0; }
.tool-sub { font: 400 15px var(--sans); color: var(--muted); margin-left: 6px; }
.tool-meta { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.tool-desc { font: 400 18px/1.55 var(--serif); margin: 18px 0; }
.tool-shot { margin: 0 0 20px; }
.tool-shot img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); box-shadow: 0 16px 36px -22px rgba(40,30,20,.4); }
.tool-shots { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 18px; padding: 22px 16px 14px; border-radius: 12px; background: linear-gradient(135deg, #e9eef6, #efe9f3); }
.tool-shots img { width: auto; max-width: 100%; max-height: 300px; border: 0; border-radius: 0; box-shadow: none; filter: drop-shadow(0 12px 20px rgba(40,30,60,.18)); }
.tool-shots figcaption { flex-basis: 100%; }
.tool-shot figcaption { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }
.tool-features { margin: 0 0 22px; padding-left: 1.1em; font-size: 15px; }
.tool-features li { margin: 6px 0; }
.tool-features li::marker { color: var(--accent); }
.tool-features code { font-size: 13px; background: #efece5; padding: 1px 5px; border-radius: 4px; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  font: 500 14px var(--sans); text-decoration: none; color: var(--ink);
  transition: border-color .15s, background .15s, color .15s;
}
.btn span { font-weight: 400; font-size: 12px; opacity: .7; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { border-color: transparent; background: none; padding-left: 6px; }
.btn-ghost:hover { color: var(--accent); border-color: transparent; }
.dl-count {
  font: 500 12.5px var(--sans); color: var(--muted); font-variant-numeric: tabular-nums;
  padding: 4px 10px; border-radius: 999px; background: #efece5; cursor: default;
}
.dl-count[hidden] { display: none; }
.tool-note { font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }

.footer { padding-top: 64px; padding-bottom: 48px; font-size: 14px; }

/* ---------- visitor stats (bottom-right) ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stats { position: fixed; right: 18px; bottom: 18px; z-index: 60; }
.stats-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  display: grid; place-items: center; color: var(--muted);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  box-shadow: 0 8px 22px -12px rgba(40, 30, 20, .45); transition: color .15s, border-color .15s, transform .15s;
}
.stats-btn:hover, .stats-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.stats-panel {
  position: absolute; right: 0; bottom: 52px; width: 250px; padding: 14px 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 40px -20px rgba(40, 30, 20, .45);
}
.stats-panel[hidden] { display: none; }
.stats-title { margin: 0 0 6px; font: 500 12px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.stats-total { margin: 0 0 12px; display: flex; align-items: baseline; gap: 8px; }
.stats-num { font: 500 30px/1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.stats-unit { font-size: 13px; color: var(--muted); }
.stats-link {
  display: block; padding: 9px 12px; border-radius: 10px; background: #f6f4ef; text-decoration: none;
  font: 500 14px var(--sans); color: var(--ink);
}
.stats-link small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 2px; }
.stats-link:hover { background: #efece5; color: var(--accent); }
.stats-note { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }

/* ---------- lightbox ---------- */
.lightbox {
  border: 0; padding: 0; border-radius: 14px; overflow: hidden;
  width: fit-content; max-width: min(92vw, 1000px); background: var(--bg);
}
.lightbox::backdrop { background: rgba(20, 18, 15, .6); backdrop-filter: blur(6px); }
.lightbox img, .lightbox video { display: block; width: auto; max-width: 100%; margin: 0 auto; max-height: 76vh; object-fit: contain; background: #fff; }
.lightbox [hidden] { display: none; }
.lb-link { display: inline-block; margin-top: 8px; font-size: 14px; color: var(--accent); }
.lb-text { padding: 14px 20px 18px; }
.lb-text h3 { font: 500 20px var(--serif); margin: 0 0 4px; }
.lb-text p { margin: 0; color: var(--muted); font-size: 14px; }
.lb-close {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; font-size: 22px; cursor: pointer;
}

@media (max-width: 900px) and (min-width: 641px) {
  .st-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .hero { flex-direction: column; align-items: flex-start; gap: 20px; padding-top: 6vh; }
  .hero-photo { width: 120px; height: 120px; border-radius: 18px; }
  .nav nav { gap: 14px; }
  .nav nav a:nth-child(1), .nav nav a:nth-child(4) { display: none; }
  .st-grid { grid-template-columns: 1fr; }
  .tool { padding: 18px; }
  .pub { grid-template-columns: 1fr; gap: 10px; }
  .pub-toc { width: 100%; height: 190px; }
  .pub-badge { flex-direction: row; gap: 8px; padding: 4px 10px; justify-self: start; }
  .gallery-stage { height: 62vh; }
}
