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

:root {
  --bg: #FCFCF9;
  --bg2: #F4F4EE;
  --bg3: #EBEBE3;
  --border: #E2E2D8;
  --border-strong: #CFCFC2;
  --ink: #0D0D0B;
  --ink2: #3A3A35;
  --ink3: #8A8A82;
  --ink4: #B8B8AE;
  --accent: #1565f5;
  --accent-light: #E8EFFE;
  --accent2: #E8F5F0;
  --accent2-ink: #0D6E4F;
  --warm: #FFF1E5;
  --warm-ink: #A8531B;
  --navy: #0A1628;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --rail: 240px;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
}

/* Side rail */
.rail {
  position: fixed;
  top: 0; left: 0;
  width: var(--rail);
  height: 100vh;
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  z-index: 100;
  /* The contact stack sits under the logos. On a short desktop the rail
     would otherwise clip the last links; scroll the rail instead. */
  overflow-y: auto;
}

.rail-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.rail-mark {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.18;
}
.rail-mark span { color: var(--accent); display: block; font-weight: 600; }
.rail-status {
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink3);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.rail-status .dot {
  width: 6px; height: 6px;
  background: #2BA66E;
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% {opacity:1;} 50% {opacity:.3;} }

.rail-section {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink4);
  margin-bottom: 0.85rem;
}

.rail-nav { display: flex; flex-direction: column; margin-bottom: 2.25rem; gap: 1px; }

.rail-nav a {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink2);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 3px;
  display: grid;
  grid-template-columns: 28px 1fr 14px;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.005em;
  transition: background 0.15s, color 0.15s;
}
.rail-nav a .num {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink4);
  font-variant-numeric: tabular-nums;
}
.rail-nav a .key {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--ink4);
  background: var(--bg2);
  padding: 2px 5px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}
.rail-nav a:hover { background: var(--bg2); color: var(--ink); }
.rail-nav a:hover .key { opacity: 1; }
.rail-nav a.active { background: var(--ink); color: var(--bg); }
.rail-nav a.active .num { color: color-mix(in srgb, var(--bg) 55%, transparent); }
.rail-nav a.active .key { background: color-mix(in srgb, var(--bg) 12%, transparent); color: color-mix(in srgb, var(--bg) 70%, transparent); opacity: 1; }

.rail-spacer { flex: 1; }

/* Contact links at the foot of the rail. Icon + label on desktop; the
   900px block turns this into an icon row. Hover is a colour change and a
   1px lift. */
.rail-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  margin-top: 2px;
}
.rail-links a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 4px 2px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink2);
  text-decoration: none;
  transition: color 0.15s, transform 0.15s;
}
.rail-links a:hover {
  color: var(--accent);
  transform: translateY(-1px);
}
.rail-links a:focus-visible {
  color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.rail-links svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .rail-links a { transition: color 0.15s; }
  .rail-links a:hover { transform: none; }
}

/* Affiliation logos under the supervisors (home) */
.hero-affil {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  margin-top: 2rem;
}
.hero-affil img {
  height: 71px;
  width: auto;
  max-width: 100%;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.hero-affil img:hover { opacity: 1; }

/* Main canvas */
main {
  margin-left: var(--rail);
  min-height: 100vh;
}

/* Hero */
.hero {
  padding: 4.5rem 4rem 3.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

/* Floating decorative shapes (network / wing / globe / rings / halftone)
   built by graphs.js. */
.float-graph {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  color: var(--accent);
  opacity: 0.65;
  animation: float 16s ease-in-out infinite;
}
.float-graph.subtle    { opacity: 0.45; }
.float-graph.fainter   { opacity: 0.28; }
.float-graph.delay     { animation: float 22s ease-in-out infinite reverse; }
.float-graph > svg     { width: 100%; height: 100%; display: block; overflow: visible; }
.float-graph .stroke   { stroke: currentColor; stroke-width: 0.75; fill: none; vector-effect: non-scaling-stroke; }
.float-graph .dot      { fill: currentColor; stroke: none; }
.float-graph.spin > svg         { animation: slow-rotate 80s linear infinite; transform-origin: center; transform-box: view-box; }
.float-graph.spin-rev > svg     { animation: slow-rotate 120s linear infinite reverse; transform-origin: center; transform-box: view-box; }

/* Network shape: 5-node graph */
.float-graph .edges line        { stroke: currentColor; stroke-width: 1; fill: none; opacity: 0.55; stroke-dasharray: 2 3; }
.float-graph .nodes circle      { fill: currentColor; opacity: 0.85; transform-box: fill-box; transform-origin: center; animation: nodepulse 5s ease-in-out infinite; }
.float-graph .nodes circle.hub  { fill: var(--accent); opacity: 1; }
.float-graph .nodes circle:nth-child(2) { animation-delay: 0.7s; }
.float-graph .nodes circle:nth-child(3) { animation-delay: 1.4s; }
.float-graph .nodes circle:nth-child(4) { animation-delay: 2.1s; }
.float-graph .nodes circle:nth-child(5) { animation-delay: 2.8s; }
@keyframes nodepulse {
  0%, 100% { transform: scale(1);   opacity: 0.85; }
  50%      { transform: scale(1.4); opacity: 1;    }
}

@keyframes float { 0%, 100% { transform: translate(0,0); } 50% { transform: translate(-8px,-22px); } }
@keyframes slow-rotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink2);
  padding: 5px 0;
  margin-bottom: 2rem;
  position: relative;
  z-index: 2;
}
.hero-eyebrow::before {
  content: "";
  width: 26px; height: 1.5px;
  background: var(--accent);
}

