/* =========================================================
   Miguel Ortega-Sánchez — personal academic website
   Plain CSS, no frameworks. Palette: aubergine + sand.
   ========================================================= */

:root {
  --bg: #fbf9fc;
  --surface: #ffffff;
  --surface-2: #f4eff6;
  --text: #231a26;
  --muted: #6b5f70;
  --line: #e7dfea;
  --accent: #6d2f78;          /* links, highlights */
  --accent-strong: #562560;   /* buttons */
  --accent-soft: #efe2f2;
  --sand: #c99a55;
  --sand-soft: #f5ead9;
  --eyebrow: #94621c;
  --plum-deep: #2a1230;       /* hero, footer */
  --plum-mid: #4a1d52;
  --on-deep: #f6eef8;
  --on-deep-muted: #cdb8d3;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(42, 18, 48, .06), 0 8px 24px rgba(42, 18, 48, .07);
  --shadow-lg: 0 2px 4px rgba(42, 18, 48, .08), 0 20px 48px rgba(42, 18, 48, .14);
  --max: 1160px;
  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 68px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141016;
    --surface: #1c161f;
    --surface-2: #251d29;
    --text: #efe8f1;
    --muted: #b1a4b6;
    --line: #342a39;
    --accent: #d8acdf;
    --accent-strong: #b77cc2;
    --accent-soft: #33243a;
    --sand: #e0bd86;
    --sand-soft: #33291d;
    --eyebrow: #e0bd86;
    --plum-deep: #1a0b1e;
    --plum-mid: #331538;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, .35), 0 20px 48px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--sand); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2.3rem, 5.5vw, 3.9rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.7rem, 3.2vw, 2.4rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 14px; z-index: 100; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.eyebrow {
  font-family: var(--sans);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--eyebrow);
  margin-bottom: .9rem;
  display: inline-flex; align-items: center; gap: .6rem;
}
.eyebrow::before { content: ""; width: 28px; height: 2px; background: currentColor; border-radius: 2px; }

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; flex-direction: column; text-decoration: none; color: var(--text); line-height: 1.15; }
.brand strong { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.brand span { font-size: .74rem; color: var(--muted); letter-spacing: .04em; }

.nav-list { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; }
.nav-list a {
  display: block; padding: 8px 12px; border-radius: 999px;
  font-size: .92rem; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color .15s, background-color .15s;
}
.nav-list a:hover { color: var(--text); background: var(--surface-2); }
.nav-list a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.nav-toggle {
  display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); cursor: pointer; align-items: center; justify-content: center;
}
.nav-toggle svg { width: 22px; height: 22px; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    position: fixed; inset: var(--header-h) 0 auto 0;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-lg);
    padding: 12px var(--gutter) 20px;
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity .2s, transform .2s, visibility .2s;
  }
  .site-nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav-list { flex-direction: column; }
  .nav-list a { padding: 12px 14px; font-size: 1.02rem; border-radius: 10px; }
}

