/* ==========================================================================
   Ghadi Nehme — personal academic website
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --bg-alt: #f3f1ec;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #3d424d;
  --muted: #6b7280;
  --line: #e5e2da;
  --accent: #a31f34;          /* MIT red */
  --accent-soft: #fbeef0;
  --navy: #13345b;
  --navy-soft: #e9eff7;
  --gold: #a4731c;
  --gold-soft: #fbf3e1;
  --green: #1f6f4a;
  --green-soft: #e6f4ec;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, .05), 0 16px 40px rgba(16, 24, 40, .10);
  --radius: 14px;
  --maxw: 1080px;
  --serif: var(--sans);   /* single typeface site-wide */
  --sans: "Exo", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --bg-alt: #151820;
  --surface: #181b23;
  --ink: #eef0f4;
  --ink-2: #c3c8d2;
  --muted: #8b93a3;
  --line: #2a2f3a;
  --accent: #ff6b7f;
  --accent-soft: #3a1c23;
  --navy: #8fb8ff;
  --navy-soft: #1a2638;
  --gold: #f0bf5a;
  --gold-soft: #332813;
  --green: #6fd3a0;
  --green-soft: #15291f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 40px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  font: 16px/1.65 var(--sans);
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.2; }
p { margin: 0 0 1em; }
ul { margin: 0; padding-left: 1.2em; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding-inline: 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav .wrap { height: 100%; display: flex; align-items: center; gap: 24px; }
.brand { font-size: 1.12rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 4px; margin-left: auto; list-style: none; padding: 0; }
.nav-links a {
  display: block; padding: 6px 11px; border-radius: 8px;
  color: var(--ink-2); font-size: .9rem; font-weight: 500;
}
.nav-links a:hover { background: var(--bg-alt); text-decoration: none; color: var(--ink); }
.nav-links a.active { color: var(--accent); }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); display: grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: grid; margin-left: auto; }
  .nav-links {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px 16px 16px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 12px; }
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; position: relative; overflow: hidden; }