.hero-h1 {
  font-size: clamp(56px, 8.4vw, 122px);
  font-weight: 600;
  line-height: 0.94;
  color: var(--ink);
  letter-spacing: -0.045em;
  max-width: 1180px;
  position: relative;
  z-index: 2;
}
.hero-h1 .accent { color: var(--accent); font-style: italic; font-weight: 500; }
.hero-h1 .block { display: block; }
.hero-h1 .period { color: var(--accent); }

.hero-meta-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 3rem;
  margin-top: 3rem;
  padding-top: 2.25rem;
  border-top: 1px solid var(--border);
  align-items: start;
  position: relative;
  z-index: 2;
}

.hero-bio {
  font-size: 15.5px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--ink2);
  max-width: 620px;
}
.hero-bio strong { color: var(--ink); font-weight: 500; }
.hero-bio em { font-style: italic; color: var(--accent); font-weight: 400; }

/* Hero side card (portrait) */
.hero-side {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  min-height: 320px;
  background: var(--navy);
  box-shadow: 0 12px 32px -16px rgba(10,22,40,0.35);
}
.hero-side img.portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(0.18) contrast(1.02);
}
.hero-side .overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 1.1rem 1.25rem;
  background: linear-gradient(to top, rgba(10,22,40,0.85) 0%, rgba(10,22,40,0.65) 60%, rgba(10,22,40,0) 100%);
  color: rgba(255,255,255,0.85);
}
.hero-side .overlay .label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hero-side .overlay .label::before {
  content: "";
  width: 14px; height: 1.5px;
  background: rgba(255,255,255,0.45);
}
.hero-side .overlay strong { display: block; font-weight: 600; font-size: 13.5px; color: #fff; letter-spacing: -0.01em; }
.hero-side .overlay span { font-size: 11.5px; font-weight: 400; color: rgba(255,255,255,0.6); }

/* Orbit decoration sitting beside portrait, animated */
.hero-orbit {
  position: absolute;
  top: 14px; right: 14px;
  width: 64px; height: 64px;
  z-index: 2;
}
.hero-orbit svg { width: 100%; height: 100%; display: block; }
.hero-orbit .orbit-spin   { transform-origin: 32px 32px; animation: spin 22s linear infinite; }
.hero-orbit .orbit-spin-r { transform-origin: 32px 32px; animation: spin 38s linear infinite reverse; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.rail-links svg {
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

.hero-supervisors {
  margin-top: 2rem;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.sup-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink3);
  padding-top: 3px;
  flex-shrink: 0;
  min-width: 90px;
}
.sup-list { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.sup-entry p {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.sup-entry span {
  font-size: 11.5px;
  color: var(--ink3);
  font-weight: 400;
}

/* Page header (sub-pages) */
.page-head {
  padding: 5rem 4rem 3rem;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
/* (page-head decoration now uses .float-graph in HTML) */
.page-head .kicker,
#publications .kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 2;
}
.page-head .kicker::before,
#publications .kicker::before {
  content: "";
  width: 24px; height: 1.5px;
  background: var(--accent);
}
.page-head h1 {
  font-size: clamp(48px, 6vw, 88px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 0.98;
  color: var(--ink);
  max-width: 1100px;
  position: relative;
  z-index: 2;
}
.page-head h1 .accent { color: var(--accent); font-style: italic; font-weight: 500; }

/* Design / photography switch in the Other heading */
.h1-switch { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.28em; }
.h1-opt {
  font: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--ink4);
  transition: color .18s;
}
.h1-opt:hover:not(:disabled):not(.active) { color: var(--ink2); }
.h1-opt.active { color: var(--accent); font-style: italic; font-weight: 500; }
.h1-opt:disabled { cursor: not-allowed; opacity: 0.45; }
.h1-amp { color: var(--ink); }

.sec-pane[hidden] { display: none; }

/* Multi-paragraph lede (page body content) */
.page-head .lede p + p { margin-top: 0.85em; }
/* Wider measure for the multi-paragraph intro on /other */
.page-head .lede-wide { max-width: 900px; }
.page-head .lede {
  font-size: 16px;
  font-weight: 300;
  color: var(--ink2);
  line-height: 1.75;
  max-width: 680px;
  margin-top: 1.75rem;
  position: relative;
  z-index: 2;
}
.page-head .lede a { color: var(--accent); text-decoration: none; border-bottom: 1.5px solid var(--accent); }

/* Section */
.section {
  padding: 4rem 4rem;
  border-bottom: 1px solid var(--border);
}
.section-kicker {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.section-kicker::before {
  content: "";
  width: 20px; height: 1.5px;
  background: var(--ink3);
}
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 2rem;
  flex-wrap: wrap;
}
.section-title {
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.05;
}
.section-title .accent { color: var(--accent); font-style: italic; font-weight: 500; }

.section-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1.5px solid var(--accent);
  padding-bottom: 1px;
}

/* Research interest rows (home preview) */
.research-list { display: flex; flex-direction: column; }
.research-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 1.5rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: padding-left 0.2s, background 0.2s;
  position: relative;
}
.research-row:first-child { border-top: 1px solid var(--border); }
.research-row:hover { padding-left: 1rem; }
.research-row .rr-num {
  font-size: 24px;
  font-weight: 300;
  color: var(--ink4);
  letter-spacing: -0.04em;
  line-height: 1;
}
.research-row h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.25;
}
.research-row p {
  font-size: 13.5px;
  font-weight: 300;
  color: var(--ink2);
  line-height: 1.75;
  max-width: 540px;
}

