:root {
  color-scheme: light;
  --bg: #fafaf9;
  --text: #1c1917;
  --muted: #5f5b57;
  --subtle: #726e6a;
  --line: #e7e5e4;
  --soft: #f5f5f4;
  --button: #e7e5e4;
  --button-hover: #d6d3d1;
  --link: #1d4ed8;

  /* Liquid glass */
  --glass-surface: rgba(255, 255, 255, 0.28);
  --glass-edge: rgba(255, 255, 255, 0.6);
  --glass-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.22));
  --glass-cursor-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
  --glass-rim: inset 0 1px 0 rgba(255, 255, 255, 0.85), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  --glass-glow: 0 6px 22px rgba(28, 25, 23, 0.1);
}

:root.dark {
  color-scheme: dark;
  --bg: #0c0a09;
  --text: #f5f5f4;
  --muted: #a8a29e;
  --subtle: #78716c;
  --line: #44403c;
  --soft: #292524;
  --button: #44403c;
  --button-hover: #57534e;
  --link: #60a5fa;

  /* Liquid glass */
  --glass-surface: rgba(28, 20, 18, 0.22);
  --glass-edge: rgba(255, 255, 255, 0.1);
  --glass-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  --glass-cursor-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  --glass-rim: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  --glass-glow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 160ms ease;
}

a:hover {
  color: var(--link);
  text-decoration: underline;
}

button {
  font: inherit;
}

.theme-toggle {
  align-items: center;
  background: var(--button);
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  height: 36px;
  justify-content: center;
  padding: 0;
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
  transition: background 160ms ease, color 160ms ease;
  width: 36px;
  z-index: 10;
}

.theme-toggle:hover {
  background: var(--button-hover);
  color: var(--text);
}

