:root {
  --text: #1f2328;
  --muted: #5f6670;
  --rule: #e4e6ea;
  --accent: #a8323e;
  --accent-hover: #7f2530;
  --bg: #ffffff;
  color-scheme: light;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Dark theme: follows the system setting until the header toggle (theme.js) sets a choice */
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #e6e7e9;
  --muted: #a0a6ae;
  --rule: #30343a;
  --accent: #8db8ec;
  --accent-hover: #b5d2f5;
  --bg: #16181b;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  overflow-wrap: break-word;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Header */
header {
  position: relative;
  border-bottom: 1px solid var(--rule);
}

header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 22px;
  padding-bottom: 18px;
}

header .name {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  font-size: 0.95rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 2px 0;
  border-bottom: 2px solid transparent;
}

nav a:hover { color: var(--text); }

.theme-toggle {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover { color: var(--text); border-color: var(--muted); }

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg { width: 16px; height: 16px; fill: currentColor; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }

nav a.current {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Main content */
main {
  padding-top: 40px;
  padding-bottom: 72px;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 2.1rem;
  margin: 0 0 24px;
}

h2 {
  font-size: 1.4rem;
  margin: 36px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

h3 {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 26px 0 10px;
  color: var(--muted);
}

h1 + h2 { margin-top: 28px; }
h2 + h3 { margin-top: 14px; }

p { margin: 0 0 16px; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

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

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

header .name:hover { color: var(--text); }

ul {
  margin: 0 0 16px;
  padding-left: 20px;
}

li { margin-bottom: 8px; }
ul:last-child { margin-bottom: 0; }
li::marker { color: var(--muted); }

li ul {
  margin-top: 6px;
  margin-bottom: 4px;
}

li li {
  margin-bottom: 4px;
  font-size: 0.95em;
  color: var(--muted);
}

.note {
  color: var(--muted);
  font-size: 0.92em;
}

.date {
  font-weight: 600;
}

/* Resume: date column beside each entry */
.cv {
  display: grid;
  gap: 18px;
  margin-bottom: 8px;
}

.entry {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 4px 24px;
}

.when {
  color: var(--muted);
  font-size: 0.92rem;
  padding-top: 2px;
}

.what { min-width: 0; }
.what strong { font-weight: 600; }

ul.details {
  list-style: none;
  display: grid;
  gap: 6px;
  margin: 8px 0 0;
  padding-left: 0;
}

ul.details li {
  position: relative;
  margin: 0;
  padding-left: 16px;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--muted);
}

ul.details li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: color-mix(in srgb, var(--muted) 60%, transparent);
}

/* Home page: photo beside bio */
.intro {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 36px;
  align-items: start;
}

.intro h1 { margin-bottom: 18px; }

img.profile {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  margin-top: 6px;
}

/* Lists of papers and links */
.pubs {
  list-style: none;
  padding-left: 0;
}

.pubs > li {
  margin-bottom: 14px;
  padding-left: 14px;
  border-left: 2px solid var(--rule);
}

/* Keep the menu clear of the toggle once the screen edge reaches the content */
@media (max-width: 900px) {
  header .wrap { padding-right: 62px; }
}

@media (max-width: 640px) {
  .theme-toggle { top: 18px; transform: none; }
  body { font-size: 1rem; }
  main { padding-top: 28px; }
  h1 { font-size: 1.75rem; }
  .intro {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  img.profile { max-width: 140px; margin-top: 0; }
  h2 { margin-top: 32px; font-size: 1.3rem; }
  header .wrap { padding-top: 16px; padding-bottom: 12px; row-gap: 4px; }
  nav { gap: 4px 18px; }
  .entry { grid-template-columns: 1fr; gap: 0; }
  .when { padding-top: 0; }
}

/* Profile links under the name */
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: -6px 0 20px;
  font-size: 0.93rem;
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
}

.links a:hover { color: var(--accent); }

.links svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  flex: none;
}

details { margin-top: 4px; }

summary {
  cursor: pointer;
  width: fit-content;
  font-size: 0.85rem;
  color: var(--muted);
}

summary:hover { color: var(--text); }

details p {
  margin: 8px 0 4px;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Small link buttons under a paper */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tags a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}

.tags a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tags a.highlight {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.tags a.highlight:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }

.tags svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
