:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #2d2d2d;
  --ink-muted: #6b6b6b;
  --link: #0a4a8a;
  --link-hover: #0c5eb0;
  --line: #e5e5e5;
  --line-strong: #c9c9c9;
  --accent-bg: #fafaf8;
  --serif: 'Source Serif 4', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg: #141414;
  --ink: #ececec;
  --ink-soft: #d4d4d4;
  --ink-muted: #9a9a9a;
  --link: #7ab0e5;
  --link-hover: #a3c7ee;
  --line: #2a2a2a;
  --line-strong: #3b3b3b;
  --accent-bg: #1a1a1a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }

/* Top nav */
.topnav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topnav-inner {
  max-width: 760px; margin: 0 auto;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 20px;
  font-family: var(--sans); font-size: 14px;
}
.home { color: var(--ink); font-weight: 600; }
.home:hover { text-decoration: none; }
.topnav nav { display: flex; gap: 11px; flex: 1; flex-wrap: wrap; font-size: 13px; }
.topnav nav a { color: var(--ink-muted); }
.topnav nav a:hover { color: var(--ink); text-decoration: none; }
.topnav nav a.active { color: var(--ink); }
.topnav-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: transparent; border: none; color: var(--ink-muted);
  width: 28px; height: 28px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.icon-btn:hover { color: var(--ink); background: var(--accent-bg); }
.link-btn {
  background: transparent; border: none; padding: 0;
  color: var(--link); cursor: pointer; font: inherit;
  font-family: var(--sans); font-size: 14px;
}
.link-btn:hover { color: var(--link-hover); text-decoration: underline; text-underline-offset: 3px; }

/* Container */
.container { max-width: 720px; margin: 0 auto; padding: 40px 24px 80px; }

/* Hero */
.hero { margin-bottom: 56px; }
.hero h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: 32px; letter-spacing: -.01em;
  margin: 0 0 14px;
}
.hero .han { color: var(--ink-muted); font-weight: 400; font-size: .72em; margin-left: 6px; }

.intro { margin: 0 0 14px; color: var(--ink-soft); font-size: 17px; }
.intro em { font-style: italic; color: var(--ink); }

.links { margin: 0 0 24px; font-family: var(--sans); font-size: 14px; color: var(--ink-muted); }
.links .dot { margin: 0 6px; color: var(--ink-muted); }

.portrait {
  margin: 8px 0 0; text-align: center;
}
.portrait img {
  width: 180px; height: 180px;
  object-fit: cover; border-radius: 4px;
  border: 1px solid var(--line-strong);
  cursor: zoom-in;
  transition: opacity .15s;
}
.portrait img:hover { opacity: .9; }
.portrait figcaption {
  margin-top: 8px;
  font-family: var(--sans); font-size: 12px;
  color: var(--ink-muted);
}

/* Section */
.section { margin: 72px 0; }
.section + .section { margin-top: 72px; }
.section h2 {
  font-family: var(--serif); font-weight: 700;
  font-size: 28px; letter-spacing: -.01em;
  margin: 0 0 24px;
  padding-bottom: 10px; border-bottom: 2px solid var(--ink);
  color: var(--ink);
}
.subhead {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-muted); margin: 18px 0 10px;
}

.para { margin: 0 0 14px; color: var(--ink-soft); }
.para.small { font-size: 15.5px; margin-top: 6px; }

/* News */
.news { margin: 0; }
.news-item {
  display: grid; grid-template-columns: 100px 1fr; gap: 16px;
  padding: 6px 0; border-bottom: 1px dotted var(--line);
  font-size: 16px;
}
.news-item:last-child { border-bottom: none; }
.news-item dt {
  font-family: var(--sans); font-size: 13px;
  color: var(--ink-muted); padding-top: 4px;
}
.news-item dd { margin: 0; color: var(--ink-soft); }

/* Topics list (Research) */
.topics { margin: 12px 0 0; padding-left: 20px; color: var(--ink-soft); }
.topics li { margin: 6px 0; }

/* Generic list (Education, Experience, Projects, Teaching, Service) */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px dotted var(--line); }
.list > li:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  flex-wrap: wrap;
}
.row > div { flex: 1 1 340px; }
.row > div > strong:first-child { font-size: 18px; color: var(--ink); }
.date {
  font-family: var(--sans); font-size: 13px; color: var(--ink-muted);
  white-space: nowrap;
}
.muted { color: var(--ink-muted); font-size: 15.5px; }

