/* ---------- tokens ---------- */
:root {
  --bg: #fcfcfa;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --faint: #e8e8e4;
  --code-bg: #f3f3ef;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --alt: #b45309;
  --alt-soft: #fdf3e2;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --measure: 46rem;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111214;
  --fg: #e6e6e3;
  --muted: #94949a;
  --faint: #26272b;
  --code-bg: #1a1b1e;
  --accent: #5eead4;
  --accent-soft: #15302d;
  --alt: #f59e0b;
  --alt-soft: #2c2313;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1rem; }
main.wrap { padding-top: 2.5rem; padding-bottom: 4rem; min-height: 70vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.3; font-weight: 600; }
h2 { font-size: 1.15rem; margin: 2.75rem 0 1rem; }
h3 { font-size: 1rem; margin: 2rem 0 .75rem; }
h2.section {
  font: 500 .85rem var(--mono);
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: .02em;
  border-bottom: 1px solid var(--faint);
  padding-bottom: .4rem;
}
h2.section::before { content: "## "; color: var(--accent); }
img { max-width: 100%; height: auto; }
hr { border: 0; border-top: 1px solid var(--faint); margin: 2.5rem 0; }
blockquote { margin: 1.5rem 0; padding: .25rem 1rem; border-left: 3px solid var(--faint); color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; display: block; overflow-x: auto; }
th, td { border-bottom: 1px solid var(--faint); padding: .4rem .6rem; text-align: left; }

.page-title { font-size: 1.75rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
.lead { color: var(--muted); margin-top: 0; }
.meta, .muted { color: var(--muted); font-size: .9rem; }
.meta { font-family: var(--mono); font-size: .8rem; margin: 0 0 .5rem; }

/* ---------- header / footer ---------- */
.site-header {
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem;
  align-items: baseline; justify-content: space-between;
  padding-top: 1.75rem;
  font-family: var(--mono); font-size: .9rem;
}
.logo { color: var(--fg); font-weight: 500; }
.logo:hover { text-decoration: none; color: var(--accent); }
.site-header nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: baseline; }
.site-header nav a { color: var(--muted); }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--fg); text-decoration: none; }
.site-header nav a::before { content: "./"; opacity: .6; }
.site-header nav a[aria-current]::before { color: var(--accent); opacity: 1; }
.theme-toggle {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { color: var(--fg); }
.site-footer {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between;
  border-top: 1px solid var(--faint);
  padding-top: 1rem; padding-bottom: 2rem;
  font: .8rem var(--mono); color: var(--muted);
}
.site-footer a { color: var(--muted); }

/* ---------- home ---------- */
.intro { display: grid; grid-template-columns: 9rem 1fr; gap: 1.75rem; align-items: center; margin-bottom: 1.5rem; }
.intro img { width: 9rem; height: 9rem; object-fit: cover; border-radius: 50%; filter: grayscale(15%); }
.intro h1 { font-size: 1.75rem; margin: 0; letter-spacing: -.01em; }
.intro .role { margin: .2rem 0 0; color: var(--muted); }
.intro .tagline { margin: .1rem 0 .75rem; font: .85rem var(--mono); color: var(--accent); }
.social { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font: .85rem var(--mono); }
.social a { display: inline-flex; align-items: center; gap: .35rem; }
.icon { width: 1em; height: 1em; flex: none; }
@media (max-width: 560px) {
  .intro { grid-template-columns: 1fr; gap: 1rem; }
  .intro img { width: 7rem; height: 7rem; }
}

.interests {
  border: 1px solid var(--faint); border-radius: 6px;
  padding: .6rem 1rem; margin: 0 0 1rem;
}
.bio {
  border: 1px solid var(--faint); border-radius: 6px;
  padding: 1.1rem 1.4rem; margin-bottom: 1.75rem;
  text-align: justify; hyphens: auto; -webkit-hyphens: auto;
}
.bio p { margin: 0 0 .9rem; }
.bio p:last-child { margin-bottom: 0; }
@media (max-width: 560px) { .bio { padding: .9rem 1rem; text-align: left; } }
.interests > summary { cursor: pointer; list-style: none; font: .85rem/1.6 var(--mono); display: flex; gap: .6rem; align-items: flex-start; }
.interests .prompt { flex: none; }
.interests > summary::-webkit-details-marker { display: none; }
.interests > summary::after { content: "+"; color: var(--accent); flex: none; margin-left: auto; }
.interests[open] > summary::after { content: "−"; }
.interests .prompt { color: var(--accent); }
.interests .preview { display: flex; flex-wrap: wrap; gap: .35rem; min-width: 0; }
.interests[open] .preview { display: none; }
.interests dl { display: grid; grid-template-columns: 12rem 1fr; gap: .7rem 1rem; margin: .9rem 0 .3rem; }
.interests dt { line-height: 1.9; }
.interests dd { margin: 0; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.chips li { font-size: .8rem; line-height: 1.5; padding: .1rem .55rem; border-radius: 4px; background: var(--c-soft, var(--code-bg)); color: var(--fg); }
.pill {
  display: inline-block; font: 600 .78rem/1.5 var(--mono); white-space: nowrap;
  padding: .05rem .5rem; border-radius: 4px;
  color: var(--c); background: var(--c-soft); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
}
/* area colours (light) */
.c-teal   { --c: #0f766e; --c-soft: #e6f4f1; }
.c-violet { --c: #6d28d9; --c-soft: #f1ecfd; }
.c-rose   { --c: #be123c; --c-soft: #fdecef; }
.c-blue   { --c: #1d4ed8; --c-soft: #e8effd; }
.c-slate  { --c: #475569; --c-soft: #eef1f5; }
.c-amber  { --c: #b45309; --c-soft: #fdf3e2; }
.c-green  { --c: #15803d; --c-soft: #e7f6ec; }
/* area colours (dark) */
:root[data-theme="dark"] .c-teal   { --c: #5eead4; --c-soft: #15302d; }
:root[data-theme="dark"] .c-violet { --c: #c4b5fd; --c-soft: #2a2140; }
:root[data-theme="dark"] .c-rose   { --c: #fda4af; --c-soft: #3a1d24; }
:root[data-theme="dark"] .c-blue   { --c: #93c5fd; --c-soft: #1a2540; }
:root[data-theme="dark"] .c-slate  { --c: #cbd5e1; --c-soft: #242a33; }
:root[data-theme="dark"] .c-amber  { --c: #fcd34d; --c-soft: #2c2313; }
:root[data-theme="dark"] .c-green  { --c: #86efac; --c-soft: #173023; }
@media (max-width: 560px) {
  .interests dl { grid-template-columns: 1fr; gap: .2rem; }
  .interests dd { margin-bottom: .6rem; }
}

/* highlights */
.highlights { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.hl {
  display: flex; flex-direction: column;
  border: 1px solid var(--faint); border-top: 3px solid var(--c); border-radius: 6px;
  padding: .9rem 1.1rem;
}
.hl h3 { margin: 0 0 .4rem; line-height: 1.35; }
.hl-name { display: block; font: 600 1.05rem var(--mono); color: var(--c); }
.hl-tagline { display: block; font-size: .85rem; font-weight: 400; color: var(--muted); }
.hl p { margin: 0 0 .8rem; font-size: .9rem; line-height: 1.55; flex: 1; }
.hl-foot { display: flex; flex-direction: column; gap: .45rem; }
.hl-venues { display: flex; flex-wrap: wrap; gap: .3rem; }
.hl .links { margin-top: 0; }
.hl-more { margin: .6rem 0 0; text-align: right; font: .8rem var(--mono); }
@media (max-width: 640px) { .highlights { grid-template-columns: 1fr; } }

.callout {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: .9rem 1.1rem; margin: 1.75rem 0;
  border-radius: 0 6px 6px 0; font-size: .95rem;
}
.callout p { margin: 0; }
.callout + .callout { margin-top: -0.75rem; }
.callout-alt { background: var(--alt-soft); border-left-color: var(--alt); }
.callout-alt a { color: var(--alt); }
details.callout > summary { cursor: pointer; list-style: none; }
details.callout > summary::-webkit-details-marker { display: none; }
details.callout > summary::after { content: " +"; font: 500 .9rem var(--mono); color: var(--accent); }
details.callout-alt > summary::after { color: var(--alt); }
details.callout[open] > summary::after { content: " −"; }
details.callout[open] > p { margin-top: .4rem; }

/* dated lists: news, posts, talks */
.dated { list-style: none; padding: 0; margin: 0; }
.dated > li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; padding: .35rem 0; }
.dated time { font: .8rem/1.65rem var(--mono); color: var(--muted); }
.dated p { margin: 0; }
details.news-year { margin: .35rem 0 0 1.2rem; }
details.news-year > summary { cursor: pointer; list-style: none; font: 500 .8rem var(--mono); color: var(--muted); padding: .2rem 0; }
details.news-year > summary::-webkit-details-marker { display: none; }
details.news-year > summary::before { content: "+ "; color: var(--accent); }
details.news-year[open] > summary::before { content: "− "; }
details.news-year > summary .count { opacity: .7; font-weight: 400; }
.news-img { display: block; max-width: 14rem; max-height: 5rem; width: auto; margin-top: .5rem; }
.dated .tags { margin-top: .2rem; }
details.more > summary {
  cursor: pointer; list-style: none;
  font: .8rem var(--mono); color: var(--muted); margin-top: .5rem;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "+ "; }
details.more[open] > summary::before { content: "− "; }
@media (max-width: 560px) {
  .dated > li { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- tags ---------- */
.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .3rem .6rem; font: .75rem var(--mono); }
.tags a, .tag-filter button { color: var(--muted); }
.tags a:hover { color: var(--accent); text-decoration: none; }
.tag-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.5rem; }
.tag-filter button {
  font: .75rem var(--mono); background: none; cursor: pointer;
  border: 1px solid var(--faint); border-radius: 999px; padding: .15rem .6rem;
}
.tag-filter button:hover { border-color: var(--muted); color: var(--fg); }
.tag-filter button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- publications ---------- */
.pubs { list-style: none; padding: 0; margin: 0; }
.pub { padding: .7rem 0; border-bottom: 1px dashed var(--faint); }
.pub:last-child { border-bottom: 0; }
.pub > span { display: block; }
.pub-title { font-weight: 600; }
.pub-authors, .pub-venue { font-size: .92rem; color: var(--muted); }
.pub-authors .me { color: var(--fg); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.badge {
  font: .7rem var(--mono); color: var(--accent);
  border: 1px solid currentColor; border-radius: 3px; padding: 0 .3rem; margin-left: .2rem;
  vertical-align: 1px;
}
.pub > .links, .links { display: flex; flex-wrap: wrap; gap: .2rem .9rem; margin-top: .25rem; font: .8rem var(--mono); }
.links a::before, .links button::before { content: "["; color: var(--muted); }
.links a::after, .links button::after { content: "]"; color: var(--muted); }
.links button { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.pub pre.bibtex { margin: .6rem 0 0; font-size: .75rem; }
.year-group { margin-top: .5rem; }
.year-group > summary {
  cursor: pointer; list-style: none; padding: .35rem 0;
  font: 500 .9rem var(--mono); color: var(--fg);
}
.year-group > summary::-webkit-details-marker { display: none; }
.year-group > summary::before { content: "+ "; color: var(--accent); }
.year-group[open] > summary::before { content: "− "; }
.year-group > summary .count { color: var(--muted); font-weight: 400; font-size: .8rem; }
.year-group > .pubs { padding-left: 1.2rem; }
}

/* ---------- code projects / cv ---------- */
.projects { list-style: none; padding: 0; margin: 0; }
.projects li { padding: .5rem 0; }
.projects .name { font: 500 .95rem var(--mono); }
.projects .desc { margin: .1rem 0 0; }
.projects .paper { font: .75rem var(--mono); color: var(--muted); }
.cv-list { list-style: none; padding: 0; margin: 0; }
.cv-list li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: .4rem 0; }
.cv-list .when { font: .8rem/1.65rem var(--mono); color: var(--muted); }
.cv-list p { margin: 0; }
.cv-list .sub { color: var(--muted); font-size: .92rem; }
@media (max-width: 560px) { .cv-list li { grid-template-columns: 1fr; gap: 0; } }

/* ---------- posts ---------- */
.post header { margin-bottom: 2rem; }
.post h2 { font-size: 1.3rem; }
.post h3 { font-size: 1.1rem; }
.post-nav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--faint); font-size: .9rem; }
mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; }

/* ---------- code ---------- */
code, pre { font-family: var(--mono); font-size: .85em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 1rem; border-radius: 6px; overflow-x: auto; line-height: 1.5; }
.highlight { margin: 1.25rem 0; }
.highlight pre { margin: 0; }
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: var(--muted); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kc, .highlight .kr, .highlight .ow { color: #a626a4; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sd { color: #50a14f; }
.highlight .m, .highlight .mi, .highlight .mf { color: #b76b01; }
.highlight .nf, .highlight .fm { color: #4078f2; }
.highlight .nc, .highlight .nn { color: #c18401; }
.highlight .nb, .highlight .bp { color: #0184bc; }
:root[data-theme="dark"] .highlight .k, :root[data-theme="dark"] .highlight .kd, :root[data-theme="dark"] .highlight .kn, :root[data-theme="dark"] .highlight .ow { color: #c678dd; }
:root[data-theme="dark"] .highlight .s, :root[data-theme="dark"] .highlight .s1, :root[data-theme="dark"] .highlight .s2 { color: #98c379; }
:root[data-theme="dark"] .highlight .nf { color: #61afef; }

/* ---------- coloured publication tags ---------- */
.tag-filter button[class*="c-"] { color: var(--c); }
.tag-filter button[class*="c-"][aria-pressed="true"] { color: var(--c); background: var(--c-soft); border-color: var(--c); }
.pub > .pub-tags { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.pub-tags span {
  font: 500 .65rem/1.4 var(--mono); padding: 0 .35rem; border-radius: 3px;
  color: var(--c); background: var(--c-soft);
}
