:root {
  --bg: #f3f6f1;
  --fg: #1f2a22;
  --muted: #5c6b60;
  --rule: #d6e0d2;
  --accent: #2e6b47;
  --accent-hover: #1b4a2f;
  --nav-bg: #e7eee4;
  --maxw: 1080px;
}
/* Dark mode: follows the system unless the visitor picked light; toggle can force dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c2620;
    --fg: #e3e9e4;
    --muted: #a0ada4;
    --rule: #33413a;
    --accent: #8fcaa4;
    --accent-hover: #b6dec4;
    --nav-bg: #232f28;
  }
}
:root[data-theme="dark"] {
  --bg: #1c2620;
  --fg: #e3e9e4;
  --muted: #a0ada4;
  --rule: #33413a;
  --accent: #8fcaa4;
  --accent-hover: #b6dec4;
  --nav-bg: #232f28;
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  line-height: 0;
  align-self: center;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--muted); }
.theme-toggle svg { width: 15px; height: 15px; fill: currentColor; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Top navigation */
.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--nav-bg);
}
.masthead nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
}
.masthead .site-title {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--fg);
  margin-right: auto;
}
.masthead .site-title:hover { text-decoration: none; }
.masthead a.nav-link { color: var(--muted); }
.masthead a.nav-link:hover, .masthead a.nav-link.active { color: var(--fg); text-decoration: none; }
.masthead a.nav-link.active { font-weight: 600; }
@media (max-width: 520px) {
  .masthead nav { column-gap: 1.1rem; }
  .masthead .site-title { flex-basis: 100%; }
}

/* Layout */
.wrapper {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2.2rem 1rem 3rem;
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 3rem;
}
@media (max-width: 760px) {
  .wrapper { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 1.5rem; }
}

/* Sidebar */
.sidebar { font-size: 0.92rem; }
.sidebar img.avatar {
  width: 100%;
  max-width: 200px;
  border-radius: 6px;
  display: block;
  margin-bottom: 1rem;
}
.sidebar h2 { font-size: 1.25rem; margin: 0 0 0.2rem; }
.sidebar .bio { color: var(--muted); margin: 0 0 1rem; }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { display: flex; align-items: center; gap: 0.55rem; padding: 0.18rem 0; color: var(--muted); }
.sidebar li svg { width: 16px; height: 16px; flex-shrink: 0; fill: currentColor; }
@media (max-width: 760px) {
  .sidebar { display: grid; grid-template-columns: 110px 1fr; gap: 0 1rem; align-items: start; }
  .sidebar img.avatar { grid-row: span 3; margin: 0; }
}

/* Content */
.content { min-width: 0; }
.content h1 {
  font-size: 1.7rem;
  margin: 0 0 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}
.content h2 {
  font-size: 1.25rem;
  margin: 2rem 0 0.8rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}
.content p { margin: 0 0 1rem; }

/* Papers */
.paper { margin: 0 0 1.4rem; }
.paper .title { font-weight: 600; }
.paper .coauthors { color: var(--fg); }
.paper .status { color: var(--muted); font-style: italic; }
.paper .links { margin-top: 0.1rem; }
.paper .presentations { color: var(--muted); font-size: 0.9rem; margin-top: 0.2rem; }

.content ul.resources { padding-left: 1.2rem; }
.content ul.resources li { margin-bottom: 0.35rem; }

.note {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0.9rem;
  background: var(--nav-bg);
  font-size: 0.95rem;
}

.cv-embed {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--rule);
  border-radius: 4px;
  margin: 0.5rem 0 1.5rem;
}

footer {
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.2rem 1rem 2rem;
}