.theme-icon {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.moon-icon,
.dark .sun-icon {
  display: none;
}

.dark .moon-icon {
  display: block;
}

.page {
  display: flex;
  flex: 1 0 auto;
  gap: 64px;
  margin: 0 auto;
  max-width: 1024px;
  padding: 48px max(24px, env(safe-area-inset-right)) 48px max(24px, env(safe-area-inset-left));
  width: 100%;
}

.sidebar {
  align-self: flex-start;
  flex: 0 0 240px;
  position: sticky;
  top: 48px;
  /* Darker grey for sidebar text than the main content (light mode) */
  --muted: #45413e;
}

/* In dark mode use a brighter grey so the sidebar stays legible */
.dark .sidebar {
  --muted: #c4beb7;
}

.profile-photo {
  border-radius: 8px;
  height: 128px;
  margin-bottom: 20px;
  object-fit: cover;
  width: 128px;
}

.sidebar h1 {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 4px;
}

.sidebar p,
.sidebar > a {
  color: var(--muted);
  display: block;
  font-size: 14px;
  line-height: 1.55;
  margin: 0 0 2px;
}

.sidebar > a:last-of-type {
  margin-bottom: 16px;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  /* pull the row back into line with the text since the tap targets add padding */
  margin: 14px -7px;
}

.social-links a {
  align-items: center;
  border-radius: 8px;
  color: var(--muted);
  display: inline-flex;
  height: 40px;
  justify-content: center;
  line-height: 1;
  width: 40px;
}

.social-links a:hover {
  background: var(--soft);
  color: var(--text);
  text-decoration: none;
}

/* Forces the icons after it onto a new row */
.social-break {
  flex-basis: 100%;
  height: 0;
}

.social-links iconify-icon {
  font-size: 27px;
}

.social-links .hf-icon {
  height: 26px;
  width: 28px;
}

.sidebar .cv-link {
  align-items: center;
  background: var(--button);
  border-radius: 7px;
  color: var(--text);
  display: inline-flex;
  gap: 8px;
  font-size: 16px;
  margin-bottom: 20px;
  padding: 5px 11px;
  transition: background 160ms ease, color 160ms ease;
  width: fit-content;
}

.cv-link:hover {
  background: var(--button-hover);
  color: var(--text);
  text-decoration: none;
}

.cv-link svg {
  fill: none;
  height: 22px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 22px;
}

/* Native share button: hidden by default; revealed on mobile (see media query)
   only when JS confirms the Web Share API is available (body.can-share) */
.share-btn {
  align-items: center;
  background: var(--button);
  border: 0;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  display: none;
  gap: 8px;
  font-size: 16px;
  margin-bottom: 20px;
  padding: 5px 11px;
  transition: background 160ms ease, color 160ms ease;
}

.share-btn:hover {
  background: var(--button-hover);
}

.share-btn svg {
  fill: none;
  height: 19px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 19px;
}

.contact-list {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  gap: 8px;
  margin-bottom: 28px;
}

.contact-row {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.contact-row a {
  overflow-wrap: anywhere;
}

.copy-email {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  height: 26px;
  justify-content: center;
  padding: 0;
  transition: background 160ms ease, color 160ms ease;
  width: 26px;
}

.copy-email:hover {
  background: var(--soft);
  color: var(--text);
}

.copy-email svg {
  fill: none;
  height: 17px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 17px;
}

.side-jump {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.side-jump a {
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.side-jump a:hover {
  color: var(--text);
  text-decoration: none;
}

.side-jump a.active {
  color: var(--link);
  font-weight: 600;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
}

section {
  margin-bottom: 40px;
}

h2 {
  border-bottom: 1px solid var(--line);
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 20px;
  padding-bottom: 8px;
}

h3 {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 12px;
}

h4 {
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  margin: 0;
}

p {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

strong {
  color: var(--text);
  font-weight: 600;
}

em {
  color: var(--muted);
}

.justify {
  color: color-mix(in srgb, var(--text), var(--muted) 35%);
  font-size: 16px;
  line-height: 1.65;
  text-align: justify;
}

.content a {
  color: var(--link);
}

.entry {
  margin-bottom: 24px;
}

.entry p {
  line-height: 1.65;
}

/* Card entries: publications, talks, and writing each sit in their own
   rectangle. Scoped by section so the plain lists elsewhere stay flat. */
#publications .entry,
#talks .entry,
#writing .software-list > p {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

/* The writing list is already a grid with its own gap; only the article
   sections need explicit spacing between cards. */
#publications .entry,
#talks .entry {
  margin-bottom: 14px;
}

#publications .entry:last-child,
#talks .entry:last-child {
  margin-bottom: 0;
}

#publications .entry:hover,
#talks .entry:hover,
#writing .software-list > p:hover {
  border-color: var(--link);
  transform: translateY(-2px);
}

/* Titles sit tighter inside a card than they do in open text. */
#publications .entry > h3,
#talks .entry > h3 {
  margin-bottom: 8px;
}

/* Breathing room between the citation and the DOI / project-page row. */
#publications .entry > p {
  margin-bottom: 6px;
}

.entry > a,
.software-list a {
  color: var(--link);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.doi-label {
  color: var(--muted);
  font-size: 14px;
}

/* Publication venue (bioRxiv / journal name), bold italic */
.venue {
  color: var(--text);
  font-style: italic;
  font-weight: 600;
}

.soon-tag {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-left: 6px;
  padding: 2px 8px;
  text-transform: uppercase;
  vertical-align: middle;
}

.page-link {
  color: var(--link);
  font-size: 14px;
}

.page-link .software-globe {
  margin-right: 4px;
}

.software-list {
  display: grid;
  gap: 12px;
}

.software-list p {
  line-height: 1.6;
}

.software-globe {
  color: #2563eb;
  font-size: 15px;
  margin-right: 6px;
  vertical-align: -2px;
}

.timeline {
  display: grid;
  gap: 16px;
  margin: 0 0 28px;
}

.timeline article {
  display: flex;
  gap: 20px;
}

.timeline time {
  color: var(--subtle);
  flex: 0 0 112px;
  font-size: 14px;
  padding-top: 2px;
}

.timeline p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 2px;
}

.note {
  color: var(--subtle);
  font-size: 14px;
  margin: -14px 0 28px 132px;
}

.compact-list,
.detail-list {
  color: var(--muted);
  display: grid;
  font-size: 15px;
  gap: 12px;
  line-height: 1.6;
  list-style: none;
  margin: 0;
  padding: 0;
}