/* Research detail (research page) */
.research-detail {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 3rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}
.research-detail:last-child { border-bottom: 0; }
.research-detail .rd-num {
  font-size: 56px;
  font-weight: 300;
  color: var(--ink4);
  letter-spacing: -0.04em;
  line-height: 1;
}
.research-detail h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1.15;
  margin-bottom: 0.5rem;
}
.research-detail p {
  font-size: 15px;
  font-weight: 300;
  color: var(--ink2);
  line-height: 1.6;
  max-width: 740px;
  margin-bottom: 0.45rem;
}
.research-detail .rd-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.65rem;
}
.rd-meta .rd-meta-label {
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink2);
  margin-right: 0.2rem;
}
.rd-meta .tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink2);
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 4px 11px;
  border-radius: 3px;
}

/* Themes section sits directly above the publications band, whose rule is the divider. */
.research-threads { border-bottom: 0; }

/* Publications band on /research. The id is the anchor target. */
#publications { position: relative; scroll-margin-top: 1.25rem; }
/* Heading-to-chips gap matches .section-header (1.5rem). The sticky bar's
   padding-top is part of that gap while the bar is in flow, and is the
   inset that remains once the bar sticks, so it is not added again here. */
#publications .pub-band-head { margin-bottom: 0.75rem; }
#publications .pub-band-head .section-title .accent {
  color: inherit;
  font-style: normal;
  font-weight: inherit;
}

/* Hairline between thread 03 and the band. --border is the site's line token.
   Full width of the column, drawn from the left as the band enters view.
   The finished state is the default, so a browser that cannot run the
   timeline, and prefers-reduced-motion, both show the line already drawn. */
