/* ===== Base ===== */
:root {
  --bg: #ffffff;
  --text: #1a1a1a;
  --muted: #777;
  --link: #1565c0;
  --rule: #e6e6e6;
  --placeholder: #f0f0f0;
  --maxw: 760px;
}

/* Dark palette shared by system-preference and manual override */
:root[data-theme="dark"],
:root.theme-dark {
  --bg: #16181c;
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --link: #6db3f2;
  --rule: #2c2f34;
  --placeholder: #24272c;
}

/* Follow the OS setting when the user hasn't chosen explicitly */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181c;
    --text: #e6e6e6;
    --muted: #9aa0a6;
    --link: #6db3f2;
    --rule: #2c2f34;
    --placeholder: #24272c;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ===== Theme toggle ===== */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { border-color: var(--muted); }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 56px 24px 80px;
}

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

/* ===== Header / profile ===== */
.profile {
  text-align: left;
  margin-bottom: 48px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 32px;
}

.profile-text { flex: 7; min-width: 0; }
.profile-photo {
  flex: 3;
  display: flex;
  justify-content: flex-end;
}

.avatar {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--placeholder);
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.name {
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px 18px;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.bio {
  margin: 18px 0 0;
  max-width: 540px;
  color: var(--muted);
}

/* ===== Section headings ===== */
section { margin-bottom: 44px; }

h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.date {
  display: inline-block;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 10px;
}

/* ===== News (collapsible via checkbox) ===== */
.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.news-list li { margin-bottom: 8px; }

.news-toggle { display: none; }

.news-more { display: none; }
.news-toggle:checked ~ .news-more { display: block; }

.news-label {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--link);
  cursor: pointer;
}
.news-label::after { content: "↓ SHOW MORE ↓"; }
.news-toggle:checked ~ .news-label::after { content: "↑ HIDE ↑"; }

/* ===== Education ===== */
.edu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.edu-list li { margin-bottom: 16px; }

.edu-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.edu-school { font-weight: 600; }
.edu-head .date { margin-right: 0; white-space: nowrap; }

.edu-detail { color: var(--muted); margin-top: 2px; }
.edu-note { font-style: italic; }

/* ===== Research / publications ===== */
.pub {
  display: flex;
  gap: 22px;
  margin-bottom: 30px;
  align-items: flex-start;
}

.pub-thumb {
  flex: 0 0 180px;
  height: 110px;
  border-radius: 6px;
  background: #ffffff;
}
.pub-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.pub-info { flex: 1; min-width: 0; }

.pub-title {
  font-weight: 600;
  font-size: 18px;
}

.pub-authors,
.pub-venue,
.pub-resources {
  margin: 6px 0 0;
}

.pub-authors .me {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pub-venue { color: var(--muted); font-style: italic; }

.pub-resources a {
  margin-right: 14px;
  font-size: 15px;
}

/* ===== Talks / awards lists ===== */
.talk-list,
.award-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.talk-list li,
.award-list li { margin-bottom: 10px; }

.brackets { color: var(--muted); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin-top: 60px;
}

/* ===== Responsive ===== */
@media (max-width: 560px) {
  .profile { text-align: center; }
  .profile-row {
    flex-direction: column-reverse;
    align-items: center;
    gap: 20px;
  }
  .profile-photo { justify-content: center; }
  .links { justify-content: center; }
  .bio { margin-left: auto; margin-right: auto; }

  .edu-head { flex-direction: column; gap: 0; }

  .pub { flex-direction: column; }
  .pub-thumb { flex-basis: auto; width: 100%; }
}