.compact-list li,
.detail-list li {
  padding-left: 18px;
  position: relative;
}

.compact-list li::before,
.detail-list li::before {
  color: var(--subtle);
  content: "•";
  left: 0;
  position: absolute;
}

.detail-list span,
.entry .tag {
  color: var(--subtle);
  font-size: 13px;
}

.detail-list p {
  font-size: 14px;
  margin-top: 2px;
}

.tag {
  background: var(--soft);
  border-radius: 4px;
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
}

/* Top-tab navigation + content panels */
.tabs {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  margin-bottom: 32px;
  padding-top: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.tabs .tab {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  padding-bottom: 12px;
  position: relative;
}

.tabs .tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tabs .tab.active {
  color: var(--text);
  font-weight: 600;
}

.tabs .tab.active::after {
  background: var(--link);
  border-radius: 2px 2px 0 0;
  bottom: -1px;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  right: 0;
}

/* Keep a jumped-to section's heading clear of the sticky tab bar */
section[id] {
  scroll-margin-top: 72px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  animation: tab-fade 200ms ease;
  display: block;
}

@keyframes tab-fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Lead intro paragraph on the About tab */
.lead {
  margin-bottom: 36px;
}

/* Updates grouped by year */
.updates-year {
  margin-bottom: 28px;
}

.updates-year:last-child {
  margin-bottom: 0;
}

.year-label {
  border-bottom: 1px solid var(--line);
  color: var(--subtle);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 0 0 14px;
  padding-bottom: 8px;
}

/* News / updates */
.news-list {
  display: grid;
  gap: 12px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.news-list li {
  display: flex;
  gap: 16px;
}

.news-date {
  color: var(--subtle);
  flex: 0 0 76px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.news-list p {
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}

/* Featured project cards */
.project-cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease;
}

.project-card:hover {
  border-color: var(--link);
  text-decoration: none;
  transform: translateY(-2px);
}

.project-card img {
  background: var(--soft);
  height: 96px;
  object-fit: contain;
  padding: 8px;
  width: 100%;
}

.project-card .card-body {
  padding: 10px 12px 12px;
}

.project-card h3 {
  color: var(--link);
  font-size: 14px;
  margin: 0 0 3px;
}

.project-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* Skills: compact label + inline list */
.skills {
  display: grid;
  gap: 10px;
  margin: 0;
}

.skill-row {
  display: flex;
  gap: 16px;
}

.skill-row dt {
  color: var(--text);
  flex: 0 0 132px;
  font-size: 14px;
  font-weight: 600;
}

.skill-row dd {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

footer {
  border-top: 1px solid var(--line);
}

footer div {
  color: var(--subtle);
  font-size: 12px;
  margin: 0 auto;
  max-width: 1024px;
  padding: 20px 24px max(20px, env(safe-area-inset-bottom));
  text-align: center;
}

/* ============================================================
   LIQUID GLASS: frosted chrome + traveling cursor highlight.
   Restrained: only the interactive surfaces become glass; body
   text stays on the flat background for readability. Uses plain
   backdrop-filter (no SVG displacement) so every browser matches.
   ============================================================ */

/* Frosted sticky tab bar: a rounded glass bar that floats over the content
   as it scrolls under. */
.tabs {
  background: var(--glass-surface);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border: 1px solid var(--glass-edge);
  border-radius: 16px;
  box-shadow: var(--glass-rim), var(--glass-glow);
  padding: 14px 20px 2px;
  top: 12px;
}

/* Glass chips: theme toggle + CV / share buttons. */
.theme-toggle,
.sidebar .cv-link,
.share-btn {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(12px) saturate(1.6);
  backdrop-filter: blur(12px) saturate(1.6);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-rim), var(--glass-glow);
}

.theme-toggle:hover,
.cv-link:hover,
.share-btn:hover {
  background: var(--glass-fill);
  box-shadow: var(--glass-rim), 0 8px 26px rgba(28, 25, 23, 0.16);
}

.dark .theme-toggle:hover,
.dark .cv-link:hover,
.dark .share-btn:hover {
  box-shadow: var(--glass-rim), 0 8px 28px rgba(0, 0, 0, 0.5);
}

/* Publication, talk, and writing rectangles as glass panels. */
#publications .entry,
#talks .entry,
#writing .software-list > p {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  backdrop-filter: blur(10px) saturate(1.4);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-rim), var(--glass-glow);
}

#publications .entry:hover,
#talks .entry:hover,
#writing .software-list > p:hover {
  border-color: var(--glass-edge);
  box-shadow: var(--glass-rim), 0 12px 30px rgba(28, 25, 23, 0.16);
  transform: translateY(-3px);
}