#publications .pub-rule {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
  transform-origin: left center;
  transform: scaleX(1);
}
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    #publications {
      view-timeline-name: --pub-band;
      view-timeline-axis: block;
    }
    #publications .pub-rule {
      animation: pub-rule-grow linear both;
      animation-timeline: --pub-band;
      animation-range: entry 0% entry 40%;
    }
    #publications .pub-band-head .kicker,
    #publications .pub-band-head .section-title {
      animation: pub-head-in linear both;
      animation-timeline: --pub-band;
      animation-range: entry 12% entry 55%;
    }
  }
}
@keyframes pub-rule-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes pub-head-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
/* IntersectionObserver fallback (scripts.html) adds these classes only when
   view() is unavailable and the user has not asked for reduced motion. */
#publications.pub-band-pending .pub-rule { transform: scaleX(0); }
#publications.pub-band-pending .pub-band-head .kicker,
#publications.pub-band-pending .pub-band-head .section-title {
  opacity: 0;
  transform: translateY(8px);
}
#publications.pub-band-pending.pub-band-in .pub-rule {
  transform: scaleX(1);
  transition: transform 0.6s ease;
}
#publications.pub-band-pending.pub-band-in .pub-band-head .kicker,
#publications.pub-band-pending.pub-band-in .pub-band-head .section-title {
  opacity: 1;
  transform: none;
  transition: opacity 0.6s ease, transform 0.6s ease;
}
@media (prefers-reduced-motion: reduce) {
  #publications .pub-rule,
  #publications .pub-band-head .kicker,
  #publications .pub-band-head .section-title {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* Publications: year-grouped cards */
.pub-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  align-items: center;
}
/* Sticky only inside the research publications band, so the gallery
   chips on /other keep their place in the page. */
#publications .pub-toolbar-sentinel {
  height: 1px;
  margin-bottom: -1px;
  pointer-events: none;
}
#publications .pub-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  margin-left: -4rem;
  margin-right: -4rem;
  padding: 0.75rem 4rem;
}
#publications .pub-toolbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--border);
  opacity: 0;
}
#publications .pub-toolbar.is-stuck::after { opacity: 1; }
#publications .year-group .yr { top: 4.75rem; z-index: 1; }
.pub-filter {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink2);
  background: transparent;
  border: 1.5px solid var(--border);
  padding: 6px 13px;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: all 0.15s;
  font-family: inherit;
}
.pub-filter:hover { border-color: var(--ink3); color: var(--ink); }
.pub-filter.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.pub-filter .count {
  margin-left: 6px;
  color: var(--ink4);
  font-weight: 400;
}
.pub-filter.active .count { color: rgba(255,255,255,0.5); }
.pub-filter:focus-visible,
.h1-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.year-group {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 2.5rem;
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--border);
}
.year-group:first-child { border-top: 1px solid var(--border); }
.year-group .yr {
  font-size: 52px;
  font-weight: 300;
  color: var(--ink4);
  letter-spacing: -0.04em;
  line-height: 1;
  position: sticky;
  top: 1.5rem;
  align-self: start;
}
.year-group .yr small {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-top: 8px;
}

.pub-list { display: flex; flex-direction: column; gap: 1rem; }

.pub-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
.pub-item:hover { border-color: var(--ink3); transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) {
  .pub-item,
  .pub-item:hover { transform: none; }
}

.pub-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 6px;
  letter-spacing: -0.015em;
}
.pub-title a { color: inherit; text-decoration: none; }
.pub-title a:hover { color: var(--accent); }
.pub-meta {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink3);
  line-height: 1.6;
}
.pub-meta strong { font-weight: 600; color: var(--ink2); }
.pub-venue { font-style: italic; }
.pub-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}
.pub-action {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink2);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 3px;
  transition: all 0.15s;
}
.pub-action:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }

