:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --fg: #14171d;
  --mut: #5a6372;
  --acc: #0b7d73;
  --acc-fg: #ffffff;
  --line: #dfe3ea;
  --tile: #ffffff;
  --radius: 14px;
}
:root[data-theme="dark"] {
  --bg: #0f1115;
  --card: #181b22;
  --fg: #e8eaf0;
  --mut: #8f96a6;
  --acc: #4fd1c5;
  --acc-fg: #0f1115;
  --line: #262a33;
  --tile: #ffffff; /* logos are dark line art: keep their tiles light in both themes */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --card: #181b22;
    --fg: #e8eaf0;
    --mut: #8f96a6;
    --acc: #4fd1c5;
    --acc-fg: #0f1115;
    --line: #262a33;
    --tile: #ffffff;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--acc); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--acc); outline-offset: 3px; border-radius: 4px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; background: var(--card); padding: 8px 12px; z-index: 10; }

/* header */
/* Sticky header: stays at the top while scrolling. */
:root { --header-h: 90px; }
html { scroll-padding-top: calc(var(--header-h) + 8px); }  /* in-page links land below the header */
header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header.top .bar { display: flex; align-items: center; gap: 6px 14px; padding-top: 10px; padding-bottom: 10px; }
header.top .name { display: inline-flex; align-items: center; gap: 14px; font-weight: 650; font-size: 1.6rem; letter-spacing: -.01em; color: var(--fg); text-decoration: none; }
header.top .name img { height: 68px; width: auto; }
nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; margin-left: auto; }
nav a { color: var(--mut); text-decoration: none; font-size: .9rem; }
nav a:hover { color: var(--acc); }
/* Light switch: lever up = light mode, down = dark mode */
#theme { background: none; border: 0; padding: 4px; margin-left: 6px; cursor: pointer; line-height: 0; }
.sw-plate {
  display: block; position: relative; width: 24px; height: 36px; border-radius: 6px;
  background: var(--card); border: 1.5px solid var(--line); transition: border-color .15s;
}
.sw-plate::before { /* slot the lever travels in */
  content: ""; position: absolute; left: 50%; top: 5px; bottom: 5px; width: 10px; margin-left: -5px;
  border-radius: 5px; background: var(--bg); border: 1px solid var(--line);
}
.sw-lever {
  position: absolute; left: 50%; width: 14px; height: 16px; margin-left: -7px; border-radius: 4px;
  background: var(--acc); top: 4px; transition: top .18s ease;
}
#theme[aria-checked="true"] .sw-lever { top: 14px; } /* dark: lever down */
#theme:hover .sw-plate { border-color: var(--acc); }
@media (prefers-reduced-motion: reduce) { .sw-lever, .sw-plate { transition: none; } }

/* hero */
.hero { padding: 56px 0 8px; }
.lead { font-size: clamp(1.5rem, 3.4vw, 2.1rem); line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .5em; max-width: 820px; font-weight: 650; text-align: justify; text-justify: inter-word; hyphens: manual; }
.lead em { color: var(--acc); font-style: normal; }
.sub { color: var(--mut); max-width: 820px; margin: 0 0 1.2em; font-size: 1.05rem; text-align: justify; text-justify: inter-word; hyphens: auto; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 8px; padding: 0; list-style: none; }
.links a {
  display: inline-block; padding: 7px 14px; border: 1px solid var(--line); border-radius: 99px;
  text-decoration: none; font-size: .9rem; color: var(--fg); background: var(--card);
}
.links a:hover { border-color: var(--acc); color: var(--acc); }
.links a.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-fg); }
.links a.primary:hover { color: var(--acc-fg); opacity: .9; }

/* stats */
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 32px 0 0; }
.strip div { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--mut); font-size: .85rem; }
.strip b { display: block; color: var(--fg); font-size: 1.6rem; line-height: 1.2; }

/* sections */
section { padding: 52px 0 0; }
h2 { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mut); margin: 0 0 18px; font-weight: 600; }

