/* Layout: fixed identity column on the left, research list on the right; stacks on phones.
   Thumbnails are diagrams drawn with currentColor so they follow the theme. */
:root {
  --paper: #f6f7f5;        /* cool paper, faint green-grey bias */
  --surface: #ffffff;
  --ink: #1b2026;
  --ink-soft: #5c6670;
  --rule: #dde1df;
  --accent: #24497c;       /* deep ink blue */
  --accent-wash: #e8edf4;
  --hover: #eef1ef;
  --cluster-b: #b47d2c;   /* ochre, second series in figures */
  --cluster-c: #4c8063;   /* sage, third series */

  --font-display: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --sidebar: 260px;
  --gap: clamp(40px, 6vw, 80px);
  --maxw: 1100px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14181c; --surface: #1b2025; --ink: #e6e9ec; --ink-soft: #9aa4ae;
    --rule: #2c333a; --accent: #8fb3e6; --accent-wash: #1f2b3a; --hover: #1b2126; --cluster-b: #e0b06a; --cluster-c: #8cc4a2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14181c; --surface: #1b2025; --ink: #e6e9ec; --ink-soft: #9aa4ae;
  --rule: #2c333a; --accent: #8fb3e6; --accent-wash: #1f2b3a; --hover: #1b2126; --cluster-b: #e0b06a; --cluster-c: #8cc4a2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16.5px/1.65 var(--font-body);
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-block: clamp(40px, 7vw, 88px) 64px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: var(--gap);
}

/* ---------- Identity column ---------- */
.profile {
  position: sticky;
  top: 48px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-right: calc(var(--gap) / 2);
  border-right: 1px solid var(--rule);
}
.avatar {
  width: 140px; height: 140px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-wash);
  color: var(--accent);
  display: grid; place-items: center;
  font: 500 44px/1 var(--font-display);
  letter-spacing: 0.02em;
}
.name {
  margin: 4px 0 0;
  font: 500 32px/1.15 var(--font-display);
  letter-spacing: -0.01em;
}
.role { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.5; }
.blurb { margin: 0; font-size: 15.5px; }
.contact {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0; padding: 0; list-style: none;
  font-size: 14.5px;
}
.contact .email { font-family: var(--font-mono); font-size: 13.5px; color: var(--ink); user-select: all; }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; }

.nav {
  display: flex; gap: 4px;
  margin-top: 8px; padding-top: 18px;
  border-top: 1px solid var(--rule);
}
.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 6px 10px; border-radius: 6px;
}
.nav a:first-child { margin-left: -10px; }
.nav a:hover { color: var(--ink); background: var(--hover); }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- Main column ---------- */
main { min-width: 0; display: flex; flex-direction: column; gap: 64px; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-title {
  margin: 0 0 12px;
  font: 500 25px/1.2 var(--font-display);
  display: flex; align-items: baseline; gap: 12px;
}
.section-title .count {
  font: 400 13px/1 var(--font-mono); color: var(--ink-soft);
}
.section-title::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
  transform: translateY(-6px);
}