/* ---------- Buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .8rem 1.3rem; border-radius: 999px;
  font-weight: 600; font-size: .95rem; text-decoration: none; border: 1px solid transparent;
  transition: transform .15s, background-color .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--sand); color: #24121f; }
.btn-primary:hover { box-shadow: 0 8px 20px rgba(201, 154, 85, .35); }
.btn-ghost { color: var(--on-deep); border-color: rgba(255, 255, 255, .35); }
.btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.btn svg, .chip svg { width: 18px; height: 18px; flex: none; }

.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .45rem .9rem; border-radius: 999px;
  font-size: .86rem; font-weight: 500; text-decoration: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
  transition: border-color .15s, color .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  color: var(--on-deep); background: #4a2754;
  padding: clamp(64px, 10vw, 120px) 0 clamp(72px, 10vw, 128px);
}
.hero-bg { position: absolute; inset: 0; z-index: -2; }
.hero-bg img { width: 100%; height: 100%; object-fit: cover; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(100deg, rgba(58, 28, 68, .80) 0%, rgba(92, 52, 106, .58) 45%, rgba(120, 82, 134, .22) 78%, rgba(120, 82, 134, .06) 100%);
}
.hero .container { display: grid; grid-template-columns: 1.35fr .85fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
.hero .eyebrow, .page-hero .eyebrow { color: #e0bd86; }
.hero h1, .page-hero h1 { text-shadow: 0 2px 18px rgba(30, 10, 36, .35); }
.hero .lead, .page-hero p { text-shadow: 0 1px 10px rgba(30, 10, 36, .35); }
.hero h1 { color: #fff; margin-bottom: .35em; }
.hero .role { font-family: var(--serif); font-size: clamp(1.1rem, 2vw, 1.35rem); color: var(--on-deep-muted); font-style: italic; margin-bottom: 1.4rem; }
.hero .lead { font-size: clamp(1.05rem, 1.6vw, 1.2rem); max-width: 38em; color: #efe3f2; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 2rem 0 1.8rem; }
.profiles { display: flex; flex-wrap: wrap; gap: 8px; }
.profiles .chip { background: rgba(255, 255, 255, .08); color: var(--on-deep); border-color: rgba(255, 255, 255, .18); }
.profiles .chip:hover { background: rgba(255, 255, 255, .16); color: #fff; border-color: rgba(255, 255, 255, .4); }

.portrait { position: relative; justify-self: center; width: min(100%, 360px); }
.portrait img {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 30%;
  border-radius: 24px; box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
}
.portrait::before {
  content: ""; position: absolute; inset: -7px; z-index: -1;
  border: 1.5px solid var(--sand); border-radius: 30px; opacity: .75;
}

/* Affiliation card over the portrait */
.affil {
  position: absolute; left: -44px; bottom: 30px; width: max-content; max-width: 300px;
  display: grid; grid-template-columns: 3px 1fr; column-gap: 14px;
  padding: 14px 20px 14px 14px; border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  line-height: 1.3;
}
.affil::before {
  content: ""; grid-row: 1 / span 3; border-radius: 3px;
  background: linear-gradient(180deg, var(--accent-strong), var(--sand));
}
.affil-faculty { font-family: var(--serif); font-size: 1.06rem; font-weight: 600; letter-spacing: -.005em; }
.affil-uni { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.affil-inst {
  display: flex; align-items: baseline; gap: 7px;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line);
  font-size: .7rem; line-height: 1.35; color: var(--muted);
}
.affil-inst abbr {
  text-decoration: none; flex: none;
  font-size: .64rem; font-weight: 700; letter-spacing: .12em;
  color: var(--accent); background: var(--accent-soft); padding: 2px 6px; border-radius: 4px;
}

@media (max-width: 860px) {
  .hero .container { grid-template-columns: 1fr; }
  .portrait {
    order: -1; width: 100%; margin: 0 0 8px; justify-self: stretch;
    display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 16px; align-items: end;
  }
  .portrait::before { display: none; }
  .portrait img { border-radius: 16px; outline: 2px solid var(--sand); outline-offset: 5px; box-shadow: none; }
  .affil { position: static; width: auto; max-width: none; padding: 12px 14px 12px 12px; }
  .affil-faculty { font-size: .98rem; }
}