.pub-badge {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 3px;
  white-space: nowrap;
  align-self: start;
  margin-top: 2px;
  height: fit-content;
}
.badge-journal  { background: rgba(21, 101, 245, 0.22);  color: #1565F5; }
.badge-talk     { background: rgba(247, 135, 100, 0.28); color: #C75A2E; }
.badge-poster   { background: rgba(218, 65, 103, 0.22);  color: #DA4167; }
.badge-preprint { background: rgba(44, 165, 141, 0.22);  color: #1D8770; }
.badge-thesis   { background: rgba(111, 146, 131, 0.28); color: #4F7065; }
.badge-award    {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--warm-ink);
  background: var(--warm);
  padding: 2px 7px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Tools strip */
.tools-strip {
  padding: 1.5rem 4rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--bg2);
  flex-wrap: wrap;
}
.tools-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink3);
  font-weight: 600;
}
.tools-list { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tool-tag {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink2);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 3px;
}

/* Teaching */
.teach-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.teach-card {
  background: var(--bg);
  padding: 1.75rem 1.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border-color 0.18s, transform 0.18s;
}
.teach-card:hover { border-color: var(--ink3); transform: translateY(-2px); }
.teach-card .tc-code {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-light);
  display: inline-block;
  padding: 3px 9px;
  border-radius: 2px;
  margin-bottom: 1rem;
}
.teach-card h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--ink);
  line-height: 1.3;
}
.teach-card .tc-meta {
  font-size: 12px;
  color: var(--ink3);
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: 1rem;
}
.teach-card .tc-meta strong { color: var(--ink2); font-weight: 600; }
.teach-card p {
  font-size: 13.5px;
  font-weight: 300;
  color: var(--ink2);
  line-height: 1.75;
}

/* CV. Date column is the publications year-group width, at text size.
   No row or section rules here: entries sit a short gap apart, and the
   shared .section padding separates the sections. The page-head rule stays,
   matching the other pages. */
.cv-section { border-bottom: 0; }
.cv-section .section-title { margin-bottom: 1.35rem; }
.cv-list { display: flex; flex-direction: column; gap: 1rem; }
.cv-entry {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 2.5rem;
  align-items: start;
  padding: 0;
  border: 0;
}
.cv-subhead {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink2);
  margin: 1.35rem 0 0;
}
.cv-list > .cv-subhead:first-child { margin-top: 0; }
.cv-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink3);
  line-height: 1.35;
  padding-top: 1px;
}
.cv-title {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.35;
  letter-spacing: -0.011em;
}
.cv-detail {
  margin-top: 0.12rem;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink3);
  line-height: 1.35;
}
.cv-detail strong { font-weight: 600; color: var(--ink2); }
.cv-title a:not(.cv-tag):not(.pub-action),
.cv-detail a:not(.cv-tag):not(.pub-action) {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1.5px solid var(--accent);
}
.cv-title a:not(.cv-tag):not(.pub-action):focus-visible,
.cv-detail a:not(.cv-tag):not(.pub-action):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.cv-detail .pub-venue { font-style: italic; }
.cv-detail .pub-action {
  display: inline-block;
  margin: 0 0 0 0.4rem;
  vertical-align: middle;
}
/* Award-style pill. Sits beside the entry; the label has no year. */
.cv-tag {
  display: inline-block;
  flex: none;
  margin: 0 0 0 0.5rem;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--warm-ink);
  background: var(--warm);
  padding: 4px 9px;
  border-radius: 3px;
  text-decoration: none;
  vertical-align: middle;
}
a.cv-tag:hover { color: var(--accent); background: var(--accent-light); }
a.cv-tag:focus-visible,
.cv-detail .pub-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* News. Same 140px date column as the CV, at text size. */
.news-list { display: flex; flex-direction: column; }
.news-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 2.5rem;
  align-items: baseline;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border);
}
.news-row:first-child { border-top: 1px solid var(--border); }
.news-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink3);
  line-height: 1.35;
}
.news-text {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.55;
  letter-spacing: -0.011em;
}
.news-text a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1.5px solid var(--accent);
}
.news-text a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.contact-card {
  padding: 2rem 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.contact-card.dark {
  background: var(--navy);
  color: rgba(255,255,255,0.85);
  border-color: var(--navy);
  position: relative;
  overflow: hidden;
}
/* (dark contact card decoration uses .float-graph in HTML) */
.contact-card .cc-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 1rem;
  position: relative;
  z-index: 1;
}
.contact-card.dark .cc-label { color: rgba(255,255,255,0.45); }
.contact-card .cc-val {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 0.85rem;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}
.contact-card.dark .cc-val { color: #fff; }
.contact-card .cc-val a { color: inherit; text-decoration: none; border-bottom: 1.5px solid var(--accent); }
.contact-card.dark .cc-val a { border-bottom-color: rgba(255,255,255,0.4); }
.contact-card p {
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.8;
  color: var(--ink2);
  max-width: 380px;
  position: relative;
  z-index: 1;
}
.contact-card.dark p { color: rgba(255,255,255,0.6); }

/* Footer */
footer {
  padding: 1.75rem 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
footer p {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink3);
}
.footer-links { display: flex; gap: 2rem; }
.footer-links a {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink3);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}
.footer-links a:hover { color: var(--ink); }

