/* ---------- Design tokens ---------- */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-soft: #55555f;
  --muted: #8a8a94;
  --border: #e6e6e2;
  --accent: #2f5c8f;
  --accent-soft: #eaf0f7;
  --badge-accept-bg: #e7f3ec;
  --badge-accept-fg: #276749;
  --badge-submit-bg: #eef1f6;
  --badge-submit-fg: #3a4d6b;
  --badge-manu-bg: #f4eee7;
  --badge-manu-fg: #7a5a30;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
  --maxw: 820px;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --bg-soft: #161922;
    --surface: #161922;
    --text: #e8e8ea;
    --text-soft: #b0b3bd;
    --muted: #7c8090;
    --border: #262a35;
    --accent: #7fa8db;
    --accent-soft: #1b2432;
    --badge-accept-bg: #16281d;
    --badge-accept-fg: #7fc79a;
    --badge-submit-bg: #1a2130;
    --badge-submit-fg: #9db4d6;
    --badge-manu-bg: #2a2318;
    --badge-manu-fg: #cfa871;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.25);
  }
}

/* Explicit theme overrides via toggle */
:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #161922;
  --surface: #161922;
  --text: #e8e8ea;
  --text-soft: #b0b3bd;
  --muted: #7c8090;
  --border: #262a35;
  --accent: #7fa8db;
  --accent-soft: #1b2432;
  --badge-accept-bg: #16281d;
  --badge-accept-fg: #7fc79a;
  --badge-submit-bg: #1a2130;
  --badge-submit-fg: #9db4d6;
  --badge-manu-bg: #2a2318;
  --badge-manu-fg: #cfa871;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 20px rgba(0,0,0,0.25);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Top nav ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; color: var(--accent); }
.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.nav-links a {
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s, color .2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.nav-toggle { display: none; }

/* ---------- Layout ---------- */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}
.section {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}
.section h2 {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 22px;
}
.section p { color: var(--text-soft); }

/* ---------- Hero ---------- */
.hero {
  display: flex;
  align-items: center;
  gap: 34px;
  padding: 56px 0 44px;
}
.avatar {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid var(--surface);
  box-shadow: var(--shadow);
}
.hero-text h1 {
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.tagline {
  font-size: 1.05rem;
  color: var(--text);
  margin: 0 0 6px;
  font-weight: 500;
}
.affil {
  color: var(--text-soft) !important;
  margin: 0 0 16px;
  font-size: 0.95rem;
}
.links {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  margin: 0 0 12px;
}
.links a {
  display: inline-block;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface);
  transition: all .18s ease;
}
.links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
  transform: translateY(-1px);
}
.contact-line { font-size: 0.85rem; color: var(--muted) !important; margin: 0; }
.contact-line .sep { margin: 0 6px; opacity: 0.6; }
.contact-line a { color: var(--muted); }

/* ---------- About ---------- */
#about p { margin: 0 0 14px; max-width: 68ch; }

/* ---------- News ---------- */
.news-list { list-style: none; padding: 0; margin: 0; }
.news-list li {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--text-soft);
  font-size: 0.94rem;
}
.news-list li:last-child { border-bottom: none; }
.news-list .date {
  flex-shrink: 0;
  width: 84px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding-top: 1px;
}
.news-body { flex: 1; min-width: 0; }

/* ---------- Publications ---------- */
.pub-list { list-style: none; padding: 0; margin: 18px 0 0; counter-reset: pub; }
.pub {
  position: relative;
  padding: 16px 18px 16px 48px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .2s, transform .2s;
}
.pub:hover { border-color: var(--accent); transform: translateY(-1px); }
.pub::before {
  counter-increment: pub;
  content: counter(pub);
  position: absolute;
  left: 16px;
  top: 17px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pub-title {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin-bottom: 4px;
}
.pub-authors { font-size: 0.9rem; color: var(--text-soft); margin-bottom: 6px; }
.pub-authors strong { color: var(--text); }
.pub-venue { font-size: 0.86rem; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pub-links { margin-top: 8px; display: flex; gap: 12px; }
.pub-links a {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-accept { background: var(--badge-accept-bg); color: var(--badge-accept-fg); }
.badge-submit { background: var(--badge-submit-bg); color: var(--badge-submit-fg); }
.badge-manu   { background: var(--badge-manu-bg);   color: var(--badge-manu-fg); }

/* ---------- Entries (experience / research / projects) ---------- */
.entry { padding: 16px 0; border-bottom: 1px dashed var(--border); }
.entry:last-child { border-bottom: none; }
.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.entry-title { font-weight: 600; color: var(--text); font-size: 1rem; }
.entry-date { color: var(--muted); font-size: 0.84rem; white-space: nowrap; flex-shrink: 0; }
.entry-sub { color: var(--text-soft); font-size: 0.88rem; margin-top: 2px; }
.entry ul { margin: 8px 0 0; padding-left: 18px; }
.entry li { color: var(--text-soft); font-size: 0.92rem; margin-bottom: 5px; }

/* ---------- Two column (teaching + skills) ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.two-col .section { border-top: 1px solid var(--border); }
.skill-group { margin-bottom: 14px; }
.skill-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 2px;
}
.skill-group p { margin: 0; font-size: 0.92rem; }

/* ---------- Footer ---------- */
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 24px 48px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer p { margin: 4px 0; color: var(--text-soft); font-size: 0.88rem; }

/* ---------- Responsive ---------- */
@media (max-width: 680px) {
  html { scroll-padding-top: 60px; }
  .nav { padding: 10px 18px; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 18px 14px;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 8px 0; width: 100%; }
  .theme-toggle { margin-top: 8px; }
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    margin-left: auto;
    width: 38px;
    height: 34px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 0 9px;
  }
  .nav-toggle span {
    display: block;
    height: 2px;
    background: var(--text-soft);
    border-radius: 2px;
  }
  main { padding: 0 18px; }
  .hero {
    flex-direction: column;
    text-align: center;
    gap: 20px;
    padding: 40px 0 32px;
  }
  .avatar { width: 132px; height: 132px; }
  .hero-text h1 { font-size: 2.1rem; }
  .links { justify-content: center; }
  .contact-line { text-align: center; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .two-col .section:first-child { border-bottom: none; }
  .entry-head { flex-direction: column; gap: 2px; }
  .news-list li { flex-direction: column; gap: 2px; }
  .news-list .date { width: auto; }
  .pub { padding-left: 18px; }
  .pub::before { position: static; display: inline-block; margin-right: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
