:root {
  --bg: #0b1020;
  --bg-soft: #111a33;
  --surface: #ffffff;
  --surface-2: #f6f8ff;
  --text: #172033;
  --muted: #64708a;
  --line: #dfe5f2;
  --navy: #11182f;
  --purple: #4e2a84;
  --violet: #7251b5;
  --gold: #f4c95d;
  --cyan: #4cc9f0;
  --green: #2fbf71;
  --shadow: 0 18px 45px rgba(17, 24, 47, 0.13);
  --radius: 22px;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #f8faff 0%, #fff 45%, #f8faff 100%);
  line-height: 1.62;
}
body.dark {
  --surface: #111827;
  --surface-2: #0f172a;
  --text: #e5edf7;
  --muted: #a7b4ca;
  --line: #25314a;
  background: #0b1020;
}

a { color: inherit; text-decoration: none; }
a.link { color: var(--purple); font-weight: 700; border-bottom: 1px solid rgba(78,42,132,.28); }
body.dark a.link { color: #cdb7ff; }

.container { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: rgba(255,255,255,.82);
  border-bottom: 1px solid rgba(223,229,242,.85);
}
body.dark .topbar { background: rgba(11,16,32,.82); border-color: #25314a; }
.nav {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 850;
  letter-spacing: -.02em;
}
.logo {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  color: #18120a; font-weight: 900;
  background: linear-gradient(135deg, var(--gold), #fff2bf);
  box-shadow: 0 12px 25px rgba(244,201,93,.32);
}
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav-links a, .nav-links button {
  border: 0; background: transparent; cursor: pointer;
  padding: 9px 12px; border-radius: 999px;
  color: var(--muted); font-weight: 720; font-size: 14px;
}
.nav-links a:hover, .nav-links a.active, .nav-links button:hover { color: var(--text); background: var(--surface-2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 17px; border-radius: 999px;
  background: var(--navy); color: white !important; font-weight: 800;
  box-shadow: 0 16px 30px rgba(17,24,47,.18);
  border: 1px solid rgba(255,255,255,.1);
}
.btn.gold { background: linear-gradient(135deg, var(--gold), #ffe6a3); color: #241706 !important; }
.btn.ghost { background: transparent; color: var(--text) !important; border: 1px solid var(--line); box-shadow: none; }

.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(76,201,240,.22), transparent 34%),
    radial-gradient(circle at 82% 14%, rgba(244,201,93,.30), transparent 32%),
    linear-gradient(135deg, #11182f 0%, #25154a 58%, #4e2a84 100%);
  color: #fff;
  padding: 80px 0 62px;
}
.hero::after {
  content: ""; position: absolute; inset: auto -10% -60px -10%; height: 140px;
  background: #fff; transform: rotate(-2.3deg); transform-origin: left center;
}
body.dark .hero::after { background: #0b1020; }
.hero-grid { position: relative; z-index: 2; display: grid; grid-template-columns: 1.14fr .86fr; gap: 34px; align-items: center; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.11); border: 1px solid rgba(255,255,255,.18); font-size: 13px; font-weight: 760; color: #edf3ff; }
.hero h1 { font-size: clamp(44px, 7vw, 78px); line-height: .95; letter-spacing: -.06em; margin: 18px 0 14px; }
.hero h1 span { color: var(--gold); }
.hero .lead { font-size: clamp(18px, 2.1vw, 23px); color: #dce6ff; max-width: 760px; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.profile-card {
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18); border-radius: 32px;
  padding: 22px; box-shadow: 0 30px 70px rgba(0,0,0,.22); backdrop-filter: blur(10px);
}
.profile-photo {
  width: 100%; aspect-ratio: 1/1.05; object-fit: cover; border-radius: 26px;
  border: 3px solid rgba(244,201,93,.9); box-shadow: 0 18px 35px rgba(0,0,0,.24);
  background: rgba(255,255,255,.1);
}
.hero-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 12px; }
.stat { padding: 12px 10px; border-radius: 18px; background: rgba(255,255,255,.11); text-align: center; }
.stat strong { display: block; font-size: 22px; color: var(--gold); line-height: 1; }
.stat span { display: block; color: #dce6ff; font-size: 12px; margin-top: 6px; }

.section { padding: 72px 0; }
.section.compact { padding-top: 36px; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 28px; }
.kicker { color: var(--purple); font-weight: 900; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }
body.dark .kicker { color: #cdb7ff; }
h2 { font-size: clamp(31px, 4vw, 48px); line-height: 1.05; letter-spacing: -.045em; margin: 7px 0 0; }
h3 { font-size: 21px; letter-spacing: -.025em; line-height: 1.2; margin: 0 0 8px; }
.subtitle { color: var(--muted); max-width: 760px; margin: 10px 0 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card.small { padding: 20px; }
.card.accent { border-top: 5px solid var(--gold); }
.card.purple { border-top: 5px solid var(--purple); }
.card.cyan { border-top: 5px solid var(--cyan); }
.icon {
  width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(78,42,132,.14), rgba(76,201,240,.14)); color: var(--purple); font-size: 22px;
}
.meta { color: var(--muted); font-weight: 730; font-size: 14px; margin-bottom: 8px; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.tag { padding: 6px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-weight: 760; font-size: 12px; }

.timeline { position: relative; display: grid; gap: 16px; }
.timeline-item {
  position: relative; padding: 22px 22px 22px 90px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
}
.timeline-item::before {
  content: attr(data-year); position: absolute; left: 18px; top: 22px; width: 54px; min-height: 54px; border-radius: 18px;
  background: linear-gradient(135deg, var(--purple), #2f1a5b); color: var(--gold); display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 12px; line-height: 1.08; padding: 4px;
}
.timeline-item p { margin: 8px 0 0; color: var(--muted); }

.page-hero { padding: 58px 0; color: #fff; background: linear-gradient(135deg, #11182f, #4e2a84); }
.page-hero h1 { font-size: clamp(30px, 6vw, 64px); letter-spacing: -.055em; line-height: .96; margin: 12px 0; }
.page-hero p { max-width: 780px; color: #dce6ff; font-size: 19px; margin: 0; }

.split { display: grid; grid-template-columns: .85fr 1.15fr; gap: 22px; align-items: start; }
.sidebar { position: sticky; top: 92px; }
.sidebar .card { box-shadow: none; }
.list { padding-left: 20px; margin: 10px 0 0; color: var(--muted); }
.list li { margin-bottom: 7px; }
.footer { padding: 44px 0; background: var(--navy); color: #dce6ff; }
.footer-grid { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer a { color: #fff; font-weight: 760; }
.footer .muted { color: #aebadc; }
.contact-row { display: grid; gap: 12px; }
.contact-pill { display: flex; gap: 12px; align-items: center; padding: 13px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.pub-placeholder { border-style: dashed; background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.mobile-menu { display: none; }

@media (max-width: 900px) {
  .hero-grid, .grid.two, .grid.three, .split { grid-template-columns: 1fr; }
  .hero { padding-top: 52px; }
  .profile-card { max-width: 460px; }
  .section-head { display: block; }
  .sidebar { position: static; }
  .nav-links { display: none; position: absolute; left: 20px; right: 20px; top: 72px; padding: 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
  .nav-links.open { display: grid; justify-content: stretch; }
  .nav-links a, .nav-links button { text-align: left; }
  .mobile-menu { display: inline-flex; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 10px 12px; border-radius: 12px; font-weight: 800; }
}

@media (max-width: 560px) {
  .container { width: min(100% - 26px, var(--max)); }
  .hero-stats { grid-template-columns: 1fr; }
  .timeline-item { padding-left: 22px; padding-top: 90px; }
}


/* Teaching page: polished academic cards */
.teaching-hero {
  background:
    radial-gradient(circle at 12% 24%, rgba(244,201,93,.24), transparent 34%),
    radial-gradient(circle at 88% 12%, rgba(76,201,240,.20), transparent 30%),
    linear-gradient(135deg, #11182f 0%, #2a1857 52%, #4e2a84 100%);
}
.teaching-hero h1 { margin-top: 0; }
.teaching-layout {
  display: grid;
  grid-template-columns: 0.36fr 0.64fr;
  gap: 24px;
  align-items: start;
}
.teaching-summary {
  position: sticky;
  top: 96px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(244,201,93,.12), transparent 34%),
    var(--surface);
}
.summary-icon {
  width: 62px;
  height: 62px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 30px;
  background: linear-gradient(135deg, var(--gold), #fff2bf);
  box-shadow: 0 16px 30px rgba(244,201,93,.24);
  margin-bottom: 16px;
}
.teaching-summary h2 {
  font-size: 30px;
  margin: 0 0 12px;
}
.teaching-summary p { color: var(--muted); margin-top: 0; }
.teaching-focus { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.teaching-focus span {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.teaching-list { display: grid; gap: 18px; }
.teaching-card {
  position: relative;
  overflow: hidden;
  padding: 26px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.teaching-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
  background: linear-gradient(180deg, var(--gold), var(--purple));
}
.teaching-card.kth-card::before { background: linear-gradient(180deg, #cdb7ff, var(--purple)); }
.teaching-card.ut-card::before { background: linear-gradient(180deg, var(--cyan), var(--purple)); }
.teaching-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.teaching-card h2 {
  font-size: clamp(23px, 3vw, 34px);
  margin: 8px 0 0;
  letter-spacing: -.045em;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(244,201,93,.20);
  color: #5e3a00;
  border: 1px solid rgba(244,201,93,.42);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
body.dark .role-badge { color: #ffe6a3; }
.role-badge.violet {
  background: rgba(114,81,181,.16);
  color: var(--purple);
  border-color: rgba(114,81,181,.28);
}
body.dark .role-badge.violet { color: #d8c8ff; }
.role-badge.cyan {
  background: rgba(76,201,240,.16);
  color: #0e6680;
  border-color: rgba(76,201,240,.30);
}
body.dark .role-badge.cyan { color: #a8ecff; }
.institution-mark {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-weight: 950;
  letter-spacing: -.04em;
  color: #241706;
  background: linear-gradient(135deg, var(--gold), #fff2bf);
  box-shadow: 0 16px 30px rgba(17,24,47,.10);
}
.info-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.info-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
  font-weight: 790;
}
.info-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(17,24,47,.07);
}
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.course-grid.single { grid-template-columns: 1fr; }
.course-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  font-weight: 780;
  line-height: 1.38;
}
.course-icon {
  color: var(--purple);
  font-size: 14px;
  line-height: 1.9;
}

@media (max-width: 900px) {
  .teaching-layout { grid-template-columns: 1fr; }
  .teaching-summary { position: static; }
}
@media (max-width: 640px) {
  .teaching-card { padding: 22px 18px 22px 22px; }
  .teaching-card-head { align-items: flex-start; }
  .institution-mark { width: 50px; height: 50px; flex-basis: 50px; border-radius: 18px; font-size: 14px; }
  .course-grid { grid-template-columns: 1fr; }
  .info-chip { width: 100%; }
}


/* Contact page: polished profile/contact layout */
.contact-hero {
  background:
    radial-gradient(circle at 14% 20%, rgba(244,201,93,.24), transparent 32%),
    radial-gradient(circle at 88% 16%, rgba(76,201,240,.20), transparent 30%),
    linear-gradient(135deg, #11182f 0%, #2c185a 55%, #4e2a84 100%);
}
.contact-hero-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
}
.contact-cv-download {
  min-width: 235px;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  box-shadow: 0 22px 50px rgba(0,0,0,.20);
  backdrop-filter: blur(10px);
}
.contact-cv-download:hover { transform: translateY(-2px); background: rgba(255,255,255,.17); }
.contact-cv-download strong, .contact-cv-download small { display: block; line-height: 1.15; }
.contact-cv-download small { color: #dce6ff; margin-top: 4px; }
.contact-cv-icon {
  width: 46px; height: 46px; border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), #ffe9aa);
  color: #231705; font-size: 24px; font-weight: 950;
}
.contact-section { padding-top: 48px; }
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: 22px;
  align-items: stretch;
}
.contact-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 26px;
  box-shadow: var(--shadow);
}
.contact-main-card { grid-row: span 2; }
.contact-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--gold), var(--cyan), var(--purple));
}
.contact-card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.contact-card-head.small-head { margin-bottom: 18px; }
.contact-card h2 { font-size: clamp(25px, 3vw, 36px); margin: 0; letter-spacing: -.04em; }
.contact-card p { margin: 0; }
.contact-muted { color: var(--muted); }
.contact-icon-box {
  flex: 0 0 auto;
  width: 58px; height: 58px; border-radius: 20px;
  display: grid; place-items: center;
  color: #27133f;
  background: linear-gradient(135deg, var(--gold), #fff0b8);
  box-shadow: 0 18px 35px rgba(244,201,93,.23);
}
.contact-icon-box svg { width: 30px; height: 30px; fill: currentColor; }
.contact-icon-box.map { background: linear-gradient(135deg, rgba(76,201,240,.24), rgba(244,201,93,.22)); color: var(--purple); }
.contact-icon-box.research { background: linear-gradient(135deg, rgba(78,42,132,.16), rgba(76,201,240,.18)); color: var(--purple); }
.contact-link-list { display: grid; gap: 13px; }
.contact-link-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.contact-link-card:hover {
  transform: translateY(-2px);
  border-color: rgba(78,42,132,.35);
  box-shadow: 0 16px 34px rgba(17,24,47,.11);
}
.contact-link-card strong, .contact-link-card small { display: block; line-height: 1.18; }
.contact-link-card strong { font-size: 16px; }
.contact-link-card small { color: var(--muted); margin-top: 5px; word-break: break-word; }
.contact-link-icon {
  flex: 0 0 auto;
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--purple);
  font-weight: 950;
}
.contact-link-icon svg { width: 25px; height: 25px; fill: currentColor; }
.contact-link-icon.email { color: #4e2a84; background: rgba(78,42,132,.08); }
.contact-link-icon.website { color: #14799b; background: rgba(76,201,240,.12); }
.contact-link-icon.kth { color: white; background: #1954a6; border-color: #1954a6; font-family: Georgia, serif; font-size: 25px; }
.contact-link-icon.scholar { color: #1557b0; background: rgba(21,87,176,.10); }
.contact-link-icon.linkedin { color: white; background: #0a66c2; border-color: #0a66c2; font-size: 18px; }
.contact-address-box {
  display: grid;
  gap: 5px;
  padding: 18px;
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(78,42,132,.09), rgba(76,201,240,.10)),
    var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}
.contact-address-box strong { font-size: 18px; }
.contact-address-box span { color: var(--muted); }
.contact-map-frame {
  width: 100%;
  height: 245px;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
  margin: 0 0 16px;
}
.contact-map-frame iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  filter: saturate(.96) contrast(.98);
}
.contact-map-button {
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 13px 16px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-weight: 850;
}
.contact-map-button:hover { transform: translateY(-1px); }
.research-interest-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}
.research-interest-grid span {
  position: relative;
  padding: 12px 13px 12px 35px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 780;
  line-height: 1.28;
}
.research-interest-grid span::before {
  content: "•";
  position: absolute;
  left: 15px; top: 10px;
  color: var(--gold);
  font-size: 24px;
  line-height: 1;
}
.contact-cv-card {
  background:
    radial-gradient(circle at 90% 0%, rgba(244,201,93,.22), transparent 30%),
    linear-gradient(135deg, var(--surface), var(--surface-2));
}
.contact-mini-label {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(244,201,93,.16);
  border: 1px solid rgba(244,201,93,.35);
  color: var(--purple);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}
body.dark .contact-mini-label { color: #ffe7a6; }
.contact-cv-button { margin-top: 18px; }

@media (max-width: 900px) {
  .contact-hero-inner, .contact-grid { grid-template-columns: 1fr; display: grid; }
  .contact-cv-download { width: 100%; min-width: 0; }
  .contact-main-card { grid-row: auto; }
}

@media (max-width: 560px) {
  .contact-card { padding: 20px; border-radius: 23px; }
  .contact-card-head { align-items: flex-start; }
  .contact-icon-box { width: 52px; height: 52px; border-radius: 18px; }
  .contact-link-card { align-items: flex-start; }
  .research-interest-grid { grid-template-columns: 1fr; }
}

/* Teaching page fix: real university emblems + clearer course links */
.teaching-card-head {
  align-items: flex-start;
  gap: 24px;
}
.institution-mark.emblem-wrap {
  width: 118px;
  height: 118px;
  flex: 0 0 118px;
  padding: 10px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(255,255,255,.94) !important;
  border: 1px solid rgba(255,255,255,.35);
  box-shadow: 0 20px 44px rgba(0,0,0,.18);
  color: transparent;
}
.institution-mark.emblem-wrap::before,
.institution-mark.emblem-wrap::after {
  content: none !important;
  display: none !important;
}
.institution-mark.emblem-wrap .institution-emblem,
.institution-emblem {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  opacity: 1 !important;
  visibility: visible !important;
  filter: none !important;
}
.kth-emblem-wrap {
  background: #1f5aa6 !important;
  border-color: rgba(80, 135, 218, .55) !important;
}
body.dark .institution-mark.emblem-wrap {
  background: rgba(255,255,255,.95) !important;
}
body.dark .kth-emblem-wrap {
  background: #1f5aa6 !important;
}
.course-copy {
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
}
.course-with-link {
  align-items: flex-start;
}
.course-with-link .course-copy > span {
  display: block;
}
.course-cta {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  padding: 11px 15px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #fff1b8);
  color: #1b1631 !important;
  border: 1px solid rgba(244,201,93,.55);
  box-shadow: 0 12px 24px rgba(244,201,93,.16);
  font-size: 13px;
  font-weight: 950;
  line-height: 1.1;
  text-decoration: none !important;
  letter-spacing: .01em;
  white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.course-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(244,201,93,.28);
  filter: brightness(1.02);
}
.course-cta-small {
  padding: 9px 12px;
  font-size: 12px;
}
body.dark .course-cta {
  background: linear-gradient(135deg, #ffe48a, #fff4c7);
  color: #151222 !important;
  border-color: rgba(255,228,138,.62);
}
@media (max-width: 760px) {
  .institution-mark.emblem-wrap {
    width: 86px;
    height: 86px;
    flex-basis: 86px;
    border-radius: 22px;
    padding: 8px;
  }
  .teaching-card-head {
    gap: 16px;
  }
  .course-cta {
    width: 100%;
  }
}
@media (max-width: 520px) {
  .institution-mark.emblem-wrap {
    width: 74px;
    height: 74px;
    flex-basis: 74px;
  }
  .course-grid {
    grid-template-columns: 1fr !important;
  }
}

/* =========================
   Publications page
   ========================= */
.publications-hero {
  background:
    radial-gradient(circle at 18% 15%, rgba(76,201,240,.20), transparent 32%),
    radial-gradient(circle at 88% 10%, rgba(244,201,93,.25), transparent 28%),
    linear-gradient(135deg, #10162b 0%, #2a1856 58%, #4e2a84 100%);
}
.publications-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr);
  gap: 26px;
  align-items: stretch;
}
.publications-hero h1 { max-width: 950px; }
.pub-hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.pub-metrics-card {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 28px;
  padding: 20px;
  background: rgba(255,255,255,.09);
  backdrop-filter: blur(12px);
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  display: grid;
  gap: 12px;
}
.pub-metric {
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  padding: 17px;
  background: rgba(255,255,255,.09);
}
.pub-metric strong { display: block; color: var(--gold); font-size: 18px; line-height: 1.1; }
.pub-metric span { display: block; color: #e8edff; font-size: 13px; margin-top: 7px; }
.publications-section { padding-top: 54px; }
.pub-section-head { align-items: flex-start; }
.pub-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 24px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  width: fit-content;
  max-width: 100%;
}
.pub-filter {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  font-family: inherit;
}
.pub-filter:hover { color: var(--text); background: var(--surface-2); }
.pub-filter.active {
  color: #221503;
  background: linear-gradient(135deg, var(--gold), #ffedb0);
  border-color: rgba(244,201,93,.55);
  box-shadow: 0 10px 22px rgba(244,201,93,.23);
}
.publication-list { display: grid; gap: 18px; }
.publication-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.publication-card:hover {
  transform: translateY(-2px);
  border-color: rgba(78,42,132,.32);
  box-shadow: 0 24px 56px rgba(17,24,47,.17);
}
.publication-card.featured { border-color: rgba(244,201,93,.65); }
.publication-year {
  display: grid;
  place-items: center;
  padding: 18px 10px;
  color: #251805;
  font-size: 22px;
  font-weight: 950;
  letter-spacing: -.04em;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.65), transparent 34%),
    linear-gradient(180deg, #ffe891, var(--gold));
}
.publication-body { padding: 24px 26px; }
.publication-topline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 11px; }
.pub-type,
.pub-topic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
}
.pub-topic.hardware { color: #5f3ac1; background: rgba(114,81,181,.12); border-color: rgba(114,81,181,.22); }
.pub-topic.puf { color: #0b7f9e; background: rgba(76,201,240,.13); border-color: rgba(76,201,240,.25); }
.pub-topic.vlsi { color: #8b6100; background: rgba(244,201,93,.16); border-color: rgba(244,201,93,.34); }
.publication-card h3 {
  font-size: clamp(21px, 2.2vw, 28px);
  letter-spacing: -.035em;
  margin-bottom: 10px;
}
.publication-authors,
.publication-venue,
.publication-note { margin: 8px 0; }
.publication-authors { color: var(--text); }
.publication-venue { color: var(--muted); font-weight: 760; }
.publication-note { color: var(--muted); max-width: 980px; }
.publication-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.pub-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 850;
  font-size: 13px;
}
.pub-btn:hover { transform: translateY(-1px); }
.pub-btn.primary { background: var(--navy); color: #fff; border-color: rgba(255,255,255,.1); }
body.dark .pub-btn.primary { background: #222c49; }
.pub-btn.ghost { background: transparent; color: var(--muted); }
.pub-howto-card {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  border: 1px dashed rgba(78,42,132,.35);
  border-radius: 26px;
  background:
    linear-gradient(135deg, rgba(78,42,132,.08), rgba(76,201,240,.06));
}
.pub-howto-card h3 { margin-bottom: 8px; }
.pub-howto-card p { margin: 0; color: var(--muted); }
.pub-howto-card code {
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
}
@media (max-width: 900px) {
  .publications-hero-grid { grid-template-columns: 1fr; }
  .pub-metrics-card { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .publication-card { grid-template-columns: 76px minmax(0, 1fr); }
  .publication-body { padding: 20px; }
  .pub-toolbar { border-radius: 24px; width: 100%; }
}
@media (max-width: 640px) {
  .pub-metrics-card { grid-template-columns: 1fr; }
  .publication-card { grid-template-columns: 1fr; }
  .publication-year { min-height: 58px; place-items: center start; padding-left: 20px; }
  .publication-actions .pub-btn { width: 100%; }
  .pub-howto-card { align-items: stretch; flex-direction: column; }
}

/* =========================
   Compact Publications page override
   ========================= */
.compact-publications-hero .container {
  padding-top: 54px;
  padding-bottom: 46px;
}
.compact-pub-hero-grid {
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
}
.compact-publications-hero h1 {
  max-width: 1040px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: .98;
}
.compact-publications-hero p {
  max-width: 850px;
}
.compact-pub-summary {
  align-content: center;
  padding: 16px;
}
.compact-pub-summary .pub-metric {
  padding: 13px 15px;
}
.compact-pub-summary .pub-metric strong {
  font-size: 17px;
}
.compact-publications-section {
  padding-top: 38px;
}
.compact-pub-section-head {
  margin-bottom: 14px;
}
.compact-pub-toolbar {
  margin-bottom: 18px;
  padding: 7px;
  box-shadow: 0 12px 30px rgba(17,24,47,.08);
}
.compact-pub-toolbar .pub-filter {
  padding: 8px 12px;
  font-size: 13px;
}
.compact-publication-list {
  gap: 11px;
}
.compact-publication-card {
  grid-template-columns: 74px minmax(0, 1fr);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(17,24,47,.08);
}
.compact-publication-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 36px rgba(17,24,47,.13);
}
.compact-publication-card .publication-year {
  font-size: 18px;
  padding: 12px 8px;
  letter-spacing: -.02em;
}
.compact-publication-card .publication-body {
  padding: 14px 17px 13px;
}
.compact-publication-card .publication-topline {
  margin-bottom: 6px;
  gap: 6px;
}
.compact-publication-card .pub-type,
.compact-publication-card .pub-topic {
  font-size: 9.5px;
  padding: 4px 7px;
  letter-spacing: .055em;
}
.compact-publication-card h3 {
  font-size: clamp(16px, 1.4vw, 20px);
  line-height: 1.22;
  margin: 0 0 6px;
  letter-spacing: -.02em;
}
.compact-publication-card .publication-authors,
.compact-publication-card .publication-venue {
  margin: 4px 0;
  font-size: 13.5px;
  line-height: 1.35;
}
.compact-publication-card .publication-venue {
  font-weight: 700;
}
.compact-publication-card .publication-note {
  display: none !important;
}
.compact-publication-card .publication-actions {
  gap: 7px;
  margin-top: 9px;
}
.compact-publication-card .pub-btn {
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1;
}
.compact-pub-howto-card {
  margin-top: 16px;
  padding: 18px;
  border-radius: 22px;
}
.compact-pub-howto-card h3 {
  font-size: 20px;
  margin-bottom: 4px;
}
.compact-pub-howto-card p {
  font-size: 14px;
}
@media (max-width: 900px) {
  .compact-pub-hero-grid {
    grid-template-columns: 1fr;
  }
  .compact-pub-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .compact-publication-card {
    grid-template-columns: 1fr;
  }
  .compact-publication-card .publication-year {
    min-height: 42px;
    place-items: center start;
    padding-left: 17px;
  }
  .compact-publication-card .publication-actions .pub-btn {
    width: auto;
    flex: 1 1 auto;
  }
  .compact-pub-summary {
    grid-template-columns: 1fr;
  }
}


/* Research + publications merged page */
.research-combined-hero .hero-actions { margin-top: 22px; }
.research-mini-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.research-mini-stat {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow-soft);
}
body.dark .research-mini-stat { background: rgba(20, 18, 36, .72); }
.research-mini-stat strong { display: block; font-size: 1.05rem; color: var(--text); }
.research-mini-stat span { display: block; font-size: .78rem; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.research-themes-compact .card { padding: 20px; }
.research-themes-compact .card h3 { margin-bottom: 8px; }
.research-themes-compact .card p { font-size: .94rem; line-height: 1.55; }
.merged-publication-note {
  margin-top: 12px;
  font-size: .88rem;
  color: var(--muted);
}
@media (max-width: 820px) {
  .research-mini-panel { grid-template-columns: 1fr; }
}


/* Publications page: compact 2x2 research theme grid */
.research-themes-section {
  padding-top: 34px;
}
.research-themes-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.research-themes-grid .card {
  padding: 22px 24px;
  min-height: 188px;
}
.research-themes-grid .card h3 {
  margin: 0 0 10px;
  font-size: 1.28rem;
  letter-spacing: -.025em;
}
.research-themes-grid .card p {
  margin: 0;
  font-size: .95rem;
  line-height: 1.55;
  color: var(--muted);
}
@media (max-width: 820px) {
  .research-themes-grid { grid-template-columns: 1fr; }
  .research-themes-grid .card { min-height: auto; }
}


/* Consistent sticky topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 9999;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body.dark .topbar {
  background: rgba(8, 13, 29, 0.90);
}

body:not(.dark) .topbar {
  background: rgba(255, 255, 255, 0.88);
}


/* Strong sticky topbar above every page section */
.topbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 99999 !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

body.dark .topbar {
  background: rgba(8, 13, 29, 0.92) !important;
}

body:not(.dark) .topbar {
  background: rgba(255, 255, 255, 0.90) !important;
}


/* ===== Final consistency and polish pass ===== */
:root { color-scheme: light dark; }
.topbar { position: sticky !important; top: 0 !important; z-index: 9999 !important; }
body:not(.dark) .topbar { background: rgba(255,255,255,0.91); }
body:not(.dark) .nav-links a:hover,
body:not(.dark) .nav-links a.active,
body:not(.dark) .nav-links button:hover { background: #eef3ff; color: #111827; }
body.dark .nav-links a:hover,
body.dark .nav-links a.active,
body.dark .nav-links button:hover { background: rgba(255,255,255,0.08); color: #fff; }

.email-obfuscated { font-weight: 850; color: #fff; white-space: nowrap; }
.email-obfuscated.big { display: inline-flex; padding: 10px 13px; border-radius: 999px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
body.dark .email-obfuscated.big { background: rgba(255,255,255,0.06); color: #e5edf7; }
.footer { border-top: 1px solid rgba(255,255,255,0.10); }
.footer-links { text-align: right; }
.copyright { margin-top: 7px; color: #aebadc; font-size: 0.78rem; font-weight: 650; }
body:not(.dark) .footer { background: #11182f; color: #dce6ff; }

.home-hero-v2 {
  position: relative;
  overflow: hidden;
  padding: 88px 0 68px;
  color: #fff;
  background:
    radial-gradient(circle at 12% 18%, rgba(112,215,255,0.20), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(255,231,136,0.26), transparent 28%),
    linear-gradient(135deg, #11182f 0%, #25154a 58%, #4e2a84 100%);
}
.home-hero-v2::after { content: ""; position: absolute; inset: auto -10% -66px -10%; height: 150px; background: #fff; transform: rotate(-2deg); transform-origin: left center; }
body.dark .home-hero-v2::after { background: #0b1020; }
.home-hero-grid-v2 { position: relative; z-index: 1; display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 34px; align-items: center; }
.home-hero-copy-v2 h1 { font-size: clamp(48px, 7vw, 86px); line-height: .92; letter-spacing: -.065em; margin: 18px 0 14px; }
.home-hero-copy-v2 h1 span { color: var(--gold); }
.home-hero-copy-v2 .lead { font-size: clamp(18px, 2vw, 23px); color: #dce6ff; max-width: 790px; margin: 0; }
.home-signal-card { position: relative; border: 1px solid rgba(255,255,255,.18); border-radius: 34px; padding: 26px; min-height: 330px; background: linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,.055)); box-shadow: 0 30px 70px rgba(0,0,0,.22); backdrop-filter: blur(10px); }
.home-signal-card h2 { margin-top: 128px; font-size: clamp(28px, 3.2vw, 44px); color: #fff; }
.home-signal-card p { color: #dce6ff; }
.signal-orbit { position: absolute; left: 26px; top: 26px; right: 26px; height: 110px; border-radius: 28px; background: radial-gradient(circle at 50% 50%, rgba(255,231,136,.18), transparent 55%); }
.signal-orbit span { position: absolute; display: grid; place-items: center; width: 68px; height: 68px; border-radius: 24px; color: #111827; background: linear-gradient(135deg, #fff1a8, #ffd66f); font-weight: 950; box-shadow: 0 14px 30px rgba(0,0,0,.18); }
.signal-orbit span:nth-child(1) { left: 0; top: 8px; }
.signal-orbit span:nth-child(2) { left: calc(50% - 34px); top: 0; background: linear-gradient(135deg, #70d7ff, #c5f2ff); }
.signal-orbit span:nth-child(3) { right: 0; top: 8px; background: linear-gradient(135deg, #cdb7ff, #8d5cf6); color: #fff; }
.signal-tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 18px; }
.signal-tags span { padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.16); color: #eef4ff; font-size: 0.75rem; font-weight: 850; }
.home-scroll-map { padding: 28px 0 0; }
.home-strip { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: 0 14px 32px rgba(15,23,42,0.08); }
.home-strip a { padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 850; font-size: 0.84rem; }
.home-strip a:hover { color: #111827; background: linear-gradient(135deg, #fff1a8, #ffd66f); }
body.dark .home-strip a:hover { color: #111827; }
.interest-grid-v2 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.interest-card-v2 { position: relative; overflow: hidden; padding: 18px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 14px 32px rgba(15,23,42,0.07); }
body.dark .interest-card-v2 { background: rgba(17,24,39,0.92); border-color: rgba(255,255,255,0.10); }
.interest-card-v2::before { content:""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, #ffe788, #70d7ff, #8d5cf6); }
.interest-card-v2.wide { grid-column: span 2; }
.interest-card-v2 h3 { font-size: 1rem; margin: 10px 0 6px; }
.interest-card-v2 p { margin: 0; color: var(--muted); font-size: 0.80rem; line-height: 1.55; }
.interest-icon-v2 { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 15px; font-size: 0.68rem; font-weight: 950; color: #111827; background: linear-gradient(135deg, #fff1a8, #ffd66f); }
.interest-icon-v2.lock { background: linear-gradient(135deg, #7ee0b2, #d6ffec); }
.interest-icon-v2.trust { background: linear-gradient(135deg, #cdb7ff, #8d5cf6); color: #fff; }
.interest-icon-v2.power { background: linear-gradient(135deg, #70d7ff, #d7f6ff); }
.interest-icon-v2.cpu { background: linear-gradient(135deg, #ffe788, #70d7ff); }
.home-preview-card { padding: 26px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.home-preview-card p { color: var(--muted); }
.home-contact-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 26px; border-radius: 28px; background: linear-gradient(135deg, rgba(255,231,136,.12), rgba(112,215,255,.08)), var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.home-contact-card p { color: var(--muted); margin-bottom: 0; }
.home-contact-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.home-project-strip .card { min-height: 150px; }

body:not(.dark) .card,
body:not(.dark) .timeline-item,
body:not(.dark) .contact-panel,
body:not(.dark) .project-research-card,
body:not(.dark) .project-job-row,
body:not(.dark) .career-job-row,
body:not(.dark) .skill-metric-card,
body:not(.dark) .award-tile { background-color: #ffffff; color: #111827; }
body:not(.dark) .page-hero,
body:not(.dark) .contact-compact-hero,
body:not(.dark) .teaching-hero { color: #111827; background: linear-gradient(135deg, #f8faff, #eef3ff 60%, #ffffff); }
body:not(.dark) .page-hero p,
body:not(.dark) .contact-compact-hero p,
body:not(.dark) .teaching-hero p { color: #4b5872; }
body:not(.dark) .eyebrow { background: rgba(17,24,39,.06); border-color: rgba(17,24,39,.10); color: #31415c; }
body:not(.dark) .home-hero-v2 .eyebrow { background: rgba(255,255,255,.11); border-color: rgba(255,255,255,.18); color: #edf3ff; }

.contact-grid-compact { align-items: stretch; }
.contact-left-stack .contact-panel { height: 100%; }
.address-line { font-weight: 950; }
.address-muted { color: var(--muted); }

@media (max-width: 980px) {
  .home-hero-grid-v2, .interest-grid-v2 { grid-template-columns: 1fr; }
  .interest-card-v2.wide { grid-column: span 1; }
  .home-signal-card h2 { margin-top: 116px; }
  .home-contact-card { display: block; }
  .home-contact-actions { justify-content: flex-start; margin-top: 16px; }
}
@media (max-width: 620px) {
  .home-hero-v2 { padding-top: 58px; }
  .signal-orbit span { width: 58px; height: 58px; border-radius: 20px; }
  .home-strip { border-radius: 22px; justify-content: flex-start; }
  .footer-links { text-align: left; }
}


.bio-link {
  color: #70d7ff;
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: color 0.18s ease, background 0.18s ease;
}

.bio-link::after {
  content: " ↗";
  font-size: 0.78em;
  font-weight: 900;
}

.bio-link:hover {
  color: #ffe788;
  background: rgba(255, 231, 136, 0.08);
  border-radius: 6px;
}

body:not(.dark) .bio-link {
  color: #1268a8;
}

body:not(.dark) .bio-link:hover {
  color: #7a4b00;
  background: rgba(255, 214, 111, 0.22);
}
