/*
 * Layout and styles adapted from https://yebulabula.github.io (Ye Mao),
 * used with the author's permission.
 * Everything up to the @keyframes rule is the original stylesheet, unmodified.
 * Site-specific additions (write-up pages, lists, tables, code) follow it.
 */

:root {
  --bg: #ffffff;
  --surface: transparent;
  --surface-muted: rgba(26, 115, 232, 0.04);
  --text: #000000;
  --text-soft: #5f6a75;
  --heading: #000000;
  --line: rgba(24, 34, 45, 0.11);
  --line-strong: rgba(24, 34, 45, 0.18);
  --rule: linear-gradient(
    90deg,
    rgba(24, 34, 45, 0.28) 0%,
    rgba(66, 133, 244, 0.12) 48%,
    rgba(24, 34, 45, 0) 100%
  );
  --rule-soft: linear-gradient(
    90deg,
    rgba(24, 34, 45, 0.16) 0%,
    rgba(66, 133, 244, 0.08) 42%,
    rgba(24, 34, 45, 0) 100%
  );
  --rule-full: linear-gradient(
    90deg,
    rgba(24, 34, 45, 0) 0%,
    rgba(66, 133, 244, 0.08) 12%,
    rgba(24, 34, 45, 0.18) 50%,
    rgba(66, 133, 244, 0.08) 88%,
    rgba(24, 34, 45, 0) 100%
  );
  --accent: #4285f4;
  --accent-strong: #1a73e8;
  --accent-soft: rgba(66, 133, 244, 0.1);
  --link: #000000;
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --max-width: 1120px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", sans-serif;
  font-size: 1.03rem;
  line-height: 1.76;
}

main {
  position: relative;
  z-index: 1;
  animation: fade-up 720ms ease both;
}

a {
  color: var(--link);
  text-decoration: none;
  transition:
    color 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}

a:hover {
  color: var(--accent);
}

::selection {
  background: rgba(66, 133, 244, 0.2);
}

img,
video {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--heading);
  font-family: "EB Garamond", serif;
  line-height: 1.12;
  letter-spacing: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 3.4vw, 2.75rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0.45rem;
  font-family: "Source Sans 3", sans-serif;
  font-size: clamp(1.45rem, 2.4vw, 1.9rem);
  line-height: 1.24;
}

h3 {
  margin-bottom: 0.45rem;
  font-family: "Source Sans 3", sans-serif;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.28;
}

p,
ul {
  margin: 0 0 1rem;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 40px), var(--max-width));
  margin: 0 auto;
  padding: 20px 0 56px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 10px;
  padding: 14px 0 18px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--rule-full);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px 28px;
}

.site-nav a {
  position: relative;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 1px;
  background: linear-gradient(
    90deg,
    currentColor 0%,
    rgba(24, 34, 45, 0.16) 72%,
    rgba(24, 34, 45, 0) 100%
  );
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease;
}

.site-nav a:hover {
  color: var(--accent-strong);
}

.site-nav a:hover::after {
  transform: scaleX(1);
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(310px, 0.82fr);
  gap: 28px;
  align-items: stretch;
  padding: 28px 0 20px;
}

.hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--rule-full);
}

.hero-copy,
.hero-aside {
  position: relative;
  z-index: 1;
}

.hero-summary {
  display: grid;
  gap: 10px;
  max-width: 760px;
  margin: 0 0 18px;
  text-align: justify;
}