/* Bullets */
.bullets { margin: 8px 0 0; padding-left: 20px; color: var(--ink-soft); font-size: 16px; }
.bullets li { margin: 4px 0; }

/* Publications */
.pubs { margin: 0; padding-left: 20px; color: var(--ink-soft); }
.pubs li { margin: 10px 0; line-height: 1.55; }
.pubs strong { color: var(--ink); font-weight: 600; }
.pubs .ko { color: var(--ink-muted); font-size: 14px; }
.pubs em { font-style: italic; }

.pub-item { display: flex; gap: 18px; align-items: flex-start; }
.pub-thumb {
  flex-shrink: 0; display: block;
  width: 110px; cursor: zoom-in;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  transition: opacity .15s, transform .15s;
}
.pub-thumb:hover { opacity: .85; transform: translateY(-1px); }
.pub-thumb img { width: 100%; height: auto; display: block; }
.pub-text { flex: 1; min-width: 0; }
.pub-actions { margin: 8px 0 0; font-family: var(--sans); font-size: 13px; }
.pub-actions a {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--ink-soft);
  margin-right: 6px;
}
.pub-actions a:hover {
  background: var(--accent-bg);
  color: var(--ink);
  text-decoration: none;
  border-color: var(--ink-muted);
}

/* PDF lightbox */
.pdf-lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.pdf-lightbox[hidden] { display: none; }
.pdf-lightbox-inner {
  background: #fff; border-radius: 6px;
  width: min(900px, 95vw); height: min(90vh, 1100px);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  overflow: hidden;
}
.pdf-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: #f4f4f4; border-bottom: 1px solid #d8d8d8;
  font-family: var(--sans); font-size: 13px;
}
.pdf-toolbar a {
  color: #1a1a1a; padding: 5px 12px;
  border: 1px solid #c5c5c5; border-radius: 4px;
  background: #fff; text-decoration: none;
}
.pdf-toolbar a:hover { background: #ececec; text-decoration: none; }
#pdfClose {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: #555;
  width: 30px; height: 30px; border-radius: 4px;
}
#pdfClose:hover { background: #ececec; color: #000; }
#pdfFrame { flex: 1; width: 100%; border: 0; background: #fff; }

/* Skills */
.skills { list-style: none; margin: 0; padding: 0; color: var(--ink-soft); }
.skills li { margin: 6px 0; font-size: 16px; }
.skills .key {
  font-family: var(--sans); font-size: 12px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); margin-right: 8px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--line);
  padding: 24px; text-align: center;
  font-family: var(--sans); font-size: 12px; color: var(--ink-muted);
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg);
  padding: 9px 14px; border-radius: 4px;
  font-family: var(--sans); font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: min(420px, 90vw); max-height: 90vh;
  border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

/* Responsive */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .topnav-inner { flex-wrap: wrap; gap: 10px 14px; padding: 10px 16px; }
  .topnav nav { order: 3; flex-basis: 100%; gap: 12px; font-size: 13px; }
  .container { padding: 28px 18px 60px; }
  .hero h1 { font-size: 26px; }
  .news-item { grid-template-columns: 86px 1fr; gap: 12px; }
  .portrait img { width: 150px; height: 150px; }
  .pub-item { flex-direction: column; gap: 12px; }
  .pub-thumb { width: 140px; }
}

/* Print */
@media print {
  :root {
    --bg: #fff; --ink: #000; --ink-soft: #111; --ink-muted: #555;
    --link: #000; --line: #ccc;
  }
  html, body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }
  .topnav, .footer, .toast, .lightbox, .pdf-lightbox, #themeToggle, #downloadPdf { display: none !important; }
  .pub-item { display: block; }
  .pub-thumb { display: none; }
  .pub-actions { display: none; }
  .container { max-width: 100%; padding: 0; }
  .hero { margin-bottom: 18px; }
  .section { margin: 18px 0; page-break-inside: avoid; }
  .section + .section { margin-top: 18px; }
  .section h2 { font-size: 14pt; margin-bottom: 10px; padding-bottom: 4px; border-bottom: 1.5px solid #000; }
  .row > div > strong:first-child { font-size: 11.5pt; }
  .portrait img { width: 110px; height: 110px; border: 1px solid #aaa; }
  .portrait figcaption { font-size: 9pt; }
  a { color: #000 !important; text-decoration: none; }
  .news-item, .list > li, .bullets li { page-break-inside: avoid; }
}