/* ---------- Stats band ---------- */
.stats { margin-top: -44px; position: relative; z-index: 2; }
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.stat { padding: 22px 24px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat b { display: block; font-family: var(--serif); font-size: 2.2rem; font-weight: 600; color: var(--accent); line-height: 1.1; }
.stat span { display: block; font-size: .88rem; line-height: 1.4; color: var(--muted); margin-top: 4px; }
@media (max-width: 720px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- Sections ---------- */
.section { padding: clamp(64px, 9vw, 110px) 0; }
.section-alt { background: var(--surface-2); }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; margin-bottom: 36px; }
.section-head p { color: var(--muted); max-width: 40em; margin: 0; }
.section-head h2 { margin-bottom: .25em; }
.link-arrow { font-weight: 600; text-decoration: none; white-space: nowrap; }
.link-arrow::after { content: " →"; transition: margin .15s; }
.link-arrow:hover::after { margin-left: 4px; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(32px, 6vw, 72px); align-items: start; }
.about-grid .prose .intro { font-family: var(--serif); font-size: 1.28rem; line-height: 1.55; }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.facts li { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
.facts li > span:first-child { color: var(--muted); font-size: .82rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding-top: 2px; }
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }

/* Research cards */
.research-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 20px; }
.research-card {
  grid-column: span 2; position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--radius); min-height: 300px; color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 24px;
  box-shadow: var(--shadow);
}
.research-card.wide { grid-column: span 3; min-height: 340px; }
.research-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform .6s ease; }
.research-card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(42, 18, 48, 0) 25%, rgba(42, 18, 48, .88) 100%); }
.research-card:hover img { transform: scale(1.05); }
.research-card h3 { color: #fff; margin-bottom: .3em; }
.research-card p { font-size: .93rem; color: #eadcee; margin: 0; }
.research-card .tag { position: absolute; top: 18px; left: 18px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; background: rgba(255, 255, 255, .16); backdrop-filter: blur(6px); padding: 4px 10px; border-radius: 999px; }
@media (max-width: 900px) { .research-card, .research-card.wide { grid-column: span 3; } }
@media (max-width: 600px) { .research-grid { grid-template-columns: 1fr; } .research-card, .research-card.wide { grid-column: auto; min-height: 240px; } }

/* Project cards */
.cards-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
@media (max-width: 760px) { .cards-2 { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.card h3 { margin: 0; }
.card .acronym { font-family: var(--sans); font-size: .8rem; font-weight: 700; letter-spacing: .1em; color: var(--accent); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0 0; font-size: .9rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--sand-soft); color: #8a5a17; width: fit-content; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
@media (prefers-color-scheme: dark) { .badge { color: var(--sand); } }

/* Publication list (shared by home + publications page) */
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub { padding: 20px 0; border-bottom: 1px solid var(--line); }
.pub:first-child { padding-top: 0; }
.pub-title { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; line-height: 1.4; margin: 0 0 4px; color: var(--text); }
.pub-authors { font-size: .92rem; color: var(--muted); margin: 0 0 4px; }
.pub-authors strong { color: var(--text); font-weight: 600; }
.pub-venue { font-size: .92rem; margin: 0; }
.pub-venue em { color: var(--accent); font-style: italic; }
.pub-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 8px; font-size: .8rem; }
.pub-type { font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pub-meta a { text-decoration: none; font-weight: 500; }
.pub-meta a:hover { text-decoration: underline; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 180px; grid-auto-flow: dense; gap: 10px; }
.gallery button {
  all: unset; cursor: zoom-in; position: relative; overflow: hidden; border-radius: 10px;
  background: var(--surface-2);
}
.gallery button:focus-visible { outline: 3px solid var(--sand); outline-offset: 3px; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease, filter .3s; }
.gallery button:hover img { transform: scale(1.06); }
.gallery .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px;
  background: linear-gradient(180deg, transparent, rgba(34, 12, 40, .85));
  color: #fff; font-size: .82rem; font-weight: 600; opacity: 0; transform: translateY(6px); transition: .25s;
}
.gallery button:hover .cap, .gallery button:focus-visible .cap { opacity: 1; transform: none; }
.gallery .g-wide { grid-column: span 2; }
.gallery .g-tall { grid-row: span 2; }
@media (max-width: 760px) {
  .gallery { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 140px; }
  .gallery .cap { opacity: 1; transform: none; }
}

.lightbox { border: 0; padding: 0; background: transparent; max-width: min(1200px, 94vw); max-height: 92vh; overflow: visible; }
.lightbox::backdrop { background: rgba(20, 8, 24, .88); backdrop-filter: blur(4px); }
.lightbox img { max-height: 80vh; width: auto; margin: 0 auto; border-radius: 10px; }
.lightbox p { color: #f1e6f4; text-align: center; margin: 12px 0 0; font-size: .95rem; }
.lightbox p b { font-family: var(--serif); font-size: 1.1rem; }
.lightbox-close { position: absolute; top: -44px; right: 0; background: none; border: 0; color: #fff; font-size: 2rem; line-height: 1; cursor: pointer; padding: 4px 10px; }

/* Contact band */
.contact-band { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.contact-band .card h3 { font-size: 1.05rem; }
.contact-band .card p { margin: 0; font-size: .95rem; color: var(--muted); }
.contact-band .card a { font-weight: 600; }
.icon-circle { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.icon-circle svg { width: 22px; height: 22px; }
@media (max-width: 860px) { .contact-band { grid-template-columns: 1fr; } }

/* ---------- Page header (inner pages) ---------- */
.page-hero { position: relative; isolation: isolate; overflow: hidden; background: #4a2754; color: var(--on-deep); padding: clamp(56px, 8vw, 96px) 0 clamp(48px, 7vw, 80px); }
.page-hero .hero-bg img { opacity: .9; }
.page-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(95deg, rgba(58, 28, 68, .82) 0%, rgba(92, 52, 106, .6) 55%, rgba(120, 82, 134, .3) 100%); }
.page-hero h1 { color: #fff; font-size: clamp(2.1rem, 4.5vw, 3.2rem); }
.page-hero p { color: #e8dbec; max-width: 44em; margin: 0; }
.page-hero .profiles { margin-top: 24px; }

/* ---------- Publications page ---------- */
.pub-toolbar {
  position: sticky; top: var(--header-h); z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); padding: 14px 0;
}
.pub-toolbar .container { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; }
.search { position: relative; flex: 1 1 260px; max-width: 420px; }
.search svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; font: inherit; font-size: .95rem; color: var(--text);
  padding: .65rem 1rem .65rem 2.6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  font: inherit; font-size: .86rem; font-weight: 500; cursor: pointer;
  padding: .45rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.filters button:hover { color: var(--text); border-color: var(--muted); }
.filters button[aria-pressed="true"] { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.filters button .n { opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }
.result-count { margin-left: auto; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .result-count { margin-left: 0; width: 100%; } }

.pub-layout { display: grid; grid-template-columns: 180px 1fr; gap: 48px; }
.year-nav { position: sticky; top: calc(var(--header-h) + 90px); align-self: start; max-height: calc(100vh - var(--header-h) - 110px); overflow: auto; }
.year-nav h2 { font-family: var(--sans); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.year-nav ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.year-nav a { display: block; text-align: center; padding: 4px 0; border-radius: 6px; font-size: .85rem; text-decoration: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.year-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.year-nav li[hidden] { display: none; }

.year-group { display: grid; grid-template-columns: 96px 1fr; gap: 24px; padding-top: 28px; border-top: 2px solid var(--text); margin-bottom: 36px; }
.year-group:first-child { border-top-color: var(--accent); }
.year-group > h2 { font-size: 2rem; color: var(--accent); font-variant-numeric: tabular-nums; margin: 0; position: sticky; top: calc(var(--header-h) + 90px); align-self: start; }
.empty-state { text-align: center; color: var(--muted); padding: 60px 0; }
mark { background: var(--sand-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

@media (max-width: 900px) {
  .pub-layout { grid-template-columns: 1fr; }
  .year-nav { display: none; }
}
@media (max-width: 600px) {
  .year-group { grid-template-columns: 1fr; gap: 12px; }
  .year-group > h2 { position: static; font-size: 1.6rem; }
}

/* ---------- Inner-page components ---------- */
.page-hero.align-right .container { display: flex; flex-direction: column; align-items: flex-end; text-align: left; }
.page-hero.align-right .container > * { width: min(100%, 560px); }
.page-hero.align-right::before { background: linear-gradient(265deg, rgba(58, 28, 68, .84) 0%, rgba(92, 52, 106, .6) 45%, rgba(120, 82, 134, .15) 80%, rgba(120, 82, 134, 0) 100%); }
.page-hero.tall { padding: clamp(80px, 12vw, 150px) 0; }
.page-hero .hero-bg img { object-position: var(--focus, center); }
@media (max-width: 760px) {
  .page-hero.align-right::before { background: linear-gradient(180deg, rgba(58, 28, 68, 0) 0, rgba(70, 36, 80, .4) 210px, #4a2754 350px); }
  .page-hero.tall { padding-top: 310px; }
  .page-hero.tall .hero-bg { bottom: auto; height: 360px; }
  .page-hero.tall .hero-bg img { object-position: 30% 35%; }
}

.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.subnav a { font-size: .85rem; font-weight: 500; text-decoration: none; color: var(--on-deep); padding: .4rem .85rem; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .06); }
.subnav a:hover { background: rgba(255, 255, 255, .16); }

.split { display: grid; grid-template-columns: 280px 1fr; gap: clamp(28px, 5vw, 64px); }
.split > header h2 { margin-bottom: .3em; }
.split > header p { color: var(--muted); font-size: .95rem; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.divider { border: 0; border-top: 1px solid var(--line); margin: clamp(48px, 7vw, 80px) 0; }

/* Education */
.edu { display: grid; gap: 16px; }
.edu .card { flex-direction: row; gap: 20px; align-items: flex-start; }
.edu .year { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; color: var(--accent); min-width: 88px; line-height: 1.2; }
.edu h3 { font-size: 1.12rem; margin-bottom: 4px; }
.edu p { margin: 0; color: var(--muted); font-size: .95rem; }
.edu .award { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 560px) { .edu .card { flex-direction: column; gap: 6px; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.chips li { padding: .5rem 1rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 500; font-size: .93rem; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 135px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 116px 1fr; gap: 44px; padding: 0 0 26px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: 129px; top: 7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent-strong);
}
.timeline li:first-child::before { background: var(--sand); border-color: var(--sand); box-shadow: 0 0 0 5px var(--sand-soft); }
.timeline .when { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); font-size: .92rem; text-align: right; padding-top: 1px; }
.timeline .what { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; line-height: 1.35; }
.timeline .orig { font-style: italic; color: var(--muted); font-size: .9rem; }
.timeline .where { font-size: .93rem; color: var(--muted); margin-top: 2px; }
@media (max-width: 560px) {
  .timeline::before { left: 6px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; padding-left: 30px; }
  .timeline li::before { left: 0; }
  .timeline .when { text-align: left; }
}

/* Research stays */
.stays { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.stay { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; border-top: 3px solid var(--sand); }
.stay .when { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--eyebrow); }
.stay h3 { font-size: 1.05rem; margin: 6px 0 4px; }
.stay p { margin: 0; font-size: .9rem; color: var(--muted); }

/* Collaborations */
.collab { display: grid; grid-template-columns: .9fr 1.1fr; gap: clamp(28px, 5vw, 56px); align-items: start; }
.collab figure { margin: 0; position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.collab figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.collab figure::after { content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, rgba(74, 29, 82, .05), rgba(42, 18, 48, .45)); }
.link-grid { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 28px; }
.link-grid li { break-inside: avoid; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .93rem; line-height: 1.4; }
.link-grid a { color: var(--text); text-decoration: none; font-weight: 500; }
.link-grid a:hover { color: var(--accent); }
.link-grid span { display: block; color: var(--muted); font-size: .82rem; }
@media (max-width: 860px) { .collab { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .link-grid { columns: 1; } }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 12px 0 12px 22px; border-bottom: 1px solid var(--line); position: relative; font-size: .96rem; }
.plain-list li::before { content: ""; position: absolute; left: 2px; top: 21px; width: 8px; height: 8px; border-radius: 2px; background: var(--sand); transform: rotate(45deg); }
.plain-list .muted { color: var(--muted); }

/* Projects */
.project-list { display: grid; gap: 20px; }
.project { display: grid; grid-template-columns: 1fr 300px; gap: 28px; }
.project .tags { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.project h3 { font-size: 1.28rem; margin: 2px 0 6px; }
.project .es { font-style: italic; color: var(--muted); font-size: .93rem; margin: 0; }
.project dl { grid-template-columns: 1fr; gap: 0; margin: 0; align-self: start; border-left: 1px solid var(--line); padding-left: 24px; }
.project dt { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: 10px; }
.project dt:first-child { margin-top: 0; }
.project dd { font-size: .92rem; }
.badge.done { background: var(--surface-2); color: var(--muted); }
.badge.pi { background: var(--accent-soft); color: var(--accent); }
.badge.pi::before { display: none; }
@media (max-width: 860px) {
  .project { grid-template-columns: 1fr; gap: 14px; }
  .project dl { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; }
}

/* Students */
.phd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.phd h3 { font-size: 1.14rem; line-height: 1.35; margin: 0; }
.phd .name { font-weight: 600; font-size: .98rem; }
.phd .meta { font-size: .88rem; color: var(--muted); margin: 0; }
.phd .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: auto; padding-top: 6px; font-size: .85rem; }
.phd .foot a { font-weight: 600; text-decoration: none; }
.phd .year-big { font-family: var(--serif); color: var(--accent); font-size: 1.05rem; font-weight: 600; }
@media (max-width: 760px) { .phd-grid { grid-template-columns: 1fr; } }

.msc-list { list-style: none; margin: 0; padding: 0; }
.msc-list li { display: grid; grid-template-columns: 64px 1fr auto; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.msc-list .y { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.msc-list .t { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; line-height: 1.4; display: block; }
.msc-list .n { font-size: .9rem; color: var(--muted); }
.msc-list a { font-size: .84rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
@media (max-width: 600px) { .msc-list li { grid-template-columns: 1fr; gap: 2px; } }

/* Courses */
.courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.course { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s; }
.course:hover { border-color: var(--accent); transform: translateY(-2px); }
.course .lvl { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--eyebrow); }
.course h3 { font-size: 1.12rem; margin: 0; line-height: 1.35; }
.course p { margin: 0; font-size: .9rem; color: var(--muted); }

/* Call-out */
.callout {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: var(--radius); padding: clamp(28px, 5vw, 48px);
  background: linear-gradient(120deg, var(--plum-deep), var(--plum-mid)); color: var(--on-deep);
  display: flex; flex-wrap: wrap; gap: 20px 40px; align-items: center; justify-content: space-between;
}
.callout::after { content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; border: 40px solid rgba(224, 189, 134, .12); z-index: -1; }
.callout h2 { color: #fff; font-size: clamp(1.4rem, 2.6vw, 1.9rem); margin-bottom: .3em; }
.callout p { margin: 0; color: var(--on-deep-muted); max-width: 40em; }

/* Contact page */
.contact-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; }
.contact-grid .card p { margin: 0; }
.contact-grid .big { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.hours { list-style: none; margin: 4px 0 0; padding: 0; }
.hours li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.hours li:last-child { border-bottom: 0; }
.hours b { font-weight: 600; }
.affil-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.affil-list li { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; }
.affil-list .lvl { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .78rem; }
.affil-list a { font-weight: 600; text-decoration: none; color: var(--text); }
.affil-list a:hover { color: var(--accent); }
.affil-list span { display: block; font-size: .85rem; color: var(--muted); }
@media (max-width: 860px) { .contact-grid { grid-template-columns: 1fr; } }

.map-link { display: inline-flex; gap: 6px; align-items: center; margin-top: 12px; font-weight: 600; text-decoration: none; font-size: .92rem; }
.map-link svg { width: 16px; height: 16px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--plum-deep); color: var(--on-deep-muted); padding: 56px 0 32px; font-size: .92rem; }
.site-footer a { color: var(--on-deep); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; }
.footer-grid h3 { font-family: var(--sans); color: #fff; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 14px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-brand strong { font-family: var(--serif); font-size: 1.3rem; color: #fff; font-weight: 600; display: block; margin-bottom: 6px; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 40px; padding-top: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: .8rem; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }

/* ---------- Motion ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .pub-toolbar, .year-nav, .site-footer, .hero-bg, .page-hero .hero-bg { display: none !important; }
  .page-hero, .hero { background: none; color: #000; padding: 0 0 16px; }
  .page-hero h1, .hero h1 { color: #000; }
  .year-group { break-inside: avoid-page; }
}

/* ---------- Key figures ---------- */
.stat small { display: block; font-size: .78rem; color: var(--muted); opacity: .85; margin-top: 2px; line-height: 1.35; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; position: relative; overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--accent-strong), var(--sand)); }
.kpi b { display: block; font-family: var(--serif); font-weight: 600; font-size: 2rem; line-height: 1.1; color: var(--accent); }
.kpi span { display: block; font-weight: 600; font-size: .95rem; margin-top: 6px; }
.kpi small { display: block; font-size: .84rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr; } }

.q-badge { font-size: .7rem; font-weight: 700; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--sand-soft); color: #8a5a17; }
@media (prefers-color-scheme: dark) { .q-badge { color: var(--sand); } }

/* Registered software */
.sw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.sw { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.sw-name { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.sw p { margin: 0; font-size: .92rem; }
.sw-year { font-size: .78rem; color: var(--muted); margin-top: auto; }

/* ---------- Research lines (image-top cards) ---------- */
.rl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.rl-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.rl-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.rl-card figure { margin: 0; position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); }
.rl-card figure img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.rl-card:hover figure img { transform: scale(1.05); }
.rl-card figure::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(58, 28, 68, 0) 55%, rgba(58, 28, 68, .35)); }
.rl-card .tag {
  position: absolute; top: 14px; left: 14px; z-index: 1;
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700;
  color: #fff; background: rgba(58, 28, 68, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  padding: 4px 10px; border-radius: 999px;
}
.rl-body { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.rl-body h3 { margin: 0; font-size: 1.18rem; }
.rl-body p { margin: 0; font-size: .93rem; color: var(--muted); line-height: 1.6; }
.rl-projects { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rl-projects li { font-size: .72rem; font-weight: 700; letter-spacing: .06em; color: var(--accent); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; }
.rl-body .link-arrow { margin-top: auto; padding-top: 6px; font-size: .9rem; }
@media (max-width: 980px) { .rl-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .rl-grid { grid-template-columns: 1fr; } }

/* ---------- Navigation aids for long pages ---------- */
html { scroll-padding-top: calc(var(--header-h) + 64px); }
.site-header { transition: box-shadow .2s ease; }
.site-header.is-scrolled { box-shadow: 0 6px 24px rgba(42, 18, 48, .08); }

/* In-page section bar (Home, CV) */
.section-bar {
  position: fixed; left: 0; right: 0; top: var(--header-h); z-index: 45;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
  transform: translateY(-8px); opacity: 0; visibility: hidden;
  transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.section-bar.is-visible { transform: none; opacity: 1; visibility: visible; }
.section-bar .container { display: flex; align-items: center; gap: 16px; height: 46px; }
.section-bar-label { flex: none; font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--eyebrow); }
.section-bar-links { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.section-bar-links::-webkit-scrollbar { display: none; }
.section-bar-links a {
  flex: none; padding: 5px 12px; border-radius: 999px; white-space: nowrap;
  font-size: .85rem; font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color .15s, background-color .15s;
}
.section-bar-links a:hover { color: var(--text); background: var(--surface-2); }
.section-bar-links a[aria-current] { color: var(--accent); background: var(--accent-soft); }
@media (max-width: 700px) {
  .section-bar-label { display: none; }
  .section-bar .container { padding-inline: 8px; }
}

/* Back-to-top button */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-strong); color: #fff; text-decoration: none;
  box-shadow: 0 8px 24px rgba(42, 18, 48, .28);
  transition: opacity .2s ease, transform .2s ease, visibility .2s, background-color .15s;
}
.to-top svg { width: 22px; height: 22px; }
.to-top:hover { background: var(--plum-mid); transform: translateY(-2px); }
.js .to-top:not(.is-visible) { opacity: 0; visibility: hidden; transform: translateY(12px); }
@media (max-width: 700px) { .to-top { right: 16px; bottom: 16px; width: 44px; height: 44px; } }
@media print { .section-bar, .to-top { display: none !important; } }

.project-note { margin: 10px 0 0; padding: 10px 14px; border-left: 3px solid var(--sand); background: var(--sand-soft); border-radius: 0 8px 8px 0; font-size: .9rem; }

.interest-group { margin-top: 14px; }
.interest-group > span { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--eyebrow); margin-bottom: 8px; }