/* Paper row */
.paper {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 24px;
  padding: 18px;
  margin: 0 -18px;
  border-radius: 10px;
  transition: background-color .2s ease;
}
.paper:hover { background: var(--hover); }
.thumb {
  margin: 0;
  width: 200px; max-width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--accent);
  overflow: hidden;
  display: grid; place-items: center;
}
.thumb svg, .thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.thumb .muted { color: var(--ink-soft); }
.thumb.placeholder {
  border-style: dashed;
  background: var(--hover);
  color: var(--ink-soft);
  font: 400 11.5px/1 var(--font-mono);
  letter-spacing: 0.08em; text-transform: uppercase;
}
/* Paper figures drawn inline with theme tokens */
.fig svg { width: 100%; height: 100%; }
.fig .lens { fill: var(--accent); fill-opacity: .06; }
.fig .alt line { stroke: var(--ink-soft); stroke-opacity: .35; stroke-width: 3; stroke-linecap: round; }
.fig .cut { stroke: var(--ink); stroke-width: 5; stroke-linecap: round; }
.fig .ca circle { fill: var(--accent); }
.fig .cb circle { fill: var(--cluster-b); }
.fig .sa { stop-color: var(--accent); }
.fig .sb { stop-color: var(--cluster-b); }
.fig .amb .dot { fill: url(#cert-split); }
.fig .amb .ring { fill: none; stroke: var(--ink); stroke-opacity: .55; stroke-width: 2.5; stroke-dasharray: 5 6; }
.paper.no-thumb { grid-template-columns: minmax(0, 1fr); }
.thumb.wide { aspect-ratio: 2 / 1; }
.lightbox .fig.wide { aspect-ratio: 2 / 1; }
.thumb.fig { cursor: zoom-in; transition: border-color .2s ease; }
.thumb.fig:hover { border-color: var(--ink-soft); }
.lightbox {
  border: 1px solid var(--rule); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  padding: 0; width: min(92vw, 960px); max-width: 92vw;
}
.lightbox::backdrop { background: rgb(10 14 18 / .55); }
.lightbox .fig { display: block; aspect-ratio: 4 / 3; cursor: zoom-out; }
.lightbox .fig svg { display: block; width: 100%; height: 100%; }
.abstract sub, .abstract sup { font-size: 0.72em; }
.paper-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.paper-title {
  margin: 0;
  font: 500 19.5px/1.35 var(--font-display);
  text-wrap: balance;
}
.paper-title a { color: var(--ink); text-decoration: none; }
.paper-title a:hover { color: var(--accent); }
.authors { margin: 0; font-size: 14.5px; color: var(--ink-soft); }
.authors .me { color: var(--ink); font-weight: 500; }
.keywords {
  margin: 2px 0 0;
  font-size: 13.5px; line-height: 1.5;
  color: var(--ink-soft);
}
.keywords span[aria-hidden] { color: var(--rule); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 6px; }
.status {
  font: 500 11.5px/1 var(--font-mono);
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-wash);
  padding: 5px 8px; border-radius: 4px;
}
.status.wip { color: var(--ink-soft); background: var(--hover); }
.meta a, .abs-toggle {
  font: 500 13px/1 var(--font-body);
  color: var(--accent); text-decoration: none;
}
.meta a:hover { text-decoration: underline; }
.abs-toggle {
  border: 0; background: none; padding: 4px 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.abs-toggle .chev { display: inline-block; transition: transform .25s ease; }
.abs-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.abstract {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease;
}
.abstract > div { overflow: hidden; }
.abstract p {
  margin: 10px 0 2px; max-width: 66ch;
  font-size: 15px; color: var(--ink);
  border-left: 2px solid var(--rule); padding-left: 14px;
}
.paper.open .abstract { grid-template-rows: 1fr; }

/* ---------- CV page ---------- */
.cv-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
.button {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 14px/1 var(--font-body);
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--accent); border-radius: 6px;
  padding: 9px 14px;
}
.button:hover { background: var(--accent-wash); }
.cv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.cv-item { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 20px; }
.cv-when { font: 400 13.5px/1.65 var(--font-mono); color: var(--ink-soft); font-variant-numeric: tabular-nums; padding-top: 1px; }
.cv-what { min-width: 0; }
.cv-what strong { font-weight: 500; }
.cv-what .sub { display: block; color: var(--ink-soft); font-size: 14.5px; }

footer {
  margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--rule);
  font-size: 13px; color: var(--ink-soft);
}

/* ---------- Phones / narrow ---------- */
@media (max-width: 820px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    gap: 48px;
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
  }
  .profile { position: static; border-right: 0; padding-right: 0; }
  .avatar { width: 104px; height: 104px; font-size: 34px; }
}
@media (max-width: 520px) {
  .paper { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .thumb { width: 100%; }
  .cv-item { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