.dark #publications .entry:hover,
.dark #talks .entry:hover,
.dark #writing .software-list > p:hover {
  box-shadow: var(--glass-rim), 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* Featured project cards as glass panels. */
.project-card {
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(10px) saturate(1.4);
  backdrop-filter: blur(10px) saturate(1.4);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-rim), var(--glass-glow);
}

.project-card:hover {
  border-color: var(--glass-edge);
  box-shadow: var(--glass-rim), 0 12px 30px rgba(28, 25, 23, 0.16);
  transform: translateY(-3px);
}

.dark .project-card:hover {
  box-shadow: var(--glass-rim), 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* The single glass pill that glides under whatever the cursor points at.
   Created by script.js. Sits above content (z:6) but below the theme
   toggle (z:10); a light fill + saturate keeps underlying text legible. */
.glass-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 6;
  width: 0;
  height: 0;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  background: var(--glass-cursor-fill);
  box-shadow: var(--glass-rim), var(--glass-glow);
  -webkit-backdrop-filter: saturate(1.7) brightness(1.04);
  backdrop-filter: saturate(1.7) brightness(1.04);
  transition:
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.22s ease;
  will-change: transform, width, height;
}

/* No traveling highlight for people who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .glass-cursor {
    display: none;
  }
}

@media (max-width: 860px) {
  .page {
    display: block;
    padding: 48px max(24px, env(safe-area-inset-right)) 32px max(24px, env(safe-area-inset-left));
  }

  /* Center the whole profile block on mobile */
  .sidebar {
    margin-bottom: 40px;
    position: static;
    text-align: center;
  }

  .sidebar .profile-photo {
    display: block;
    margin-left: auto;
    margin-right: auto;
  }

  .social-links {
    justify-content: center;
  }

  .sidebar .cv-link {
    display: flex;
    margin-left: auto;
    margin-right: auto;
  }

  /* Reveal the native share button on mobile when supported */
  body.can-share .share-btn {
    display: inline-flex;
  }

  .contact-row {
    justify-content: center;
  }

  /* Hide the section jump-list on mobile/tablet: the sticky top tabs already
     provide navigation there */
  .side-jump {
    display: none;
  }

  /* On mobile the toggle scrolls away with the page instead of staying pinned:
     absolute-position it at the top-right of the document. Drop the blur too,
     since there's no fixed layer to keep frosted. */
  .theme-toggle {
    position: absolute;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: var(--soft);
  }

  /* Let tabs scroll horizontally instead of wrapping on small screens */
  .tabs {
    flex-wrap: nowrap;
    gap: 20px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs .tab {
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .page {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }

  /* Five tabs overflow a phone at the desktop gap. Keep the type at full size
     and buy the room back from the gap and bar padding instead, so the whole
     row fits from ~390px up; narrower screens still scroll. */
  .tabs {
    gap: 11px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .project-cards {
    grid-template-columns: 1fr;
  }

  .news-list li {
    flex-direction: column;
    gap: 2px;
  }

  /* In a column, flex-basis sets height, so reset it or the date is 76px tall */
  .news-date {
    flex-basis: auto;
  }

  .skill-row {
    flex-direction: column;
    gap: 2px;
  }

  .skill-row dt {
    flex-basis: auto;
  }

  .timeline article {
    display: block;
  }

  .timeline time {
    display: block;
    margin-bottom: 4px;
  }

  .note {
    margin-left: 0;
  }

  /* Justified text looks gappy on narrow screens */
  .justify {
    text-align: left;
  }
}
