/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:      #b45309;
  --accent-soft: #fef3c7;
  --text:        #1c1008;
  --muted:       #6b5a42;
  --border:      #e5d9c8;
  --bg:          #fffbf5;
  --bg-light:    #fdf6ec;
  --max-w:       860px;
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --accent:      #fbbf24;
    --accent-soft: #3d2c10;
    --text:        #f0e8d8;
    --muted:       #9c8a72;
    --border:      #3d2c10;
    --bg:          #18130a;
    --bg-light:    #221a0e;
  }
}
[data-theme="dark"] {
  --accent:      #fbbf24;
  --accent-soft: #3d2c10;
  --text:        #f0e8d8;
  --muted:       #9c8a72;
  --border:      #3d2c10;
  --bg:          #18130a;
  --bg-light:    #221a0e;
}
[data-theme="light"] {
  --accent:      #b45309;
  --accent-soft: #fef3c7;
  --text:        #1c1008;
  --muted:       #6b5a42;
  --border:      #e5d9c8;
  --bg:          #fffbf5;
  --bg-light:    #fdf6ec;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

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

/* ── Layout ─────────────────────────────────────────────────────────────────  */
.container   { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }

/* ── Header ─────────────────────────────────────────────────────────────────  */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.site-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.site-name:hover { text-decoration: none; }

.site-nav { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.site-nav a { font-size: 0.88rem; color: var(--muted); }
.site-nav a.active,
.site-nav a:hover { color: var(--accent); }
.site-nav .cv-link {
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
  font-size: 0.82rem;
}
.site-nav .cv-link:hover { background: var(--accent); color: #fff; text-decoration: none; }
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.1rem 0.2rem;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.theme-toggle:hover { opacity: 1; }

/* ── Main content ───────────────────────────────────────────────────────────  */
.page-content { padding: 2.5rem 1.5rem 4rem; }

/* ── Home / profile ─────────────────────────────────────────────────────────  */
.profile {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
  margin-bottom: 2.5rem;
}
.profile-photo {
  flex-shrink: 0;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}
.profile-info h1 { font-size: 1.55rem; margin-bottom: 0.2rem; }
.profile-info .affiliation { color: var(--muted); margin-bottom: 0.6rem; font-size: 0.9rem; }
.profile-links { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 0.5rem; }
.profile-links a { font-size: 0.85rem; }

/* ── Section headings ───────────────────────────────────────────────────────  */
h2.section-heading {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.25rem;
  margin: 2.2rem 0 1rem;
}

/* ── Publication list ───────────────────────────────────────────────────────  */
.pub-section { margin-bottom: 2.5rem; }
.pub-list    { list-style: none; }

.pub-item {
  display: flex;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid #eee;
}
.pub-item:last-child { border-bottom: none; }

.pub-num {
  flex-shrink: 0;
  width: 2rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.82rem;
  padding-top: 0.1rem;
}
.pub-body { flex: 1; }
.pub-title {
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 0.15rem;
}
.pub-title a       { color: var(--text); }
.pub-title a:hover { color: var(--accent); text-decoration: underline; }
.pub-authors       { font-size: 0.87rem; color: var(--muted); margin-bottom: 0.1rem; }
.pub-venue         { font-size: 0.87rem; color: var(--muted); }
.pub-awards        { display: inline-block; margin-left: 0.4rem;
                     font-size: 0.78rem; font-weight: 600;
                     color: var(--accent); background: var(--accent-soft);
                     padding: 0.05rem 0.35rem; border-radius: 3px; }
.pub-note          { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.pub-links         { margin-top: 0.2rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.pub-link-badge {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  text-decoration: none;
}
.pub-link-badge:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* ── Pub footnote ───────────────────────────────────────────────────────────  */
.pub-footnote { font-size: 0.82rem; color: var(--muted); margin-bottom: 1rem; }

/* ── Talks ──────────────────────────────────────────────────────────────────  */
.talk-list { list-style: none; }
.talk-item { padding: 0.6rem 0; border-bottom: 1px solid #eee; }
.talk-item:last-child { border-bottom: none; }
.talk-header { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.talk-title  { font-weight: 500; }
.talk-year   { flex-shrink: 0; color: var(--muted); font-size: 0.87rem; }
.talk-venues { list-style: disc; margin: 0.3rem 0 0 1.2rem; }
.talk-venues li { font-size: 0.88rem; color: var(--muted); }

/* ── Students ───────────────────────────────────────────────────────────────  */
.student-list { list-style: none; }
.student-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.45rem 0;
  border-bottom: 1px solid #eee;
  gap: 1rem;
  flex-wrap: wrap;
}
.student-item:last-child { border-bottom: none; }
.student-name   { font-weight: 500; }
.student-degree { font-size: 0.87rem; color: var(--muted); }
.student-years  { flex-shrink: 0; font-size: 0.87rem; color: var(--muted); }

/* ── Teaching ───────────────────────────────────────────────────────────────  */
.teaching-group  { margin-bottom: 1.8rem; }
.teaching-group h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.7rem; color: var(--text); }
.course-list   { list-style: none; }
.course-item   { padding: 0.5rem 0; border-bottom: 1px solid #eee; }
.course-item:last-child { border-bottom: none; }
.course-header { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.course-name   { font-weight: 500; }
.course-meta   { font-size: 0.87rem; color: var(--muted); }
.course-desc   { font-size: 0.87rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Service ────────────────────────────────────────────────────────────────  */
.service-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.service-table th {
  text-align: left;
  border-bottom: 2px solid var(--border);
  padding: 0.3rem 0.5rem 0.3rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.service-table td { padding: 0.35rem 0.5rem 0.35rem 0; border-bottom: 1px solid #eee; }
.service-table tr:last-child td { border-bottom: none; }

/* ── Group photo (students page) ────────────────────────────────────────────  */
.group-photo-wrap {
  margin-bottom: 2rem;
}
.group-photo {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  object-position: center top;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: block;
}
.group-photo-caption {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.4rem;
  font-style: italic;
}

/* ── Photos ─────────────────────────────────────────────────────────────────  */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.photo-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: block;
}
.photo-caption {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.35rem;
  line-height: 1.4;
}
.photo-event {
  font-style: italic;
}

/* ── News feed ───────────────────────────────────────────────────────────────  */
.news-list {
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
}
.news-item {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.news-item:last-child { border-bottom: none; }
.news-date {
  flex-shrink: 0;
  min-width: 5.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.news-badge {
  flex-shrink: 0;
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.news-badge--paper   { background: var(--accent-soft); color: var(--accent); }
.news-badge--award   { background: var(--accent-soft); color: var(--accent); }
.news-badge--hiring  { background: var(--accent-soft); color: var(--accent); }
.news-badge--student { background: var(--accent-soft); color: var(--accent); }
.news-badge--talk    { background: var(--accent-soft); color: var(--accent); }
.news-badge--other   { background: var(--bg-light); color: var(--muted); }
.news-text { flex: 1; }

/* ── Topic filters ───────────────────────────────────────────────────────────  */
.topic-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 1rem 0 1.5rem;
}
.topic-filter-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-right: 0.25rem;
}
.topic-btn {
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.topic-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.topic-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Stats page ─────────────────────────────────────────────────────────────  */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-light);
  text-align: center;
}
.stat-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.35rem;
}
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin: 1rem 0 1.5rem;
}
.stats-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
}
.stats-table td {
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.stats-table tr:last-child td { border-bottom: none; }
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Footer ─────────────────────────────────────────────────────────────────  */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* ── Responsive ─────────────────────────────────────────────────────────────  */
@media (max-width: 600px) {
  .profile { flex-direction: column; }
  .profile-photo { width: 120px; height: 120px; }
  .pub-item { flex-direction: column; gap: 0.3rem; }
  .pub-num  { text-align: left; width: auto; }
}

/* ── Research cards ──────────────────────────────────────────────────────────  */
.research-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.2rem;
  margin: 1.5rem 0 2rem;
}
.research-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.3rem 1.2rem 1rem;
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.research-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(180,83,9,0.12);
}
.research-card-icon {
  font-size: 1.6rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}
.research-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.1rem;
}
.research-card-desc {
  font-size: 0.87rem;
  color: var(--muted);
  flex: 1;
  line-height: 1.5;
}
.research-card-link {
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.4rem;
  display: inline-block;
}
.research-card-link:hover { text-decoration: underline; }

/* ── About page ──────────────────────────────────────────────────────────────  */
.edu-list { list-style: none; margin: 0.5rem 0 1rem; }
.edu-item {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #eee;
  font-size: 0.92rem;
}
.edu-item:last-child { border-bottom: none; }
.edu-degree { font-weight: 500; flex: 1; }
.edu-detail { color: var(--muted); font-size: 0.87rem; }
.about-more-link {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.88rem;
}

/* ── BibTeX toggle ───────────────────────────────────────────────────────────  */
.bibtex-details {
  display: inline-block;
  vertical-align: middle;
}
.bibtex-details summary {
  display: inline-block;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  list-style: none;
  user-select: none;
}
.bibtex-details summary::-webkit-details-marker { display: none; }
.bibtex-details summary:hover { background: var(--accent); color: #fff; }
.bibtex-details[open] summary { background: var(--accent); color: #fff; }
.bibtex-pre {
  margin-top: 0.4rem;
  flex-basis: 100%;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.7rem 0.9rem;
  font-size: 0.78rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.55;
  color: var(--text);
}

/* ── Students page ───────────────────────────────────────────────────────────  */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.4rem;
  margin: 1.5rem 0 2.5rem;
}
.student-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.2rem 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-light);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.student-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(180,83,9,0.12);
}
.student-avatar-wrap {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 0.75rem;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.student-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.student-avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.student-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.2rem;
  line-height: 1.3;
}
.student-name a { color: var(--text); }
.student-name a:hover { color: var(--accent); text-decoration: underline; }
.student-degree {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.student-years {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.student-status {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-bottom: 0.35rem;
}
.student-status--current  { background: #d1fae5; color: #065f46; }
.student-status--graduated { background: #fef3c7; color: #92400e; }
.student-position {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
  font-style: italic;
}
@media (max-width: 600px) {
  .student-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Research interests block (about page) ───────────────────────────────────  */
.research-interests {
  margin: 0.8rem 0 0.5rem;
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.research-interests p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text);
}

/* ── Content page section spacing ────────────────────────────────────────────  */
.page-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.9rem;
}
.page-content h3 {
  margin-top: 1.6rem;
  margin-bottom: 0.5rem;
}
.page-content hr {
  margin: 2.2rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

/* ── Content page bullet/ordered lists ──────────────────────────────────────  */
.page-content ul, .page-content ol {
  margin: 0.6rem 0 0.6rem 2rem;
  padding: 0;
}
.page-content li {
  margin-bottom: 0.35rem;
}
/* Reset indentation for explicitly styled lists */
.page-content .pub-list,
.page-content .news-list,
.page-content .edu-list,
.page-content .course-list,
.page-content .student-list,
.page-content .talk-list {
  margin-left: 0;
}
