:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1b2030;
  --muted: #586075;
  --border: #e0e4ee;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, .1);
  --accent-hover: rgba(79, 70, 229, .18);
  --shadow: 0 1px 2px rgba(20, 25, 45, .05), 0 10px 30px rgba(20, 25, 45, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1219;
    --surface: #171c27;
    --text: #e8ebf3;
    --muted: #9aa3b7;
    --border: #272d3d;
    --accent: #9a95ff;
    --accent-soft: rgba(154, 149, 255, .14);
    --accent-hover: rgba(154, 149, 255, .24);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1219;
  --surface: #171c27;
  --text: #e8ebf3;
  --muted: #9aa3b7;
  --border: #272d3d;
  --accent: #9a95ff;
  --accent-soft: rgba(154, 149, 255, .14);
  --accent-hover: rgba(154, 149, 255, .24);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: clamp(340px, 30vw, 440px) minmax(0, 1fr);
  min-height: 100vh;
}
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Profile sidebar */
.profile {
  align-self: stretch;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(120% 60% at 0% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
}
.profile-inner { padding: 2.5rem 2.25rem; text-align: center; }
/* Only pin the sidebar when it fits the viewport; otherwise it scrolls with the page (never its own scrollbar) */
@media (min-width: 961px) and (min-height: 1200px), (min-width: 1280px) and (min-height: 1060px), (min-width: 1440px) and (min-height: 940px) {
  .profile { position: sticky; top: 0; align-self: start; height: 100vh; }
}
.portrait {
  width: 148px; height: 148px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--surface); box-shadow: 0 0 0 2px var(--accent), var(--shadow);
}
.profile h1 {
  font-size: clamp(1.05rem, .85rem + .7vw, 1.4rem); line-height: 1.25; margin: 1.1rem 0 .75rem;
  letter-spacing: -.01em; white-space: nowrap;
}
.profile h1 a { color: var(--text); text-decoration: none; }
.bio {
  font-size: .95rem; line-height: 1.65; color: var(--muted); margin: 0 0 1.25rem;
  text-align: justify; text-justify: inter-word; hyphens: auto; -webkit-hyphens: auto;
}
.social { list-style: none; display: flex; gap: .6rem; justify-content: center; padding: 0; margin: 0; }
.social a {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); text-decoration: none; font-size: 1.15rem;
  transition: background .2s, transform .15s;
}
.social a:hover, .social a:focus-visible { background: var(--accent-hover); transform: translateY(-2px); }

/* Main column */
main { width: 100%; max-width: 860px; padding: 1.25rem 2rem 3rem; margin-inline: auto; min-width: 0; }

.topnav {
  position: sticky; top: .75rem; z-index: 5;
  display: flex; align-items: center; gap: .5rem; justify-content: space-between;
  padding: .4rem .5rem .4rem .6rem; margin-bottom: 2rem;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border: 1px solid var(--border); border-radius: 26px; box-shadow: var(--shadow);
}
.topnav .links { display: flex; gap: .1rem; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.topnav .links::-webkit-scrollbar { display: none; }
.topnav a {
  flex: none; white-space: nowrap; color: var(--muted); text-decoration: none;
  padding: .4rem .7rem; border-radius: 999px; font-size: .92rem; font-weight: 500;
}
.topnav a:hover { color: var(--text); background: var(--accent-soft); }
.topnav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.theme-btn {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
}
.theme-btn:hover { background: var(--accent-soft); color: var(--text); }
.theme-btn .i-moon { display: none; }
:root[data-theme="dark"] .theme-btn .i-sun { display: none; }
:root[data-theme="dark"] .theme-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .i-moon { display: block; }
}

/* Entries */
article {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 1.75rem 1.75rem 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow);
}
article h1, article h2 { margin: 0; font-size: 1.55rem; line-height: 1.25; letter-spacing: -.01em; }
article h2 a { color: var(--text); text-decoration: none; }
article h2 a:hover { color: var(--accent); }
.meta { margin: .35rem 0 1.25rem; font-size: .88rem; color: var(--muted); }
article > header { margin-bottom: 1.1rem; }
article > header > .meta { margin-bottom: 0; }
.entry-body h3 { font-size: 1.1rem; margin: 1.25rem 0 .4rem; }
.entry-body h4 { font-size: 1rem; margin: 1rem 0 .35rem; }
.entry-body h5 { font-size: .95rem; margin: .9rem 0 .3rem; }
/* Graduate Work groups two degrees; make their headings read as sub-headings of the section */
.entry-body section.sub > h4[id] { font-size: 1.05rem; margin: 1.4rem 0 .5rem; padding-bottom: .3rem; border-bottom: 1px dashed var(--border); }
.entry-body section.sub > h3 + h4[id] { margin-top: .5rem; }
/* Research Activities: three sub-sections inside one card */
.entry-body section.sub { padding-top: 1.1rem; margin-top: 1.1rem; border-top: 1px solid var(--border); }
.entry-body section.sub:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
.entry-body section.sub > h3 { margin: 0 0 .6rem; font-size: 1.2rem; color: var(--accent); }
.entry-body section.sub > :last-child { margin-bottom: 0; }
.entry-body p { margin: 0 0 1rem; }
.entry-body ul { padding-left: 1.2rem; margin: 0 0 1rem; }
.entry-body li { margin-bottom: .25rem; }
.entry-body em { color: var(--muted); }

/* Publications: title, authors/venue, then link chips */
.publications p { padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.publications p:last-child { border-bottom: 0; padding-bottom: 0; }
.publications strong { display: block; font-size: 1.02rem; line-height: 1.4; }
.publications p a {
  display: inline-block; margin: .45rem .3rem 0 0; padding: .1rem .7rem; border-radius: 999px;
  font-size: .82rem; font-weight: 600; text-decoration: none; background: var(--accent-soft);
}
.publications p a:hover { background: var(--accent-hover); }

/* Videos: thumbnails */
.videos p:has(> a > img) { margin-bottom: 1.5rem; }
.videos a > img {
  display: block; width: 100%; max-width: 480px; height: auto; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border); transition: transform .2s, box-shadow .2s;
}
.videos a:hover > img { transform: translateY(-2px); box-shadow: var(--shadow); }

/* CV timeline */
.timeline { list-style: none; margin: 1.25rem 0 .25rem; padding: 0 0 0 1.25rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding-bottom: 1.4rem; }
.timeline li::before {
  content: ""; position: absolute; left: calc(-1.25rem - 7px); top: .45rem; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
.timeline h3 { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.timeline p { margin: .1rem 0 0; font-size: .95rem; color: var(--muted); }
.timeline .org { color: var(--text); font-weight: 600; }
.timeline .when { font-size: .88rem; }
.timeline p:not(.org):not(.when):not(.where) { margin-top: .4rem; color: var(--text); }

/* Archives */

.site-footer { text-align: center; color: var(--muted); font-size: .9rem; padding-top: 1rem; }
.site-footer p { margin: 0; }

@media (max-width: 1180px) {
  .topnav a { padding: .4rem .6rem; font-size: .88rem; }
}

/* Narrow screens: profile stacks above content */
@media (max-width: 960px) {
  body { display: block; }
  .profile { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .profile-inner { padding: 2rem 1.25rem 1.5rem; max-width: 640px; margin-inline: auto; }
  main { padding: 1rem 1rem 2.5rem; }
  .topnav { top: .5rem; }
  article { padding: 1.25rem 1.1rem 1rem; border-radius: 14px; }
  article h1, article h2 { font-size: 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