.hero-eyebrow,
.section-kicker,
.fact-label,
.venue,
.year {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-eyebrow {
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
}

.hero h1 {
  max-width: none;
  margin-bottom: 10px;
  font-size: clamp(2.35rem, 4.2vw, 3.35rem);
  font-weight: 700;
  white-space: nowrap;
}

.name-native {
  display: inline-block;
  margin-left: 0.2em;
  color: inherit;
  font-family: "Noto Serif SC", "EB Garamond", serif;
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.hero-lead {
  margin-bottom: 0;
  color: var(--heading);
  font-size: clamp(1.04rem, 1.55vw, 1.24rem);
  line-height: 1.58;
}

.hero-note {
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.62;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 18px;
  max-width: 620px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
  padding: 0 0 2px;
  border: none;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--accent-strong);
  font-size: 0.89rem;
  font-weight: 600;
}

.button:hover {
  border-bottom-color: transparent;
  background-image: linear-gradient(
    90deg,
    currentColor 0%,
    rgba(24, 34, 45, 0.14) 72%,
    rgba(24, 34, 45, 0) 100%
  );
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 1px;
}

.button-primary {
  color: var(--accent-strong);
  font-weight: 700;
}

.button-primary:hover {
  color: var(--accent);
}

.hero-facts {
  display: grid;
  gap: 10px;
}

.hero-facts-inline {
  grid-template-columns: minmax(240px, 0.78fr) minmax(0, 1.42fr);
  grid-template-areas: "affiliation focus";
  max-width: 760px;
}

.fact-block-affiliation {
  grid-area: affiliation;
}

.fact-block-focus {
  grid-area: focus;
}

.fact-block,
.panel,
.publication-card {
  position: relative;
  border: none;
  border-radius: 0;
  background: var(--surface);
}

.fact-block {
  display: grid;
  gap: 6px;
  padding: 14px 0 0;
}

.fact-label {
  color: var(--accent-strong);
  font-size: 0.67rem;
  font-weight: 700;
}

.fact-block strong {
  color: var(--heading);
  font-size: 0.96rem;
  line-height: 1.42;
}

.hero-facts-inline .fact-block {
  grid-template-columns: 1fr;
  align-items: start;
  row-gap: 8px;
  min-height: 100%;
}

.hero-facts-inline .fact-label {
  white-space: normal;
}

.hero-facts-inline .fact-block strong {
  font-size: 0.92rem;
}

.hero-aside {
  display: grid;
  gap: 10px;
  align-content: center;
  justify-items: center;
}

.portrait-card {
  position: relative;
  overflow: hidden;
  width: min(100%, 292px);
  aspect-ratio: 1;
  padding: 10px;
  border: 1px solid rgba(24, 34, 45, 0.18);
  border-radius: 50%;
  background: transparent;
}

.portrait-card img {
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 50%;
  object-fit: cover;
  object-position: center bottom;
}

.section {
  scroll-margin-top: 5rem;
  padding: 42px 0 18px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-heading {
  margin-bottom: 18px;
}

.section-kicker {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 700;
}

.section-heading h2 {
  font-size: clamp(1.7rem, 2.6vw, 2.15rem);
  font-weight: 700;
}

.about-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.82fr);
  align-items: start;
  gap: 22px;
}

.about-side,
.experience-column {
  display: grid;
  gap: 14px;
}

.panel {
  padding: 18px 0 0;
}

.panel h3 {
  margin-bottom: 10px;
}

.about-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: flex-start;
  padding-top: 8px;
}

.about-panel p + p {
  margin-top: 0;
}

.compact-panel,
.education-panel,
.awards-panel {
  background: transparent;
}

.about-intro,
.about-background {
  margin-bottom: 0;
}

.about-intro {
  color: var(--heading);
  line-height: 1.68;
}

.about-background {
  color: var(--text);
  font-size: 0.97rem;
  line-height: 1.62;
}

.about-intro a,
.about-background a {
  color: var(--accent-strong);
  font-weight: 600;
}

.about-intro a:hover,
.about-background a:hover {
  color: var(--accent);
}

.about-panel p,
.publication-body p,
.plain-list li,
.cv-list span,
.cv-list em,
.stack-list span,
.stack-list em,
.module-list li,
.award-list span,
.award-detail {
  text-wrap: pretty;
}

.chip-list,
.cv-list,
.stack-list,
.plain-list,
.award-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip-list li {
  display: block;
  padding: 0;
  color: var(--text);
  font-weight: 400;
  line-height: 1.5;
}

.chip-list {
  display: grid;
  row-gap: 4px;
}

.plain-list li {
  position: relative;
  padding-left: 16px;
  color: var(--text);
  line-height: 1.5;
}

.plain-list li + li {
  margin-top: 8px;
}

.plain-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  transform: translateY(-50%);
}

.compact-panel {
  padding-top: 8px;
}

.compact-panel h3 {
  margin-bottom: 6px;
  font-size: 1.08rem;
  color: var(--accent-strong);
}