/* project cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.tile { height: 170px; display: grid; place-items: center; background: var(--tile); border-bottom: 1px solid var(--line); padding: 14px; }
.tile img { max-width: 100%; max-height: 142px; width: auto; height: auto; object-fit: contain; }
a.tile { text-decoration: none; transition: filter .15s; }
a.tile img { transition: transform .2s ease; }
a.tile:hover img { transform: scale(1.04); }
a.tile:hover { filter: brightness(.97); }
a.tile:focus-visible { outline-offset: -3px; }
@media (prefers-reduced-motion: reduce) { a.tile, a.tile img { transition: none; } a.tile:hover img { transform: none; } }
.tile.shot { padding: 0; }
.tile.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.tile.ph { background: linear-gradient(135deg, var(--line), var(--card)); color: var(--mut); font-size: .85rem; text-align: center; }
.tile.ph strong { display: block; color: var(--fg); font-size: 1.15rem; letter-spacing: -.01em; }
.card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.card h3 { margin: 0 0 .3em; font-size: 1.15rem; }
.card p { margin: 0 0 .9em; color: var(--mut); font-size: .93rem; }
.tags { margin: 0 0 14px; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font-size: .72rem; padding: 2px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--mut); }
.card .actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .9rem; }

/* impact timeline */
.tl { border-left: 2px solid var(--line); padding-left: 22px; margin: 0; list-style: none; }
.tl li { position: relative; margin: 0 0 22px; }
.tl li::before { content: ""; position: absolute; left: -29px; top: .5em; width: 10px; height: 10px; border-radius: 50%; background: var(--acc); }
.tl b { display: block; }
.tl span { color: var(--mut); font-size: .95rem; }

/* publications */
.pubs { list-style: none; margin: 0; padding: 0; }
.pubs li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.pubs li:last-child { border-bottom: 0; }
.pubs a { color: var(--fg); text-decoration: none; font-weight: 500; }
.pubs a:hover { color: var(--acc); }
.pubs .meta { display: block; color: var(--mut); font-size: .88rem; }
.more { margin-top: 14px; font-size: .92rem; color: var(--mut); }

/* skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px 28px; }
.skills h3 { margin: 0 0 8px; font-size: .95rem; }
.skills .tags li { background: var(--card); }

footer { margin: 64px 0 0; padding: 24px 0 40px; border-top: 1px solid var(--line); color: var(--mut); font-size: .88rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

@media (max-width: 520px) {
  .hero { padding-top: 36px; }
  .tile { height: 140px; }
  .tile img { max-height: 112px; }
}
/* Compact header for phones and narrow tablets: the full-size name plus the
   links no longer fit on one row, so the name wraps. Switch stays on row one,
   links drop to row two. */
@media (max-width: 700px) {
  :root { --header-h: 96px; }
  header.top .bar { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  header.top .name { font-size: 1.15rem; gap: 10px; white-space: nowrap; }
  header.top .name img { height: 40px; }
  #theme { order: 2; margin-left: auto; }
  nav { order: 3; flex-basis: 100%; margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* impact sub-blocks */
.sub-h { font-size: 1.05rem; margin: 34px 0 12px; font-weight: 650; letter-spacing: -.01em; }
#impact h2 + .sub-h { margin-top: 0; }
.note { color: var(--mut); max-width: 760px; margin: 14px 0 0; font-size: .95rem; }
.note b { color: var(--fg); }
.lead-note { margin-top: 0; }
.trials { grid-template-columns: repeat(2, 1fr); }  /* 2 x 2 on wide screens, one column on phones (see media rule below) */
.trials .card .body { padding: 14px 16px; }
.trials .card h3 { font-size: 1rem; margin: 0 0 .3em; font-weight: 650; }
.trials .card p { margin: 0; font-size: .88rem; }

/* invited talks */
.talks li { display: flex; gap: 18px; align-items: baseline; }
.talks .yr { flex: 0 0 3.2em; color: var(--acc); font-weight: 600; font-variant-numeric: tabular-nums; }
.talks b { font-weight: 600; }

/* funding */
.funding { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 16px; }
.funding .card .body { padding: 16px 18px; }
.funding .card h3 { font-size: 1rem; margin: 0 0 .6em; font-weight: 650; }
.funding ul { margin: 0; padding-left: 1.1em; color: var(--mut); font-size: .9rem; }
.funding li { margin: 0 0 .5em; }
.funding li:last-child { margin-bottom: 0; }

/* full publication list */
.pubs .meta b { color: var(--fg); font-weight: 600; }
.pubs .role { display: inline-block; margin-left: 8px; font-size: .7rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--acc); color: var(--acc); font-weight: 600; vertical-align: 1px; }

/* clickable hero tiles */
.strip a { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--mut); font-size: .85rem; text-decoration: none; transition: border-color .15s, transform .15s; }
.strip a b { display: block; color: var(--fg); font-size: 1.6rem; line-height: 1.2; }
.strip a:hover { border-color: var(--acc); transform: translateY(-2px); }
.strip a:hover b { color: var(--acc); }
h2, .sub-h { scroll-margin-top: 20px; }
@media (prefers-reduced-motion: reduce) { .strip a { transition: none; } .strip a:hover { transform: none; } }

/* Justified headline needs room; below this width the gaps get too wide. */
@media (max-width: 700px) {
  .lead { text-align: left; }
}

@media (max-width: 640px) {
  .trials { grid-template-columns: 1fr; }
}