/* Keyboard hint */
.kbd-hint {
  position: fixed;
  bottom: 1.25rem;
  right: 1.5rem;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink3);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 3px;
  z-index: 90;
  opacity: 0.65;
  transition: opacity 0.2s;
}
.kbd-hint:hover { opacity: 1; }
.kbd-hint kbd {
  font-family: inherit;
  font-size: 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1px 5px;
  margin: 0 1px;
  font-weight: 600;
  color: var(--ink2);
}

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-1 { animation: fadeUp 0.5s ease both 0.05s; }
.fade-in-2 { animation: fadeUp 0.5s ease both 0.15s; }
.fade-in-3 { animation: fadeUp 0.5s ease both 0.25s; }
.fade-in-4 { animation: fadeUp 0.5s ease both 0.35s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-side, .float-graph, .float-graph.spin > svg, .float-graph.spin-rev > svg, .thread-graph,
  .hero-orbit .orbit-spin, .hero-orbit .orbit-spin-r, .rail-status .dot { animation: none !important; }
  .fade-in-1, .fade-in-2, .fade-in-3, .fade-in-4 { animation: none !important; }
}

/* Gallery (Other) */
.gal-index {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin: 0 0 1.75rem;
  border-top: 1px solid var(--border);
}
@media (min-width: 1180px) {
  .gal-index { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.gal-jump {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0.85rem 1.25rem 0.9rem 0;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.gal-jump-name {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
}
.gal-jump-meta {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink3);
}
.gal-jump:hover .gal-jump-name { color: var(--accent); }
.gal-jump:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gal-section { scroll-margin-top: 1.25rem; }
.gal-section[hidden] { display: none; }
.gal-section + .gal-section { margin-top: 34px; }

.gal-section .section-kicker {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.gal-note {
  font-size: 0.84rem;
  color: var(--ink3);
  margin-bottom: 14px;
  max-width: 62ch;
}
.gal-note a {
  color: var(--ink2);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}
.gal-note a:hover { color: var(--accent); border-color: var(--accent); }
.gal-n {
  font-size: 0.72rem;
  color: var(--ink4);
  font-weight: 400;
  letter-spacing: 0;
}


.gal {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  align-items: start;
}

.gal-item {
  margin: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  transition: border-color .18s;
}
.gal-item:hover { border-color: var(--accent); }

.gal-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: inherit;
}
.gal-open:focus { outline: none; }
.gal-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.gal-item img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}

.gal-item figcaption {
  font-size: 0.76rem;
  /* Plates stay on the cream ground in both themes, so the line under them
     stays dark rather than following --ink3, which is light in dark mode. */
  color: #3A3A35;
  padding: 7px 10px;
  border-top: 1px solid #E2E2D8;
  line-height: 1.45;
}

.empty-state { color: var(--ink3); font-size: 0.9rem; }

/* Lightbox */
.lb {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 8, 0.93);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.lb.on { display: flex; }

.lb-figure {
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lb-img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  display: block;
}

.lb-cap {
  color: rgba(255,255,255,0.78);
  font-size: 0.82rem;
  text-align: center;
  max-width: 60ch;
}

.lb button {
  position: absolute;
  background: none;
  border: 0;
  color: #fff;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity .15s;
  line-height: 1;
}
.lb button:hover { opacity: 1; }
.lb button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  opacity: 1;
}
.lb-close { top: 18px; right: 24px; font-size: 2.3rem; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); font-size: 3.4rem; padding: 0 18px; }
.lb-prev { left: 6px; }
.lb-next { right: 6px; }