.publication-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.publication-legend {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.4;
}

.publication-card {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  overflow: visible;
}

.publication-card:last-child {
  border-bottom: 1px solid var(--line);
}

.publication-media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 138px;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: #ffffff;
}

.publication-media-wide {
  padding-inline: 10px;
}

.publication-media-narrow {
  padding-inline: 18px;
}

.publication-media img,
.publication-media video {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
  border-radius: 0;
  background: transparent;
}

.publication-image-fill {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.publication-image-narrow {
  transform: scale(0.92);
  transform-origin: center;
}

.publication-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding: 0;
}

.publication-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  order: 3;
}

.venue,
.year {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: 0.66rem;
  font-weight: 700;
}

.venue {
  color: var(--accent-strong);
}

.year {
  color: var(--text-soft);
}

.publication-body h3 {
  order: 1;
  font-family: "Source Sans 3", sans-serif;
  font-size: 1.08rem;
  line-height: 1.32;
  font-weight: 600;
}

.publication-body p {
  order: 2;
  margin: 0;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.58;
}

.publication-body strong {
  color: var(--accent-strong);
}

.pub-links {
  order: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 2px 0 0;
  padding-top: 0;
}

.pub-links a {
  display: inline-flex;
  align-items: center;
  min-height: auto;
  padding: 0 0 2px;
  border-bottom: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 600;
}

.pub-links a:hover {
  background-image: linear-gradient(
    90deg,
    currentColor 0%,
    rgba(24, 34, 45, 0.16) 72%,
    rgba(24, 34, 45, 0) 100%
  );
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 1px;
}

.experience-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  gap: 42px;
  align-items: start;
}

.experience-column {
  gap: 24px;
}

.experience-column .panel {
  padding-top: 0;
}

.experience-column h3,
.awards-panel h3 {
  margin-bottom: 12px;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cv-list {
  display: grid;
  gap: 0;
}

.cv-list > li {
  display: grid;
  gap: 4px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.cv-list > li:last-child {
  border-bottom: 1px solid var(--line);
}

.cv-item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 18px;
  align-items: baseline;
}

.cv-item-head strong,
.service-list strong,
.award-list strong {
  color: var(--heading);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
}

.cv-date,
.award-year {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.cv-detail,
.cv-note,
.service-list span,
.skills-line {
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.5;
}

.cv-note {
  font-style: normal;
}

.skills-list > li {
  padding-bottom: 13px;
}

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

.stack-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 12px;
  background-image: var(--rule-soft);
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 1px;
}

.stack-list li:last-child {
  padding-bottom: 0;
  background-image: none;
}

.stack-list strong,
.bullet-list strong,
.award-list strong {
  color: var(--heading);
  font-size: 0.98rem;
  font-weight: 700;
}

.education-list li {
  gap: 8px;
  padding-bottom: 14px;
}

.education-list strong {
  color: var(--accent-strong);
}

.bullet-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-soft);
}

.bullet-list li + li {
  margin-top: 10px;
}

.bullet-list li::marker {
  color: var(--accent);
}

.module-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 5px 0 0;
  padding-left: 0;
  list-style: none;
  color: var(--text-soft);
  font-size: 0.94rem;
}

.module-list li {
  margin-bottom: 4px;
}

.award-list {
  display: grid;
  gap: 0;
}

.award-list li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 18px;
  align-items: baseline;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.award-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.award-detail {
  display: grid;
  gap: 3px;
}

.award-detail span {
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.5;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 34px;
  padding: 20px 0 30px;
  border-top: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
}

.footer-globe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
}

.footer-separator {
  color: var(--line-strong);
}