.hero-grid { display: grid; grid-template-columns: 280px 1fr; gap: 56px; align-items: start; position: relative; }
.portrait {
  width: 280px; aspect-ratio: 4 / 5; border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-lg); background: var(--bg-alt); position: relative;
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait .initials {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 4rem; font-weight: 800; color: var(--accent);
  background: linear-gradient(135deg, var(--accent-soft), var(--navy-soft));
}
.hero-side { display: flex; flex-direction: column; gap: 18px; }
.eyebrow { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.hero h1 { font-weight: 800; font-size: clamp(2.4rem, 4.6vw, 3.4rem); letter-spacing: -.035em; margin: 6px 0 8px; }
.hero .role { font-size: 1.1rem; color: var(--ink); margin-bottom: 18px; }
.hero .role a { color: inherit; border-bottom: 1px solid var(--line); }
.hero .role a:hover { border-color: var(--accent); text-decoration: none; }
.tagline { font-size: clamp(1.2rem, 2.1vw, 1.45rem); font-weight: 600; line-height: 1.3; color: var(--ink-2); margin: 0 0 14px; letter-spacing: -.015em; }
.bio p { font-size: 1.04rem; }
.bio .lede { font-size: 1.06rem; }
.more-bio { margin: 2px 0 18px; }
.more-bio summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  font: 600 .88rem var(--sans); color: var(--accent); padding: 4px 0;
}
.more-bio summary::-webkit-details-marker { display: none; }
.more-bio summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .2s; }
.more-bio[open] summary::after { transform: rotate(-135deg) translateY(-1px); }
.more-bio[open] summary { margin-bottom: 10px; }
.more-bio p { font-size: .98rem; }
.bio strong { color: var(--ink); font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: .88rem; font-weight: 500;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.pill:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.pill svg { width: 15px; height: 15px; }
.pill.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.primary:hover { background: var(--accent); border-color: var(--accent); }
.interests { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: .76rem; font-weight: 500; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-alt); color: var(--ink-2); border: 1px solid var(--line);
}
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; font-size: .9rem; }
.side-card h4 { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.side-card .edu-mini { display: grid; gap: 9px; }
.side-card .edu-mini div { line-height: 1.35; }
.side-card .edu-mini b { color: var(--ink); font-weight: 600; }
.side-card .edu-mini span { color: var(--muted); font-size: .84rem; display: block; }
.side-card .edu-mini span.yr { font-size: .76rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 1px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 44px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat b { display: block; font-size: 1.8rem; font-weight: 800; color: var(--ink); line-height: 1.1; letter-spacing: -.02em; }
.stat span { font-size: .84rem; color: var(--muted); }

@media (max-width: 860px) {
  .hero { padding-top: 36px; }
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-side { flex-direction: row; align-items: flex-start; gap: 20px; }
  .portrait { width: 160px; flex: none; }
  .hero-side .side-card { flex: 1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .hero-side { flex-direction: column; }
  .portrait { width: 180px; }
}

/* ---------- Sections ---------- */
section.block { padding: 64px 0; }
section.block.alt { background: var(--bg-alt); border-block: 1px solid var(--line); }
.sec-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.sec-head h2 { font-weight: 800; font-size: 1.85rem; letter-spacing: -.03em; }
.sec-head p { margin: 6px 0 0; color: var(--muted); font-size: .95rem; }
.sec-num { font-family: var(--sans); font-size: .78rem; color: var(--accent); font-weight: 600; letter-spacing: .12em; display: block; margin-bottom: 6px; }

/* ---------- News ---------- */
.news { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.news li {
  display: grid; grid-template-columns: 76px 78px 1fr; gap: 12px; padding: 5px 12px;
  border-radius: 8px; font-size: .94rem; line-height: 1.5; align-items: baseline;
}
.news li:hover { background: var(--surface); }
.news time { font-size: .8rem; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.news .emoji { margin-right: 4px; }
.news li.hidden { display: none; }
.more-btn {
  margin-top: 12px; background: none; border: 1px solid var(--line); color: var(--ink-2);
  padding: 8px 14px; border-radius: 999px; font: 500 .85rem var(--sans); cursor: pointer;
}
.more-btn:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 560px) { .news li { grid-template-columns: auto 1fr; gap: 4px 10px; } .news li > div { grid-column: 1 / -1; } }

/* ---------- Publications ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  font: 500 .84rem var(--sans); padding: 6px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.filter:hover { border-color: var(--muted); }
.filter.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pubs { display: grid; gap: 12px; }
.pub {
  display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; transition: box-shadow .2s, border-color .2s;
}
.pub:hover { box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.pub.hidden { display: none; }
.pub .thumb {
  border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid var(--line);
  aspect-ratio: 16 / 10; display: grid; place-items: center; position: relative;
}
.pub .thumb img { width: 100%; height: 100%; object-fit: contain; transition: transform .4s; }
.pub:hover .thumb img { transform: scale(1.03); }
.pub .thumb .venue-badge {
  position: absolute; left: 10px; top: 10px; background: rgba(22, 24, 29, .88); color: #fff; z-index: 1;
  font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: .04em;
}
.pub h3 { font-size: 1.02rem; line-height: 1.35; margin-bottom: 4px; font-weight: 700; }
.pub h3 a { color: var(--ink); }
.pub h3 a:hover { color: var(--accent); }
.authors { font-size: .86rem; margin-bottom: 2px; }
.authors .me { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.authors sup { color: var(--muted); }
.venue { font-size: .86rem; font-style: italic; color: var(--ink); margin-bottom: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.badge { font-size: .74rem; font-weight: 600; padding: 3px 9px; border-radius: 6px; display: inline-flex; gap: 5px; align-items: center; }
.badge.prize { background: var(--gold-soft); color: var(--gold); }
.badge.conf { background: var(--navy-soft); color: var(--navy); }
.badge.review { background: var(--bg-alt); color: var(--muted); border: 1px dashed var(--line); }
.badge.press { background: var(--green-soft); color: var(--green); }
.pub .tldr { font-size: .87rem; line-height: 1.55; margin-bottom: 10px; }
.pub-links { display: flex; flex-wrap: wrap; gap: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: 600 .8rem var(--sans);
  padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); cursor: pointer; transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn.demo { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.demo:hover { filter: brightness(1.08); color: #fff; }
.btn svg { width: 14px; height: 14px; }
@media (max-width: 760px) { .pub { grid-template-columns: 1fr; gap: 12px; } .pub .thumb { max-width: 360px; } }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.project {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s;
}
.project:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.project .thumb { aspect-ratio: 16 / 10; background: var(--bg-alt); overflow: hidden; position: relative; }
.project .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.project:hover .thumb img { transform: scale(1.04); }
.project .thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--navy-soft), var(--accent-soft));
  color: var(--navy);
}
.project .thumb .ph svg { width: 44px; height: 44px; opacity: .75; }
.project .when {
  position: absolute; right: 10px; top: 10px; background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--ink); font-size: .72rem; font-weight: 600; padding: 3px 8px; border-radius: 6px;
}
.project .body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.project h3 { font-size: 1rem; margin-bottom: 4px; line-height: 1.35; }
.project .org { font-size: .8rem; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.project p { font-size: .88rem; margin-bottom: 12px; flex: 1; }
.project .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.project .tags .tag { font-size: .7rem; padding: 2px 8px; }
@media (max-width: 960px) { .projects { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .projects { grid-template-columns: 1fr; } }

/* ---------- Experience timeline ---------- */
.timeline { position: relative; display: grid; gap: 14px; }
.timeline::before { content: ""; position: absolute; left: 29px; top: 12px; bottom: 12px; width: 2px; background: var(--line); }
.job { display: grid; grid-template-columns: 60px 1fr; gap: 18px; position: relative; }
.job .logo {
  width: 60px; height: 60px; border-radius: 16px; background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; z-index: 1; box-shadow: 0 0 0 5px var(--bg), var(--shadow);
}
section.alt .job .logo { box-shadow: 0 0 0 5px var(--bg-alt), var(--shadow); }
.job .logo img { width: 44px; height: 44px; object-fit: contain; }
.job .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; transition: box-shadow .2s, transform .2s; }
.job:hover .card { box-shadow: var(--shadow-lg); transform: translateX(2px); }
.job .top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.job h3 { font-size: 1.02rem; }
.job .org { color: var(--accent); font-weight: 600; font-size: .9rem; }
.job .date { font-size: .8rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.job ul { margin-top: 8px; font-size: .9rem; }
.job li { margin-bottom: 3px; }
@media (max-width: 520px) {
  .job { grid-template-columns: 44px 1fr; gap: 12px; }
  .job .logo { width: 44px; height: 44px; border-radius: 12px; }
  .job .logo img { width: 32px; height: 32px; }
  .timeline::before { left: 21px; }
}

/* ---------- Affiliation logos (hero) ---------- */
.affil { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); }
.affil-label { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.affil-logos { display: flex; flex-wrap: wrap; gap: 8px; }
.affil-logos a {
  width: 40px; height: 40px; border-radius: 10px; background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center; transition: transform .15s, box-shadow .15s;
}
.affil-logos a:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.affil-logos img { width: 28px; height: 28px; object-fit: contain; }

/* ---------- Education ---------- */
.edu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.school { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; position: relative; overflow: hidden; }
.school::after { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 4px; background: var(--c, var(--accent)); }
.school .yrs { font-size: .78rem; color: var(--muted); font-weight: 600; }
.school h3 { font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; margin: 6px 0 2px; }
.school-logo { width: 48px; height: 48px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 5px; margin: 10px 0 4px; }
.edu-extra .school { display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; align-items: center; }
.edu-extra .school .school-logo { grid-row: 1 / span 3; margin: 0; }
.school .deg { color: var(--ink); font-weight: 600; font-size: .92rem; margin-bottom: 10px; }
.school ul { font-size: .86rem; padding-left: 1.1em; }
.edu-extra { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.edu-extra .school { padding: 16px 22px; }
.edu-extra .school h3 { font-size: 1.02rem; }
@media (max-width: 860px) { .edu, .edu-extra { grid-template-columns: 1fr; } }

/* ---------- Awards ---------- */
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.award {
  display: grid; grid-template-columns: 42px 1fr; gap: 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.award .ico { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); }
.award .ico svg { width: 20px; height: 20px; }
.award.major { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.award h3 { font-size: .96rem; line-height: 1.35; }
.award p { font-size: .84rem; margin: 3px 0 0; color: var(--muted); }
.award .yr { font-weight: 700; color: var(--gold); font-size: .78rem; }
@media (max-width: 760px) { .awards { grid-template-columns: 1fr; } }

/* ---------- Teaching / leadership ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mini {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
}
.mini h3 { font-size: .98rem; }
.mini .org { color: var(--accent); font-size: .86rem; font-weight: 600; }
.mini .date { color: var(--muted); font-size: .8rem; font-weight: 600; }
.mini p { font-size: .88rem; margin: 8px 0 0; }
.subhead { font-size: .76rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0 0 12px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

.skills { display: grid; grid-template-columns: 140px 1fr; gap: 10px 20px; font-size: .92rem; }
.skills dt { color: var(--ink); font-weight: 600; }
.skills dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Contact ---------- */
.contact {
  background: var(--ink); color: #d7dae1; border-radius: 22px; padding: 44px;
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 36px; align-items: center;
  position: relative; overflow: hidden;
}
:root[data-theme="dark"] .contact { background: var(--surface); border: 1px solid var(--line); }

.contact h2 { color: #fff; font-weight: 800; font-size: 1.85rem; letter-spacing: -.03em; margin-bottom: 10px; }
.contact p { color: #b9bec9; }
.contact .email { font-size: 1.25rem; font-weight: 700; color: #fff; }
.contact-links { display: grid; gap: 8px; position: relative; }
.contact-links a {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px;
  background: rgba(255, 255, 255, .06); color: #fff; border: 1px solid rgba(255, 255, 255, .1);
  font-weight: 500; font-size: .94rem; transition: background .15s;
}
.contact-links a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.contact-links svg { width: 18px; height: 18px; opacity: .9; }
.contact-links .arrow { margin-left: auto; opacity: .5; }
@media (max-width: 760px) { .contact { grid-template-columns: 1fr; padding: 28px; } }

footer { padding: 36px 0 48px; font-size: .84rem; color: var(--muted); }
footer .wrap { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { transition: none !important; }
}

.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.edu-extra .school > *:not(.school-logo) { grid-column: 2; }
.edu-extra .school .school-logo { grid-column: 1; }

/* ---------- Research showcase ---------- */
.sc-tabs { display: flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.sc-tab { font: 600 .88rem var(--sans); padding: 8px 16px; border-radius: 9px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.sc-tab:hover { color: var(--ink); }
.sc-tab.active { background: var(--ink); color: var(--bg); }
.sc-stage {
  display: grid; grid-template-columns: 1.55fr 1fr; height: 560px;
  border-radius: 20px; overflow: hidden; border: 1px solid #1f3350; color: #c9d6ea;
  background:
    linear-gradient(rgba(143,184,255,.06) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(143,184,255,.06) 1px, transparent 1px) 0 0 / 24px 24px,
    radial-gradient(120% 90% at 30% 20%, #16263d 0%, #0b1422 70%);
  box-shadow: var(--shadow-lg);
}
.sc-stage[hidden] { display: none !important; }
.sc-view { position: relative; min-height: 480px; min-width: 0; }
.sc-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.sc-view canvas:active { cursor: grabbing; }
.sc-hud { position: absolute; left: 16px; right: 16px; bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; pointer-events: none; flex-wrap: wrap; }
.sc-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: rgba(8,14,24,.78); border: 1px solid rgba(143,184,255,.22); font: 600 .78rem var(--sans); color: #e6eefb; font-variant-numeric: tabular-nums; max-width: 100%; }
.sc-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #ff6b7f; animation: scPulse 1.6s ease-in-out infinite; flex: none; will-change: opacity; }
@keyframes scPulse { 50% { opacity: .35; } }
.sc-iou { padding: 6px 12px; border-radius: 999px; background: rgba(111,211,160,.14); border: 1px solid rgba(111,211,160,.35); color: #bff0d6; font: 600 .8rem var(--sans); font-variant-numeric: tabular-nums; }
.sc-iou b { color: #fff; }
.sc-side { overflow: hidden; padding: 22px 22px 18px; border-left: 1px solid rgba(143,184,255,.14); background: rgba(6,11,19,.35); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sc-head .eyebrow { color: #ff8a9a; }
.sc-head p { margin: 6px 0 0; font-size: .9rem; color: #aebcd3; line-height: 1.5; }
.sc-head em { color: #fff; font-style: normal; font-weight: 600; }
.sc-side a { color: #ffb3bd; }
.sc-code { margin: 0; padding: 12px 14px; border-radius: 10px; background: rgba(3,7,13,.6); border: 1px solid rgba(143,184,255,.14); font: 11px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; color: #9fb0c9; white-space: pre; overflow: auto; min-height: 120px; max-height: 210px; }
.sc-code .c-k { color: #8fb8ff; } .sc-code .c-n { color: #6fd3a0; } .sc-code .c-c { color: #5f7394; }
.sc-code .c-new { background: rgba(255,107,127,.16); color: #fff; border-radius: 3px; }
.sc-links { display: flex; gap: 14px; font-size: .84rem; font-weight: 600; margin-top: auto; flex-wrap: wrap; }
.sc-list { margin: 0; padding-left: 1.1em; font-size: .87rem; color: #aebcd3; display: grid; gap: 8px; line-height: 1.5; }
.sc-list b { color: #fff; }
.sc-list code, .vc-policy code { font: 12px ui-monospace, Menlo, monospace; color: #f0bf5a; }
.sc-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.sc-stats div { flex: 1; min-width: 90px; padding: 10px 12px; border-radius: 10px; background: rgba(143,184,255,.07); border: 1px solid rgba(143,184,255,.12); }
.sc-stats b { display: block; font-size: 1.2rem; font-weight: 800; color: #fff; line-height: 1.15; letter-spacing: -.01em; }
.sc-stats span { font-size: .74rem; color: #8ea2c2; }
.cf-view { background: #0b1422; }
.cf-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.cf-timeline { position: absolute; left: 0; right: 0; bottom: 0; height: 12px; display: flex; gap: 3px; padding: 0 3px 4px; z-index: 2; }
.cf-timeline button { all: unset; cursor: pointer; position: relative; height: 4px; margin-top: 4px; border-radius: 2px; background: rgba(143,184,255,.22); overflow: hidden; transition: height .15s, margin .15s; }
.cf-timeline button:hover { height: 8px; margin-top: 0; }
.cf-timeline i { position: absolute; inset: 0; background: #ff6b7f; transform-origin: left; transform: scaleX(0); }
.showcase .failed .sc-view::after { content: "3D preview unavailable"; position: absolute; inset: 0; display: grid; place-items: center; color: #7f93b2; }

/* CADFit steps + chart */
.cf-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: .84rem; }
.cf-steps button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 7px; color: #6f83a3; cursor: pointer; transition: color .25s, background .25s; }
.cf-steps button:hover { color: #c9d6ea; }
.cf-steps button:focus-visible { outline: 2px solid #8fb8ff; }
.cf-steps .ic { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font: 700 .68rem var(--sans); background: rgba(143,184,255,.08); color: #7f93b2; flex: none; }
.cf-steps li.done button { color: #c9d6ea; }
.cf-steps li.done .ic { background: rgba(111,211,160,.16); color: #6fd3a0; }
.cf-steps li.active button { color: #fff; background: rgba(255,107,127,.12); }
.cf-steps li.active .ic { background: #ff6b7f; color: #fff; }
.cf-chart { position: absolute; top: 14px; left: 14px; padding: 8px 10px 4px; border-radius: 10px; background: rgba(6,11,19,.78); border: 1px solid rgba(143,184,255,.18); }
.cf-chart-t { font: 600 .7rem var(--sans); color: #aebcd3; }
.cf-chart .ax { stroke: #3d5a80; stroke-width: 1; }
.cf-chart .curve { fill: none; stroke: #8fb8ff; stroke-width: 1.8; }
.cf-chart .band { fill: rgba(111,211,160,.12); }
.cf-chart .sel { stroke: #6fd3a0; stroke-dasharray: 3 3; }
.cf-chart .lbl { fill: #9fb0c9; font: 600 9px var(--sans); }
.cf-chart .dot { fill: #ff6b7f; stroke: #fff; stroke-width: 1; }

/* LAMP */
.lamp-view { display: flex; flex-direction: column; padding: 18px; gap: 12px; background: radial-gradient(90% 70% at 50% 40%, rgba(255,255,255,.95), rgba(233,239,247,.92)); }
.lamp-img { flex: 1; display: grid; place-items: center; min-height: 0; }
.lamp-img img { width: 100%; max-width: 560px; max-height: 280px; object-fit: contain; mix-blend-mode: multiply; }
.lamp-ctrl { color: #16263d; }
.lamp-readout { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-size: .88rem; font-weight: 600; margin-bottom: 8px; flex-wrap: wrap; }
.lamp-readout b { font-size: .8rem; padding: 3px 10px; border-radius: 999px; }
.lamp-readout b.in { background: #dff5e9; color: #1f6f4a; }
.lamp-readout b.ex { background: #fde3e7; color: #a31f34; }
.lamp-track { position: relative; }
.lamp-zones { display: grid; grid-template-columns: 1fr 1fr 1fr; height: 10px; border-radius: 999px; overflow: hidden; margin: 0 9px; }
.lamp-zones span { font-size: 0; }
.lamp-zones .ex { background: #f3a5b0; } .lamp-zones .in { background: #8fd6ad; }
.lamp-track input { position: absolute; inset: -6px 0 auto 0; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; height: 22px; cursor: pointer; }
.lamp-track input::-webkit-slider-runnable-track { background: transparent; height: 22px; }
.lamp-track input::-moz-range-track { background: transparent; }
.lamp-track input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%; background: #16263d; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.lamp-track input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #16263d; border: 3px solid #fff; }
.lamp-legend { display: flex; justify-content: space-between; font-size: .7rem; color: #5b6b85; margin: 8px 9px 0; }
.lamp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.lamp-chips button { font: 600 .74rem var(--sans); padding: 5px 10px; border-radius: 999px; border: 1px solid #c9d3e2; background: #fff; color: #3d4a60; cursor: pointer; }
.lamp-chips button.active { background: #16263d; border-color: #16263d; color: #fff; }
.lamp-opt-btn { margin-top: 12px; font: 600 .8rem var(--sans); padding: 7px 12px; border-radius: 9px; border: 1px solid #16263d; background: transparent; color: #16263d; cursor: pointer; }
.lamp-opt-btn:hover { background: #16263d; color: #fff; }
.lamp-opt { position: absolute; inset: 0; margin: 0; padding: 22px; background: #fff; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.lamp-opt[hidden] { display: none; }
.lamp-opt img { width: 100%; height: auto; }
.lamp-opt figcaption { font-size: .85rem; color: #3d4a60; text-align: center; }
.lamp-view .lamp-opt-btn { position: relative; z-index: 2; }

/* VideoCAD */
.vc-view { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.vc-modes { display: flex; gap: 6px; flex-wrap: wrap; }
.vc-mode { font: 600 .78rem var(--sans); padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(143,184,255,.25); background: rgba(8,14,24,.5); color: #aebcd3; cursor: pointer; }
.vc-mode.active { background: #ff6b7f; border-color: #ff6b7f; color: #fff; }
.vc-pane[hidden] { display: none; }
.vc-browser { border-radius: 10px; overflow: hidden; background: #fff; border: 1px solid rgba(143,184,255,.25); box-shadow: 0 12px 30px rgba(0,0,0,.35); }
.vc-bar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: #e9edf3; color: #4b5870; font-size: .72rem; }
.vc-bar i { width: 9px; height: 9px; border-radius: 50%; background: #c6ccd6; }
.vc-bar i:nth-child(1) { background: #ff6159; } .vc-bar i:nth-child(2) { background: #ffbd2e; } .vc-bar i:nth-child(3) { background: #28c941; }
.vc-bar span { margin-left: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.vc-browser img { width: 100%; aspect-ratio: 8 / 5; object-fit: cover; display: block; background: #f5f6f8; }
.vc-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.vc-picker button { width: 58px; height: 58px; padding: 0; border-radius: 10px; overflow: hidden; border: 2px solid transparent; background: #fff; cursor: pointer; opacity: .6; transition: opacity .15s, border-color .15s; }
.vc-picker button img { width: 100%; height: 100%; object-fit: cover; }
.vc-picker button:hover { opacity: 1; }
.vc-picker button.active { border-color: #ff6b7f; opacity: 1; }
.vc-note { margin: 0; font-size: .84rem; color: #aebcd3; }
.vc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; align-content: start; max-height: 430px; overflow: auto; padding-right: 4px; }
.vc-grid.auto { grid-template-columns: 1fr; }
.vc-grid.auto .vc-card { max-width: 520px; width: 100%; justify-self: center; }
.vc-card { margin: 0; display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 12px; padding: 10px; }
.vc-tile { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vc-tile img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; display: block; border-radius: 8px; background: #fff; }
.vc-tile.in img { outline: 1px dashed #c8d0dc; outline-offset: -1px; }
.vc-tile span { font-size: .66rem; font-weight: 600; color: #5b6b85; white-space: nowrap; }
.vc-op { font-style: normal; font-weight: 700; color: #a31f34; font-size: 1rem; flex: none; margin-bottom: 16px; }
.vc-policy { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; background: rgba(143,184,255,.07); border: 1px solid rgba(143,184,255,.12); }
.vc-in { display: grid; justify-items: center; gap: 4px; font-size: .68rem; color: #8ea2c2; flex: none; }
.vc-in img { width: 72px; height: 72px; border-radius: 8px; background: #fff; }
.vc-arrow { font-size: .8rem; color: #c9d6ea; line-height: 1.5; }
.vc-arrow b { color: #fff; }
.vc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.vc-actions span { font: 11px ui-monospace, Menlo, monospace; padding: 4px 8px; border-radius: 6px; background: rgba(3,7,13,.6); border: 1px solid rgba(143,184,255,.18); color: #f0bf5a; }

@media (max-width: 900px) {
  .sc-stage { grid-template-columns: 1fr; height: auto; }
  .sc-view { min-height: 360px; }
  .cf-view { min-height: 0; aspect-ratio: 880 / 752; }
  .cf-view video { object-fit: contain; }
  .sc-side { border-left: 0; border-top: 1px solid rgba(143,184,255,.14); }
  .vc-grid, .vc-grid.auto { grid-template-columns: 1fr; }
}

/* ---------- News categories ---------- */
.cat { display: inline-flex; align-items: center; gap: 6px; justify-self: start; font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.cat::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.cat-paper { color: #2f6fdb; } .cat-award { color: #c98a16; } .cat-press { color: #1f8a5a; } .cat-career { color: #8a4fd1; } .cat-teaching { color: #c2410c; }
:root[data-theme="dark"] .cat-paper { color: #7fb0ff; } :root[data-theme="dark"] .cat-award { color: #f0bf5a; } :root[data-theme="dark"] .cat-press { color: #6fd3a0; } :root[data-theme="dark"] .cat-career { color: #c3a2f5; } :root[data-theme="dark"] .cat-teaching { color: #ffa36b; }

/* ---------- Page headers (sub-pages) ---------- */
.page-hero { padding: 56px 0 8px; }
.page-hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -.02em; margin: 6px 0 10px; }
.page-hero p { color: var(--muted); max-width: 720px; margin: 0; }
.page-hero + section.block { padding-top: 28px; }

/* ---------- Skip link ---------- */
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.skip:focus { top: 12px; text-decoration: none; }

/* ---------- Paper thumbnails ---------- */
.pub .thumb { background: linear-gradient(140deg, #f5f8fc 0%, #e8eef6 100%); border: 1px solid var(--line); aspect-ratio: 16 / 10; }
.pub .thumb img { width: 100%; height: 100%; object-fit: cover; }
.pub .thumb.fig img { mix-blend-mode: multiply; }
.pub .thumb .venue-badge { left: auto; right: 8px; top: 8px; font-size: .66rem; padding: 3px 7px; background: rgba(22,24,29,.82); backdrop-filter: blur(4px); }

/* ---------- Videos ---------- */
.videos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.video-card { all: unset; box-sizing: border-box; cursor: pointer; position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #0b1422; border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.video-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.video-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.video-card img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.video-card:hover img { transform: scale(1.04); }
.video-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,12,20,0) 35%, rgba(8,12,20,.82) 100%); pointer-events: none; }
.vc-play { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.92); color: #a31f34; display: grid; place-items: center; z-index: 1; box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .2s; }
.vc-play svg { width: 26px; height: 26px; margin-left: 3px; }
.video-card:hover .vc-play { transform: translate(-50%, -50%) scale(1.08); }
.vc-meta { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 1; color: #fff; display: grid; gap: 2px; }
.vc-meta b { font-size: 1.1rem; font-weight: 800; }
.vc-meta span { font-size: .82rem; color: #d7deea; }
.vc-meta .vc-venue { font-size: .66rem; font-weight: 700; letter-spacing: .08em; color: #ffb3bd; text-transform: uppercase; }
.video-card iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; z-index: 3; }
.video-card.playing::after, .video-card.playing .vc-play, .video-card.playing .vc-meta { display: none; }
@media (max-width: 900px) { .videos { grid-template-columns: 1fr; } }