.lb-count {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

@media (max-width: 640px) {
  .gal { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .lb-prev, .lb-next { font-size: 2.4rem; padding: 0 8px; }
}

/* Dark mode */
[data-theme="dark"] {
  --bg:            #202020;
  --bg2:           #1A1A1A;
  --bg3:           #2A2A2A;
  --border:        #333333;
  --border-strong: #444444;
  --ink:           #F0F0F0;
  --ink2:          #D4D4D4;
  --ink3:          #999999;
  --ink4:          #666666;
  --accent:        #F3EF16;
  --accent-light:  #2D2A0A;
  --accent2:       #102822;
  --accent2-ink:   #6DD2A8;
  --warm:          #3A2A1A;
  --warm-ink:      #E3B27B;
  --navy:          #0A1628;
}

/* Active rail link → accent pill in dark mode */
[data-theme="dark"] .rail-nav a.active { background: var(--accent); color: #1A1A1A; }
[data-theme="dark"] .rail-nav a.active .num { color: rgba(0,0,0,0.55); }
[data-theme="dark"] .rail-nav a.active .key { background: rgba(0,0,0,0.12); color: rgba(0,0,0,0.7); }

/* Pub-filter active needs accent treatment in dark too */
[data-theme="dark"] .pub-filter.active { background: var(--accent); color: #1A1A1A; border-color: var(--accent); }
[data-theme="dark"] .pub-filter.active .count { color: rgba(0,0,0,0.55); }

/* Pub badges in dark mode: keep the colour, darken the chip bg */
[data-theme="dark"] .badge-journal  { background: rgba(21, 101, 245, 0.20);  color: #5C8EFF; }
[data-theme="dark"] .badge-talk     { background: rgba(247, 135, 100, 0.22); color: #FF9B7A; }
[data-theme="dark"] .badge-poster   { background: rgba(218, 65, 103, 0.22);  color: #FF6A8B; }
[data-theme="dark"] .badge-preprint { background: rgba(44, 165, 141, 0.22);  color: #4FC4A8; }
[data-theme="dark"] .badge-thesis   { background: rgba(111, 146, 131, 0.22); color: #97B5A6; }

/* Award chip */
[data-theme="dark"] .badge-award { background: var(--warm); color: var(--warm-ink); }

/* Hero side card overlay: portrait card stays dark in both modes */
/* Contact dark card stays dark too: no override needed */

/* Logo swap (filled in HTML with .logo-light + .logo-dark images) */
.hero-affil .logo-dark { display: none; }
[data-theme="dark"] .hero-affil .logo-light { display: none; }
[data-theme="dark"] .hero-affil .logo-dark  { display: block; }

/* Theme transition */
body { transition: background-color 0.25s ease, color 0.25s ease; }

/* Neural-net animation (home only): bleeds off the top-right corner */
.nn-graph {
  position: absolute;
  top: -85px;
  right: -100px;
  width: 450px;
  height: 350px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  animation: nn-drift 48s ease-in-out infinite;
  will-change: transform;
}
.nn-graph svg {
  width: 100%; height: 100%;
  display: block;
  overflow: visible;
  animation: nn-wobble 26s ease-in-out infinite;
  transform-origin: center;
}
.nn-graph .edges line { stroke: var(--accent); stroke-width: 0.7; opacity: 0.55; }
.nn-graph .node      { fill: var(--accent); opacity: 0.9; }
.nn-graph .signal    { fill: var(--accent); filter: drop-shadow(0 0 4px var(--accent)); }
@keyframes nn-drift {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-22px, -16px); }
  66%  { transform: translate(18px, 14px); }
  100% { transform: translate(0, 0); }
}
@keyframes nn-wobble {
  0%, 100% { transform: rotate(-2.5deg); }
  50%      { transform: rotate(2.5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .nn-graph, .nn-graph svg { animation: none !important; }
}
@media (max-width: 1100px) { .nn-graph { width: 280px; height: 220px; top: -55px; right: -65px; opacity: 0.22; } }
@media (max-width: 900px)  { .nn-graph { display: none; } }

/* Thread graphics (/research): one live SVG beside each research thread, built
   by assets/js/thread-graphics.js. Same ghost register as .nn-graph above --
   these sit in the page atmosphere, not in its foreground. */
.thread-graph {
  display: none;
  color: var(--accent);   /* everything inside is currentColor, so dark mode is free */
  opacity: 0.28;
  align-self: center;
  pointer-events: none;
  animation: float 20s ease-in-out infinite;
}
/* Negative delays: the three are already out of phase on the very first frame
   rather than drifting in lockstep for the first twenty seconds. */
.research-detail:nth-child(2) .thread-graph { animation-delay: -7s; }
.research-detail:nth-child(3) .thread-graph { animation-delay: -14s; }
.thread-graph svg { width: 100%; height: auto; display: block; overflow: visible; }
/* The matrix is a coarse 6x6 and carries far less detail than the other two,
   so it is drawn smaller and centred rather than stretched to the full column. */
.tg-rsa svg { max-width: 62%; margin: 0 auto; }


/* min-width, not max-width, so the 900px collapse further down still wins
   without any ordering surprises. Below 1200px the row is exactly what it is
   today: the graphic is display:none, so it is never built or animated. The
   text column narrows to make room rather than the graphic waiting for a very
   wide viewport -- 432px of measure at 1200, 536px at 1440. */
@media (min-width: 1200px) {
  .research-detail { grid-template-columns: 100px minmax(0, 1fr) 220px; gap: 2.5rem; }
  .thread-graph { display: block; }
}
@media (min-width: 1440px) {
  .research-detail { grid-template-columns: 140px minmax(0, 1fr) 300px; gap: 3rem; }
}


/* Theme toggle (fixed top-right) */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.75rem;
  z-index: 95;
  width: 44px; height: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg2);
  padding: 0;
  font: inherit;
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}
.theme-toggle:hover { border-color: var(--ink3); }
.theme-toggle .theme-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.25s ease, background 0.25s ease;
}
.theme-toggle.on .theme-knob { transform: translateX(20px); }

/* Responsive */
@media (max-width: 900px) {
  :root { --rail: 100%; }
  .rail {
    position: static;
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
  }
  .rail-spacer, .rail-section { display: none; }
  .rail-top { padding-bottom: 0; border-bottom: 0; margin-bottom: 0.5rem; }
  .rail-nav { flex-direction: row; overflow-x: auto; margin-bottom: 0; gap: 0.4rem; min-width: 0; max-width: 100%; }
  .rail-nav a { grid-template-columns: auto 1fr; padding: 6px 12px; font-size: 12px; white-space: nowrap; }
  .rail-nav a .key { display: none; }
  .rail-links {
    flex-direction: row;
    align-items: center;
    gap: 0.15rem;
    margin-top: 0.75rem;
  }
  .rail-links a {
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
  }
  .rail-links a span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .rail-links svg { width: 16px; height: 16px; }
  main { margin-left: 0; }
  .hero { padding: 2.5rem 1.5rem 2rem; }
  .hero-h1 { font-size: 44px; }
  .hero-meta-row { grid-template-columns: 1fr; gap: 1.5rem; }
  .hero-side { min-height: 260px; }
  .page-head { padding: 2.5rem 1.5rem 2rem; }
  .page-head h1 { font-size: 38px; }
  .section, .tools-strip { padding: 2.5rem 1.5rem; }
  .research-row { grid-template-columns: 60px 1fr; gap: 1rem; }
  .research-row p { grid-column: 1 / -1; max-width: none; }
  .research-detail { grid-template-columns: 1fr; gap: 1rem; }
  .year-group { grid-template-columns: 1fr; gap: 1rem; }
  .year-group .yr { position: static; font-size: 36px; }
  .cv-entry { grid-template-columns: 1fr; gap: 0.15rem; }
  .news-row { grid-template-columns: 1fr; gap: 0.3rem; align-items: start; }
  /* The rail is in normal flow below 900px, so the toolbar can sit at the
     viewport top without sliding under it. The theme toggle is fixed at the
     top-right; the extra end padding keeps the filter chips clear of it. */
  #publications .pub-toolbar {
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 5.5rem;
  }
  .teach-list, .contact-grid { grid-template-columns: 1fr; }
  footer { padding: 1.25rem 1.5rem; flex-direction: column; gap: 0.75rem; text-align: center; }
  .footer-links { justify-content: center; }
  .kbd-hint { display: none; }
}

/* Portfolio plates read better on a light ground even in dark mode */
[data-theme="dark"] .gal-item { background: #F4F4EE; }