@media (max-width: 960px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-aside {
    justify-items: start;
  }

  .about-layout,
  .experience-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .page-shell {
    width: min(calc(100% - 28px), var(--max-width));
    padding-top: 12px;
  }

  .site-header {
    position: static;
    padding: 12px 0 16px;
    backdrop-filter: none;
  }

  .site-nav {
    gap: 12px 20px;
  }

  .hero {
    gap: 18px;
    padding: 20px 0 18px;
  }

  .hero-summary {
    text-align: left;
  }

  .hero h1 {
    font-size: 2.15rem;
    white-space: normal;
  }

  .hero-facts-inline,
  .award-list {
    grid-template-columns: 1fr;
  }

  .hero-facts-inline {
    grid-template-areas:
      "affiliation"
      "focus";
  }

  .publication-card {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 0;
  }

  .publication-media {
    height: 184px;
    padding: 12px;
  }

  .publication-media-narrow {
    padding-inline: 18px;
  }

  .publication-image-narrow {
    transform: scale(0.96);
  }

  .section {
    padding-top: 36px;
  }

  .panel {
    padding-top: 16px;
  }

  .publication-body {
    padding-top: 0;
  }

  .cv-item-head {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .award-list li {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 1rem;
  }

  .hero-note,
  .publication-body p {
    font-size: 0.95rem;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Site-specific additions (not in the original stylesheet)
   ========================================================================== */

/* Card figures: 5px inside the box at every width (the original used 10px, 12px on phones) */
.publication-media {
  padding: 5px;
}

/* Cards open their write-ups */
a.publication-media:hover {
  outline: 1px solid var(--line-strong);
}

.publication-body h3 a {
  color: var(--heading);
}

.publication-body h3 a:hover {
  color: var(--accent-strong);
}

.publication-body .pub-summary {
  color: var(--text);
  font-size: 0.96rem;
}

/* "All projects · GitHub" under a section */
.section-more {
  margin: 16px 0 0;
  font-size: 0.86rem;
  font-weight: 600;
}

.section-more a {
  color: var(--accent-strong);
}

.section-more a:hover {
  color: var(--accent);
}

.section-more-sep {
  margin: 0 8px;
  color: var(--line-strong);
}

/* Compact list of smaller projects under the project cards */
.more-projects {
  padding-top: 28px;
}

.more-projects h3 {
  margin-bottom: 12px;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.more-projects .plain-list li {
  font-size: 0.97rem;
}

.more-projects .plain-list a {
  font-weight: 600;
}

.more-projects .plain-list span {
  color: var(--text-soft);
}

/* Write-up pages for papers and projects */
.article {
  max-width: 780px;
  margin: 0 auto;
  padding: 30px 0 8px;
}

.article-back {
  margin: 0 0 20px;
  font-size: 0.86rem;
  font-weight: 600;
}

.article-back a {
  color: var(--text-soft);
}

.article-back a:hover {
  color: var(--accent-strong);
}

.article h1 {
  margin: 4px 0 14px;
  font-size: clamp(1.9rem, 3.6vw, 2.55rem);
  font-weight: 700;
}

.article-authors {
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 0.98rem;
  line-height: 1.58;
}

.article-authors strong {
  color: var(--accent-strong);
}

.article-venue {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.5;
}

.article .publication-meta {
  margin: 0 0 10px;
}

.article .pub-links {
  margin: 0 0 26px;
}

.article-body {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.article-body h2 {
  margin: 36px 0 12px;
  font-size: 1.4rem;
  font-weight: 700;
}

.article-body h3 {
  margin: 26px 0 8px;
}

.article-body p,
.article-body ul,
.article-body ol {
  margin: 0 0 1rem;
}

.article-body ul,
.article-body ol {
  padding-left: 1.3rem;
}

.article-body li {
  margin-bottom: 0.5rem;
}

.article-body li::marker {
  color: var(--accent);
}

.article-body a {
  color: var(--accent-strong);
  font-weight: 600;
}

.article-body a:hover {
  color: var(--accent);
}

.article-body strong {
  color: var(--heading);
}

.article-body figure {
  margin: 8px 0 28px;
}

.article-body figure img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
}

.article-body figcaption {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.5;
}

.article-body table {
  width: 100%;
  margin: 0 0 1.25rem;
  border-collapse: collapse;
  font-size: 0.95rem;
  line-height: 1.5;
}

.article-body th,
.article-body td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.article-body thead th {
  border-bottom-color: var(--line-strong);
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.article-body code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
}

.article-body pre {
  margin: 0 0 1.25rem;
  padding: 14px 16px;
  overflow-x: auto;
  border-radius: 6px;
  background: #f6f8fb;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.article-body pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.article-body blockquote {
  margin: 0 0 1rem;
  padding-left: 16px;
  border-left: 2px solid var(--accent-soft);
  color: var(--text-soft);
}

/* Phones: name, then the portrait, then the bio; portrait and links centred */
@media (max-width: 700px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "name"
      "portrait"
      "summary"
      "links"
      "facts";
  }

  .hero-copy {
    display: contents;
  }

  .hero-copy > h1 {
    grid-area: name;
    text-align: center;
  }

  .hero-aside {
    grid-area: portrait;
    justify-items: center;
  }

  .portrait-card {
    width: min(100%, 200px);
  }

  .hero-summary {
    grid-area: summary;
    margin-top: 6px;
  }

  .hero-links {
    grid-area: links;
  }

  .hero-facts {
    grid-area: facts;
  }

  .hero-links {
    justify-content: center;
    max-width: none;
  }

  .hero-facts-inline {
    text-align: center;
    justify-items: center;
  }

  /* Section signposts and the back link on paper and project pages; body text stays left-aligned */
  .section-heading,
  .article-back {
    text-align: center;
  }
}

/* Nav: a centred cluster at every width. It keeps its spacing until the items
   would no longer fit, then tightens in two steps rather than spreading apart. */
.site-nav {
  flex-wrap: nowrap;
}

.site-nav a {
  white-space: nowrap;
}

@media (max-width: 560px) {
  .site-nav {
    gap: 14px;
  }

  .site-nav a {
    font-size: 0.78rem;
    letter-spacing: 0.02em;
  }
}

@media (max-width: 400px) {
  .site-nav {
    gap: 9px;
  }

  .site-nav a {
    font-size: 0.68rem;
    letter-spacing: 0;
  }

  .theme-toggle {
    width: 1.25rem;
    height: 1.25rem;
  }
}

@media (max-width: 340px) {
  .site-nav {
    gap: 7px;
  }

  .site-nav a {
    font-size: 0.64rem;
  }
}

/* The rule under the header: a plain line instead of a gradient that fades out at the ends */
.site-header::after {
  background: var(--line-strong);
}

/* Sections sit closer together: 42/18px of padding gave about 115px of empty
   space between one section's last line and the next heading; 28/10px gives
   about 80px, which is what the Experience-to-Awards gap already was. */
.section {
  padding: 28px 0 10px;
}

.hero {
  padding-bottom: 10px;
}

/* Skills: a full-width labelled list under the two experience columns */
.skills-panel {
  margin-top: 32px;
  padding-top: 0;
}

.skills-panel h3 {
  margin-bottom: 12px;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.skills-panel .service-list > li {
  grid-template-columns: 190px minmax(0, 1fr);
  column-gap: 24px;
  align-items: baseline;
}

@media (max-width: 700px) {
  .skills-panel .service-list > li {
    grid-template-columns: 1fr;
    row-gap: 2px;
  }
}

/* Named people and institutions in the bio read as links; credentials stay bold black */
.hero-lead a {
  color: var(--accent-strong);
  font-weight: 600;
}

.hero-lead a:hover {
  color: var(--accent);
}

/* Hero links and the affiliation / research strip, one size up */
.hero-links .button {
  font-size: 0.95rem;
}

.fact-label {
  font-size: 0.73rem;
}

.fact-block strong,
.hero-facts-inline .fact-block strong {
  font-size: 0.98rem;
}

/* Bulleted work descriptions inside experience entries */
.cv-list .bullet-list {
  margin-top: 2px;
  padding-left: 18px;
  font-size: 0.94rem;
  line-height: 1.5;
}

.cv-list .bullet-list li + li {
  margin-top: 4px;
}

/* Links inside experience and award entries read as links */
.cv-item-head strong a {
  color: var(--heading);
}

.cv-item-head strong a:hover {
  color: var(--accent-strong);
}

.cv-detail a,
.cv-note a,
.bullet-list a,
.award-detail a {
  color: var(--accent-strong);
  font-weight: 600;
}

.cv-detail a:hover,
.cv-note a:hover,
.bullet-list a:hover,
.award-detail a:hover {
  color: var(--accent);
}

/* Listing pages: all publications, all projects */
.listing-group {
  margin: 34px 0 10px;
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Author-facing TODO notes: emitted only by `jekyll serve` (see _includes/todo.html) */
.todo-note {
  display: inline-block;
  margin: 4px 0;
  padding: 1px 7px;
  border-radius: 3px;
  background: #fff3cd;
  color: #664d03;
  font-size: 0.8rem;
  line-height: 1.4;
}

@media (max-width: 700px) {
  .article {
    padding-top: 20px;
  }

  .article-body table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* ==========================================================================
   Dark mode
   A script in _layouts/base.html sets data-theme="dark" or "light" on <html>,
   from a saved choice or, failing that, the system setting; the button at the
   end of the nav toggles it. The original stylesheet is built on the :root
   variables, so most of the page switches with them; the rest are the places
   that hard-code white.
   ========================================================================== */
html[data-theme="dark"] {
    --bg: #101214;
    --surface-muted: rgba(138, 180, 248, 0.08);
    --text: #e6e8eb;
    --text-soft: #9aa3ad;
    --heading: #f3f4f6;
    --line: rgba(230, 232, 235, 0.12);
    --line-strong: rgba(230, 232, 235, 0.22);
    --rule: linear-gradient(90deg, rgba(230, 232, 235, 0.28) 0%, rgba(138, 180, 248, 0.14) 48%, rgba(230, 232, 235, 0) 100%);
    --rule-soft: linear-gradient(90deg, rgba(230, 232, 235, 0.16) 0%, rgba(138, 180, 248, 0.1) 42%, rgba(230, 232, 235, 0) 100%);
    --rule-full: linear-gradient(90deg, rgba(230, 232, 235, 0) 0%, rgba(138, 180, 248, 0.1) 12%, rgba(230, 232, 235, 0.22) 50%, rgba(138, 180, 248, 0.1) 88%, rgba(230, 232, 235, 0) 100%);
    --accent: #a8c7fa;
    --accent-strong: #8ab4f8;
    --accent-soft: rgba(138, 180, 248, 0.14);
    --link: #e6e8eb;
    color-scheme: dark;
}

html[data-theme="dark"] .site-header {
  background: rgba(16, 18, 20, 0.92);
}

html[data-theme="dark"] ::selection {
  background: rgba(138, 180, 248, 0.3);
}

/* Figures are drawn on white; keep a light card behind them so they stay legible */
html[data-theme="dark"] .publication-media,
html[data-theme="dark"] .article-body figure img {
  background: #f4f5f7;
}

html[data-theme="dark"] .article-body figure img {
  border-color: var(--line);
}

html[data-theme="dark"] .portrait-card {
  border-color: var(--line-strong);
}

html[data-theme="dark"] .article-body pre {
  background: #181b1f;
}

html[data-theme="dark"] .todo-note {
  background: #4a3a00;
  color: #ffe08a;
}

/* Theme button at the end of the nav: shows the icon for the mode you would switch to */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-left: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--accent-strong);
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

@media (max-width: 400px) {
  .theme-toggle {
    margin-left: 0;
  }
}

/* Portrait: centred in its ring. The original anchored it to the bottom (object-position: center bottom),
   which on real phones let sub-pixel rounding push the photo against the bottom of the ring. */
.portrait-card img {
  object-position: center;
  /* WebKit resolves the original's height: 100% against the ring's outer height, not the padded
     inner box, so the photo came out 178 x 200 on iPhones and was clipped at the bottom. Sizing
     from the width alone gives a square in every engine. */
  height: auto;
  aspect-ratio: 1;
}

/* Small label text one size up: nothing below 12px. Kept last so it wins over the rules above. */
.venue,
.year {
  font-size: 0.75rem;          /* was 0.66rem (10.6px) */
}

.section-kicker,
.hero-eyebrow,
.fact-label {
  font-size: 0.78rem;          /* was 0.72rem (11.5px) */
}

.pub-links a {
  font-size: 0.85rem;          /* was 0.82rem (13.1px) */
}

.article-body figcaption {
  font-size: 0.9rem;           /* was 0.86rem (13.8px) */
}

/* Phones: keep the nav pinned while scrolling, as on desktop (the original made it static below 700px) */
@media (max-width: 700px) {
  .site-header {
    position: sticky;
    top: 0;
    padding: 10px 0 12px;
    backdrop-filter: blur(10px);
  }
}
