:root {
  --bg: #141413;
  --fg: #ecebe6;
  --muted: #9a968d;
  --line: #2a2926;
  --accent: #5b8ecf;
  --card: #1b1a19;
  --serif: "DM Serif Text", Georgia, serif;
  --display: "DM Serif Display", "DM Serif Text", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --w: 760px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f5f0;
  --fg: #1b1a18;
  --muted: #6f6b63;
  --line: #e2ddd3;
  --accent: #0f2b4e;
  --card: #fffdf9;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141413;
  --fg: #ecebe6;
  --muted: #9a968d;
  --line: #2a2926;
  --accent: #5b8ecf;
  --card: #1b1a19;
  color-scheme: dark;
}

.theme-toggle {
  display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  background: none; border: 1px solid var(--line); border-radius: 50%;
  color: var(--muted); cursor: pointer; transition: color .2s, border-color .2s;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--muted); }
.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.theme-toggle .moon { display: none; }
.theme-toggle[data-mode="light"] .sun { display: none; }
.theme-toggle[data-mode="light"] .moon { display: block; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; transition: color .2s, text-decoration-color .2s; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
::selection { background: var(--accent); color: var(--bg); }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 2rem;
  max-width: var(--w); margin: 0 auto; padding: 1.1rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.mark { font: 400 1.15rem var(--display); text-decoration: none; letter-spacing: .02em; }
.topbar nav { display: flex; gap: 1.4rem; margin-right: auto; font-size: .9rem; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.topbar nav a:hover { color: var(--fg); }
.lang { display: flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); }
.lang button {
  font: inherit; letter-spacing: .06em; background: none; border: 0; padding: .2rem .15rem;
  color: var(--muted); cursor: pointer;
}
.lang button[aria-pressed="true"] { color: var(--fg); font-weight: 500; }

main { max-width: var(--w); margin: 0 auto; padding: 0 1.5rem; }

/* Hero */
.hero { padding: 4.5rem 0 3.5rem; }
.hero-head { display: flex; align-items: center; gap: 1.8rem; margin-bottom: 2.6rem; }
.portrait {
  width: 112px; height: 112px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
h1 {
  font: 400 clamp(2.4rem, 6vw, 3.4rem)/1.05 var(--display);
  letter-spacing: -.02em; margin: 0 0 .35rem;
}
.lede { font: 400 1.15rem/1.5 var(--serif); font-style: italic; color: var(--muted); margin: 0; }
.roles { list-style: none; padding: 0; margin: 0; display: grid; gap: .25rem; }
.roles li {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1rem; margin: 0 -1rem; border-radius: 12px; transition: background .25s;
}
.roles li:hover { background: var(--card); }
.ico {
  width: 38px; height: 38px; padding: 9px; flex-shrink: 0; border-radius: 50%;
  border: 1px solid var(--line); fill: none; stroke: var(--accent);
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.roles strong { display: block; font-weight: 500; font-size: .95rem; line-height: 1.35; }
.roles span { display: block; font-size: .85rem; color: var(--muted); }
.roles span a { text-decoration: none; }
.roles span a:hover { color: var(--accent); }

/* Blocks */
.block { padding: 3.5rem 0; border-top: 1px solid var(--line); }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
h2 {
  font: 400 1.9rem/1.2 var(--display); letter-spacing: -.01em;
  color: var(--fg); margin: 0 0 1.6rem;
}
.more { font-size: .85rem; color: var(--muted); text-decoration: none; }
.prose p { font: 400 1.05rem/1.75 var(--sans); margin: 0 0 1.25rem; }
.prose p:last-child { margin-bottom: 0; }

/* Academic sub-blocks */
.about-grid {
  margin-top: 2.2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.about-card {
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.about-card-full {
  grid-column: 1 / -1;
}
.about-card h3 {
  font: 500 .78rem var(--sans);
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  margin: 0 0 .95rem;
}
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.tag {
  display: inline-block;
  font-size: .86rem;
  padding: .3rem .7rem;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--fg);
  line-height: 1.4;
}
.edu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .85rem;
}
.edu-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: .5rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--line);
  font-size: .95rem;
}
.edu-list li:last-child {
  padding-bottom: 0;
  border-bottom: none;
}
.edu-list strong {
  font-weight: 500;
  color: var(--fg);
}
.edu-list span {
  color: var(--muted);
  font-size: .88rem;
}

/* Articles */
.articles { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.article a {
  display: grid; grid-template-columns: 168px 1fr; gap: 1.5rem; align-items: center;
  padding: 1rem; margin: 0 -1rem; border-radius: 14px; text-decoration: none;
  transition: background .25s;
}
.article a:hover { background: var(--card); color: inherit; }
.cover { aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: var(--line); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.article a:hover .cover img { transform: scale(1.04); }
.article h3 { font: 400 1.25rem/1.3 var(--serif); margin: 0 0 .4rem; letter-spacing: -.01em; }
.article a:hover h3 { color: var(--accent); }
.article time { font-size: .8rem; color: var(--muted); letter-spacing: .03em; }
.article p { font-size: .9rem; color: var(--muted); margin: .35rem 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Contact */
.contact-block { text-align: center; padding-bottom: 2rem; }
.contact-lede { color: var(--muted); margin: -.6rem auto 1.4rem; max-width: 30rem; }
.contact-email {
  display: inline-block; font: 400 clamp(1.25rem, 3.5vw, 1.6rem) var(--serif);
  text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: .15rem;
}
.contact-email:hover { border-color: var(--accent); }
.socials { list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: .7rem; }
.socials a {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1rem; border: 1px solid var(--line); border-radius: 999px;
  font-size: .88rem; color: var(--muted); text-decoration: none;
  transition: color .2s, border-color .2s, transform .2s;
}
.socials a:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.socials svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.footer { max-width: var(--w); margin: 0 auto; padding: 3rem 1.5rem; font-size: .8rem; color: var(--muted); text-align: center; }

/* Reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .8s ease, transform .8s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
}

@media (max-width: 600px) {
  .topbar { gap: 1rem; }
  .topbar nav { gap: .9rem; font-size: .82rem; }
  .hero { padding: 3rem 0 2.5rem; }
  .hero-head { gap: 1.1rem; margin-bottom: 1.8rem; }
  .portrait { width: 76px; height: 76px; }
  .article a { grid-template-columns: 1fr; gap: .9rem; }
  .about-grid { grid-template-columns: 1fr; gap: 1rem; }
  .edu-list li { flex-direction: column; gap: .2rem; }
}
