/* ---------- tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --text: #1d232b;
  --muted: #5d6673;
  --line: #e3e6ea;
  --accent: #1f5fa8;
  --accent-soft: #e8f0fa;
  --maxw: 1040px;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --bg-soft: #1b1f26; --text: #e4e7eb; --muted: #9aa3ae;
    --line: #2a3039; --accent: #7fb0ea; --accent-soft: #1e2a3a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- permanent top bar ---------- */
header.bar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.bar .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
nav.menu { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
nav.menu::-webkit-scrollbar { display: none; }
nav.menu a { color: var(--muted); font-size: 15px; font-weight: 500; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
nav.menu a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
nav.menu a.active { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 760px) {
  .bar .wrap { flex-direction: column; align-items: flex-start; gap: 0; padding-top: 8px; padding-bottom: 6px; }
  nav.menu { margin-left: -8px; flex-wrap: wrap; overflow: visible; gap: 0 2px; }
  nav.menu a { padding: 4px 8px; font-size: 14.5px; }
}

/* ---------- generic page ---------- */
main { min-height: 60vh; }
.page-head { padding: 40px 0 8px; }
.page-head h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.2; margin: 0 0 6px; }
.page-head .sub { color: var(--muted); margin: 0; }
.prose { max-width: 72ch; }
.prose h2 { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 36px 0 10px; }
.prose h3 { font-size: 18px; margin: 26px 0 6px; }
.prose img { border-radius: 8px; border: 1px solid var(--line); }
.prose figure { margin: 24px 0; }
.prose figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; }
.prose blockquote { margin: 16px 0; padding: 4px 18px; border-left: 3px solid var(--line); color: var(--muted); }
.prose pre { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-size: 14px; }
.prose code { font-size: 0.92em; }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.muted { color: var(--muted); }

/* ---------- hero (home) ---------- */
.hero { display: grid; grid-template-columns: 180px 1fr; gap: 36px; align-items: center; padding: 48px 0 36px; }
.hero img { width: 180px; height: 180px; object-fit: cover; object-position: 50% 20%; border-radius: 50%; border: 1px solid var(--line); }
.hero h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.2; margin: 0 0 4px; }
.hero .role { color: var(--muted); margin: 0 0 14px; font-size: 15px; }
.hero .intro p { margin: 0 0 12px; max-width: 64ch; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pills a { font-size: 14px; font-weight: 500; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); }
.pills a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 18px; padding-top: 28px; }
  .hero img { width: 120px; height: 120px; }
  .hero h1 { font-size: 28px; }
}

/* ---------- sections ---------- */
section.block { padding: 32px 0; border-top: 1px solid var(--line); }
h2.sec { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 0 0 18px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h2.sec a.more { font-family: var(--sans); font-size: 14px; font-weight: 500; white-space: nowrap; }

/* image cards */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); display: flex; flex-direction: column; color: var(--text); }
a.card:hover { text-decoration: none; border-color: var(--accent); }
.card .fig { aspect-ratio: 16/10; background: #fff; overflow: hidden; }
.card .fig img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .fig.contain img { object-fit: contain; padding: 10px; }
.card .body { padding: 14px 16px 16px; }
.card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.card p { margin: 0; font-size: 14px; color: var(--muted); }
@media (max-width: 960px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .cards { grid-template-columns: 1fr; } }

/* papers + posts */
.two { display: grid; grid-template-columns: 3fr 2fr; gap: 40px; }
@media (max-width: 860px) {
  .two { grid-template-columns: 1fr; gap: 0; }
  .two > div + div { border-top: 1px solid var(--line); padding-top: 32px; margin-top: 32px; }
}
ul.plain { list-style: none; margin: 0; padding: 0; }
.paper { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.paper:last-child { border-bottom: 0; }
.paper .t { font-weight: 600; color: var(--text); }
.paper .a { font-size: 14px; color: var(--muted); }
.paper .a b { color: var(--text); font-weight: 500; }
.paper .m a { white-space: nowrap; }
.paper .m { font-size: 14px; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.paper .j { color: var(--text); font-style: italic; }
.paper details { margin-top: 4px; font-size: 14px; }
.paper details summary { cursor: pointer; color: var(--accent); display: inline; list-style: none; }
.paper details summary::-webkit-details-marker { display: none; }
.paper details p { margin: 6px 0 2px; color: var(--muted); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--bg-soft); color: var(--muted); border: 1px solid var(--line); }
.post { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.post:last-child { border-bottom: 0; }
.post .d { font-size: 13px; color: var(--muted); }
.post .t { font-weight: 600; color: var(--text); }
.post p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }

/* talks & videos */
.videos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 18px; }
.video { color: var(--text); display: block; }
.video .vlink { color: var(--text); display: block; }
.video .vlink:hover { text-decoration: none; }
.video .parts { font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.video .thumb { aspect-ratio: 16/9; border-radius: 8px; border: 1px solid var(--line); position: relative; overflow: hidden; background: var(--bg-soft); }
.video .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video .thumb .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; text-align: center;
  font-family: var(--serif); font-size: 15px; color: #fff; background: linear-gradient(135deg, #1f5fa8, #2d6ca2 45%, #21918c); }
.video .thumb.play::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(0,0,0,.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/22px no-repeat;
  opacity: .9; transition: opacity .15s;
}
.video .vlink:hover .thumb.play::after { opacity: 1; background-color: rgba(31,95,168,.9); }
.video .vt { font-size: 14px; font-weight: 600; margin-top: 8px; line-height: 1.35; }
.video .vm { font-size: 13px; color: var(--muted); }
.video .vlink:hover .vt { color: var(--accent); }
.lang { font-size: 11px; font-weight: 600; padding: 0 5px; border-radius: 3px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; }
@media (max-width: 860px) { .videos { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .videos { grid-template-columns: 1fr; } }

/* join banner */
.join { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 22px 24px; display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.join h3 { margin: 0 0 4px; font-size: 18px; }
.join p { margin: 0; color: var(--muted); max-width: 60ch; }
.btn { display: inline-block; padding: 9px 18px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 500; }
:root:not([data-theme="light"]) .btn { color: #fff; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }

/* ---------- publications page ---------- */
.pubs-layout { display: grid; grid-template-columns: 1fr 120px; gap: 40px; align-items: start; }
.years { position: sticky; top: 84px; font-size: 14px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 100px); overflow-y: auto; }
.years a { color: var(--muted); padding: 1px 8px; border-left: 2px solid var(--line); }
.years a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.pubs h2.year { font-family: var(--serif); font-size: 22px; margin: 28px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.pubtools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 16px 0 4px; }
.pubtools input { flex: 1; min-width: 200px; max-width: 420px; font: inherit; font-size: 15px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.pubtools input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.paper .num { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-right: 6px; }
@media (max-width: 860px) {
  .pubs-layout { grid-template-columns: 1fr; }
  .years { position: static; flex-direction: row; flex-wrap: wrap; order: -1; max-height: none; gap: 4px; }
  .years a { border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; }
}

/* ---------- blog ---------- */
.postlist .post { padding: 16px 0; }
.post-meta { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); margin-top: 40px; padding: 24px 0 40px; font-size: 14px; color: var(--muted); }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
