/* ==========================================================================
   Academic website — S.M.A. Rizvi
   Plain CSS, no framework. Colours are tokens on :root; dark mode redefines
   them under [data-theme="dark"] (set by the toggle) or the OS preference.
   ========================================================================== */

/* ---------- Fonts (self-hosted, variable) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../assets/fonts/source-serif-4-var-latin.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../assets/fonts/source-serif-4-var-latin-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --bg: #f8f7f3;
  --bg-alt: #f0eee7;
  --surface: #ffffff;
  --surface-2: #f5f4ef;
  --border: #e2dfd6;
  --border-strong: #cfcbbf;
  --text: #1a2233;
  --text-muted: #525b6b;
  --text-faint: #6b7280;
  --navy: #13284c;
  --navy-2: #1f3b6b;
  --accent: #9c4317;
  --accent-soft: #f6e9df;
  --link: #1f4f99;
  --tag-bg: #eaeef6;
  --tag-text: #22375e;
  --success: #1c6b43;
  --success-soft: #e3f2e9;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --shadow: 0 1px 2px rgba(19, 40, 76, .06), 0 4px 16px rgba(19, 40, 76, .05);
  --shadow-hover: 0 2px 4px rgba(19, 40, 76, .08), 0 10px 28px rgba(19, 40, 76, .09);
  --map-dot: #c9cfdb;
  --radius: 12px;
  --radius-sm: 8px;
  --serif: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --container: 1120px;
  --header-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1320;
    --bg-alt: #111a2a;
    --surface: #141d2e;
    --surface-2: #19243a;
    --border: #243149;
    --border-strong: #33425f;
    --text: #e5e9f0;
    --text-muted: #a9b3c4;
    --text-faint: #8c97aa;
    --navy: #d3def3;
    --navy-2: #a9bde3;
    --accent: #e8a06f;
    --accent-soft: #33241b;
    --link: #8fb4ef;
    --tag-bg: #1e2b44;
    --tag-text: #c3d2ee;
    --success: #7fd3a4;
    --success-soft: #16301f;
    --warn: #f0c46b;
    --warn-soft: #33290f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .35);
    --map-dot: #2c3a55;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1320;
  --bg-alt: #111a2a;
  --surface: #141d2e;
  --surface-2: #19243a;
  --border: #243149;
  --border-strong: #33425f;
  --text: #e5e9f0;
  --text-muted: #a9b3c4;
  --text-faint: #8c97aa;
  --navy: #d3def3;
  --navy-2: #a9bde3;
  --accent: #e8a06f;
  --accent-soft: #33241b;
  --link: #8fb4ef;
  --tag-bg: #1e2b44;
  --tag-text: #c3d2ee;
  --success: #7fd3a4;
  --success-soft: #16301f;
  --warn: #f0c46b;
  --warn-soft: #33290f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .35);
  --map-dot: #2c3a55;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(1rem, .96rem + .2vw, 1.0625rem);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; }
img { height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--navy);
  line-height: 1.2;
  font-weight: 600;
  margin: 0 0 .5em;
  letter-spacing: -.005em;
}
h1 { font-size: clamp(2rem, 1.5rem + 2.2vw, 3rem); }
h2 { font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem); }
h3 { font-size: clamp(1.1rem, 1.04rem + .3vw, 1.25rem); }
p { margin: 0 0 1em; }
ul { padding-left: 1.2em; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 20px; }
@media (max-width: 480px) { .container { padding: 0 16px; } }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 200;
  background: var(--navy); color: var(--bg); padding: 8px 14px; border-radius: var(--radius-sm);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; color: var(--bg); }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.18em; }
[hidden] { display: none !important; }

/* ---------- Header / navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.site-header.scrolled { border-bottom-color: var(--border); box-shadow: 0 1px 12px rgba(0,0,0,.04); }
.nav-wrap { display: flex; align-items: center; gap: 12px; height: var(--header-h); }
.brand {
  font-family: var(--serif); font-weight: 650; font-size: 1.2rem; color: var(--navy);
  text-decoration: none; white-space: nowrap; margin-right: auto; letter-spacing: -.01em;
}
.brand:hover { color: var(--navy); }
.brand .brand-mark { color: var(--accent); font-weight: 500; }
.nav-menu { display: flex; align-items: center; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav-menu a {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--text-muted);
  text-decoration: none; font-size: .92rem; font-weight: 500; white-space: nowrap;
}
.nav-menu a:hover { color: var(--navy); background: var(--surface-2); }
.nav-menu a[aria-current="page"] { color: var(--navy); background: var(--tag-bg); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--navy); cursor: pointer; padding: 0;
}
.icon-btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn .icon { width: 20px; height: 20px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
.nav-toggle { display: none; }

@media (max-width: 1080px) {
  .nav-toggle { display: inline-grid; }
  .site-nav { order: 3; }
  .nav-menu {
    position: fixed; left: 0; right: 0; top: var(--header-h);
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px; box-shadow: 0 16px 32px rgba(0,0,0,.08);
    max-height: calc(100vh - var(--header-h)); overflow-y: auto;
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
  }
  .nav-menu.open { transform: none; opacity: 1; visibility: visible; }
  .nav-menu a { padding: 12px 12px; font-size: 1rem; }
  .nav-toggle .icon-x { display: none; }
  .nav-toggle[aria-expanded="true"] .icon-x { display: block; }
  .nav-toggle[aria-expanded="true"] .icon-menu { display: none; }
}

/* ---------- Layout sections ---------- */
main { display: block; }
.section { padding: clamp(48px, 6vw, 80px) 0; }
.section + .section { padding-top: 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-alt + .section { padding-top: clamp(48px, 6vw, 80px); }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 6px 0 0; color: var(--text-muted); max-width: 62ch; }
.eyebrow {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: .12em;
  font-size: .75rem; font-weight: 650; color: var(--accent); margin: 0 0 10px;
}
.more-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: none; font-size: .95rem; }
.more-link:hover .icon { transform: translateX(3px); }
.more-link .icon { transition: transform .15s ease; }

.page-hero { padding: clamp(40px, 6vw, 72px) 0 clamp(24px, 3vw, 36px); }
.page-hero h1 { margin-bottom: 12px; }
.page-hero .lede { font-size: 1.1rem; color: var(--text-muted); max-width: 68ch; margin: 0; }

.subnav {
  position: sticky; top: var(--header-h); z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.subnav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 8px 0; overflow-x: auto; scrollbar-width: none; }
.subnav ul::-webkit-scrollbar { display: none; }
.subnav a {
  display: block; padding: 6px 12px; border-radius: 999px; font-size: .88rem; font-weight: 550;
  color: var(--text-muted); text-decoration: none; white-space: nowrap;
}
.subnav a:hover { color: var(--navy); background: var(--surface-2); }
.subnav a.active { color: var(--navy); background: var(--tag-bg); }

/* ---------- Cards, tags, badges, buttons ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card-hover { transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; }
.card-hover:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); transform: translateY(-2px); }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.tag {
  display: inline-block; font-size: .76rem; font-weight: 550; line-height: 1.3;
  padding: 3px 9px; border-radius: 999px; background: var(--tag-bg); color: var(--tag-text);
}
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 650;
  line-height: 1.3; padding: 3px 9px; border-radius: 6px; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border);
}
.badge .icon { width: 13px; height: 13px; }
.badge-award { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-active, .badge-granted { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-planned, .badge-submitted { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: .93rem; font-weight: 600; line-height: 1;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  text-decoration: none; cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease;
  min-height: 42px;
}
.btn-primary { background: var(--navy); color: var(--bg); }
.btn-primary:hover { background: var(--navy-2); color: var(--bg); }
.btn-outline { background: var(--surface); color: var(--navy); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm {
  font-size: .8rem; padding: 6px 10px; min-height: 32px; border-radius: 7px; gap: 5px;
  background: var(--surface); color: var(--text-muted); border-color: var(--border);
}
.btn-sm:hover { color: var(--navy); border-color: var(--border-strong); background: var(--surface-2); }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-sm[aria-expanded="true"] { background: var(--tag-bg); color: var(--navy); border-color: transparent; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-size: .85rem; font-weight: 550; padding: 7px 14px; min-height: 36px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--border-strong); color: var(--navy); }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: var(--bg); }
.chip .count { font-size: .75rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .count { color: inherit; opacity: .8; }

.empty-note { color: var(--text-muted); font-style: italic; padding: 24px 0; }
.muted { color: var(--text-muted); }
.small { font-size: .88rem; }

/* ---------- Home hero ---------- */
.hero { padding: clamp(40px, 7vw, 88px) 0 clamp(40px, 5vw, 64px); }
.hero-grid { display: grid; grid-template-columns: 240px 1fr; gap: clamp(28px, 5vw, 56px); align-items: start; }
.hero-photo {
  width: 240px; aspect-ratio: 1; border-radius: 20px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.hero-photo img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 { margin-bottom: 8px; }
.hero .position { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0 0 2px; }
.hero .affiliation { color: var(--text-muted); margin: 0 0 16px; }
.hero .headline {
  font-family: var(--serif); font-style: italic; font-size: 1.12rem; color: var(--navy-2);
  border-left: 3px solid var(--accent); padding-left: 14px; margin: 0 0 18px;
}
.hero .bio { max-width: 66ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 18px; }
.social { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.social a {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted);
  text-decoration: none; font-size: .87rem; font-weight: 550;
}
.social a:hover { color: var(--navy); border-color: var(--border-strong); }
.social .icon { width: 16px; height: 16px; }
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-photo { width: 148px; border-radius: 16px; }
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.stat .value { font-family: var(--serif); font-size: 2.1rem; font-weight: 600; color: var(--navy); line-height: 1; font-variant-numeric: tabular-nums; }
.stat .label { display: block; margin-top: 8px; font-size: .86rem; font-weight: 600; color: var(--text); }
.stat .sub { display: block; font-size: .78rem; color: var(--text-faint); margin-top: 2px; }
.stats-note { font-size: .8rem; color: var(--text-faint); margin: 10px 0 0; }

.focus-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.focus-list a {
  display: flex; align-items: center; gap: 10px; height: 100%; padding: 14px 16px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); color: var(--navy); text-decoration: none;
  font-weight: 600; font-size: .93rem; line-height: 1.35;
}
.focus-list a:hover { border-color: var(--accent); }
.focus-list .icon { width: 22px; height: 22px; color: var(--accent); }

/* ---------- Publications ---------- */
.pub-controls {
  display: grid; grid-template-columns: 1fr auto; gap: 14px 20px; align-items: center;
  padding: 18px; margin-bottom: 28px;
}
.pub-controls .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pub-controls .row-full { grid-column: 1 / -1; }
.search {
  position: relative; flex: 1 1 260px;
}
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); width: 18px; height: 18px; pointer-events: none; }
.input, .select {
  font: inherit; font-size: .93rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; min-height: 42px; padding: 8px 12px;
}
.input { width: 100%; padding-left: 38px; }
.select { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.input:focus, .select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.result-count { font-size: .88rem; color: var(--text-muted); }
@media (max-width: 760px) {
  .pub-controls { grid-template-columns: 1fr; padding: 14px; }
  .pub-controls .row > label:not(.search) { flex: 1 1 140px; min-width: 0; }
  .pub-controls .select { width: 100%; }
}

.pub-group { margin-bottom: 40px; }
.pub-group > h2 { display: flex; align-items: baseline; gap: 10px; font-size: 1.5rem; padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.pub-group > h2 .count { font-family: var(--sans); font-size: .85rem; color: var(--text-faint); font-weight: 500; }
.pub-list { list-style: none; margin: 0; padding: 0; }
.pub {
  display: grid; grid-template-columns: 52px 1fr; gap: 4px 14px;
  padding: 20px 0; border-bottom: 1px solid var(--border);
}
.pub:last-child { border-bottom: 0; }
.pub:target { background: var(--accent-soft); border-radius: var(--radius-sm); }
.pub-num { font-family: var(--mono); font-size: .8rem; color: var(--text-faint); padding-top: 4px; }
.pub-title { font-family: var(--serif); font-size: 1.12rem; font-weight: 600; color: var(--navy); margin: 0 0 4px; line-height: 1.35; }
.pub-authors { margin: 0 0 3px; font-size: .95rem; color: var(--text-muted); }
.pub-authors .me { color: var(--text); font-weight: 700; }
.pub-venue { margin: 0 0 10px; font-size: .95rem; }
.pub-venue em { font-family: var(--serif); font-size: 1.02rem; }
.pub-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.pub-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bibtex {
  margin: 12px 0 0; position: relative;
}
.bibtex pre {
  margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto;
  background: var(--surface-2); border: 1px solid var(--border); font-family: var(--mono); font-size: .8rem; line-height: 1.55; color: var(--text);
}
.bibtex .btn-sm { position: absolute; top: 8px; right: 8px; }
@media (max-width: 560px) { .pub { grid-template-columns: 1fr; } .pub-num { padding: 0; } }

.latest-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.latest-item { display: grid; grid-template-columns: 64px 1fr; gap: 16px; align-items: start; }
.latest-year { font-family: var(--serif); font-weight: 600; font-size: 1.25rem; color: var(--accent); padding-top: 2px; }
.latest-item .pub-title { font-size: 1.05rem; }
.latest-item .pub-title a { color: inherit; text-decoration: none; }
.latest-item .pub-title a:hover { color: var(--accent); }

/* ---------- Research ---------- */
.theme-card { display: flex; flex-direction: column; gap: 14px; }
.theme-card header { display: flex; gap: 14px; align-items: flex-start; }
.theme-icon {
  display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 12px;
  background: var(--tag-bg); color: var(--navy);
}
.theme-icon .icon { width: 24px; height: 24px; }
.theme-card h3 { margin: 0 0 4px; }
.theme-status { font-size: .82rem; color: var(--text-faint); margin: 0; }
.theme-card p.summary { margin: 0; color: var(--text); }
.theme-figure { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.related h3 { font-family: var(--sans); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); margin: 4px 0 8px; font-weight: 650; }
.related ul { margin: 0; padding-left: 1.1em; font-size: .92rem; }
.related li { margin-bottom: 4px; }
.related li::marker { color: var(--accent); }
.related .yr { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.theme-card .more-link { margin-top: auto; }

.skills-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; }
.skill-group h3 { display: flex; align-items: center; gap: 10px; font-size: 1.08rem; margin-bottom: 12px; }
.skill-group h3 .icon { color: var(--accent); }
.skill-group .tags .tag { font-size: .82rem; padding: 4px 10px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

/* ---------- Projects ---------- */
.project-card { display: flex; flex-direction: column; gap: 10px; }
.project-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.project-period { font-size: .85rem; font-weight: 600; color: var(--text-muted); display: inline-flex; gap: 6px; align-items: center; font-variant-numeric: tabular-nums; }
.project-card h3 { font-size: 1.12rem; margin: 0; line-height: 1.35; }
.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .9rem; }
.kv dt { color: var(--text-faint); font-weight: 550; }
.kv dd { margin: 0; color: var(--text); }
.role-pi { color: var(--accent); font-weight: 650; }
.project-card .tags { margin-top: auto; padding-top: 4px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; list-style: none; margin: 0; padding: 0; }
.timeline::before {
  content: ""; position: absolute; left: 111px; top: 6px; bottom: 6px; width: 2px;
  background: linear-gradient(var(--border-strong), var(--border) 90%, transparent);
}
.tl-year {
  position: relative; display: grid; grid-template-columns: 96px 1fr; gap: 32px; padding: 6px 0 12px;
}
.tl-year-label {
  font-family: var(--serif); font-size: 1.6rem; font-weight: 650; color: var(--navy);
  text-align: right; position: sticky; top: calc(var(--header-h) + 64px); align-self: start; line-height: 1.1;
}
.tl-year-label small { display: block; font-family: var(--sans); font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tl-items { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.tl-item { position: relative; }
.tl-item::before {
  content: ""; position: absolute; left: -26px; top: 22px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--cat, var(--navy)); box-shadow: 0 0 0 4px var(--bg);
}
.tl-card { padding: 16px 20px; border-left: 3px solid var(--cat, var(--navy)); }
.tl-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.tl-cat { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cat, var(--navy)); }
.tl-cat .icon { width: 14px; height: 14px; }
.tl-date { font-size: .8rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.tl-card h3 { font-size: 1.08rem; margin: 0 0 2px; }
.tl-inst { font-size: .9rem; color: var(--text-muted); margin: 0 0 6px; }
.tl-card p.desc { margin: 0; font-size: .94rem; }
.tl-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .86rem; }
.tl-links a { text-decoration: none; display: inline-flex; gap: 5px; align-items: center; }
.tl-links a:hover { text-decoration: underline; }
.cat-education { --cat: #1f5fa8; }
.cat-position { --cat: #4a5a78; }
.cat-research { --cat: #0f7472; }
.cat-publication { --cat: #6d3fa0; }
.cat-conference { --cat: #2d6a4f; }
.cat-award { --cat: #b0521c; }
.cat-patent { --cat: #8c2f4e; }
.cat-certification { --cat: #5b6b2a; }
:root[data-theme="dark"] .cat-education { --cat: #7fb0ec; }
:root[data-theme="dark"] .cat-position { --cat: #a9b6cf; }
:root[data-theme="dark"] .cat-research { --cat: #5fcbc6; }
:root[data-theme="dark"] .cat-publication { --cat: #bc9be6; }
:root[data-theme="dark"] .cat-conference { --cat: #7fcf9f; }
:root[data-theme="dark"] .cat-award { --cat: #eda172; }
:root[data-theme="dark"] .cat-patent { --cat: #e78fac; }
:root[data-theme="dark"] .cat-certification { --cat: #c2d17f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cat-education { --cat: #7fb0ec; }
  :root:not([data-theme="light"]) .cat-position { --cat: #a9b6cf; }
  :root:not([data-theme="light"]) .cat-research { --cat: #5fcbc6; }
  :root:not([data-theme="light"]) .cat-publication { --cat: #bc9be6; }
  :root:not([data-theme="light"]) .cat-conference { --cat: #7fcf9f; }
  :root:not([data-theme="light"]) .cat-award { --cat: #eda172; }
  :root:not([data-theme="light"]) .cat-patent { --cat: #e78fac; }
  :root:not([data-theme="light"]) .cat-certification { --cat: #c2d17f; }
}
@media (max-width: 640px) {
  .timeline::before { left: 7px; }
  .tl-year { grid-template-columns: 1fr; gap: 10px; padding-left: 28px; }
  .tl-year-label { position: static; text-align: left; font-size: 1.35rem; }
  .tl-year-label small { display: inline; margin-left: 8px; }
  .tl-item::before { left: -27px; }
}

/* Simple vertical timeline (education / experience) */
.vt { list-style: none; margin: 0; padding: 0; position: relative; }
.vt > li { position: relative; padding-left: 34px; padding-bottom: 22px; }
.vt > li::before { content: ""; position: absolute; left: 8px; top: 12px; bottom: -12px; width: 2px; background: var(--border); }
.vt > li:last-child::before { display: none; }
.vt > li::after {
  content: ""; position: absolute; left: 2px; top: 22px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.vt .card { padding: 20px 22px; }
.vt-head { display: flex; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; align-items: baseline; }
.vt-head h3 { margin: 0; }
.vt-dates { font-size: .88rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.vt-org { margin: 2px 0 8px; color: var(--text-muted); font-size: .95rem; }
.vt ul.bullets { margin: 10px 0 0; padding-left: 1.1em; font-size: .95rem; }
.vt ul.bullets li { margin-bottom: 5px; }
.vt ul.bullets li::marker { color: var(--accent); }

/* ---------- Achievements ---------- */
.award-card { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.award-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.award-icon .icon { width: 24px; height: 24px; }
.award-card h3 { margin: 0 0 2px; font-size: 1.1rem; }
.award-card .year { font-weight: 650; color: var(--accent); font-size: .88rem; }
.award-card p { margin: 4px 0 0; font-size: .93rem; }
.patent-card { display: flex; flex-direction: column; gap: 10px; }
.patent-card h3 { font-size: 1.08rem; margin: 0; line-height: 1.4; }
.patent-card .num { font-family: var(--mono); font-size: .85rem; color: var(--text); }
.patent-card .inventors { font-size: .9rem; color: var(--text-muted); margin: 0; }
.patent-card .inventors .me { color: var(--text); font-weight: 700; }

/* ---------- Map ---------- */
.map-wrap { position: relative; width: 100%; aspect-ratio: 1000 / 394.4; }
.map-land {
  position: absolute; inset: 0; background: var(--map-dot);
  -webkit-mask: url("../assets/images/world-dots.svg") center / 100% 100% no-repeat;
  mask: url("../assets/images/world-dots.svg") center / 100% 100% no-repeat;
}
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.map-svg .pt { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.map-svg .pt-pulse { fill: var(--accent); opacity: .22; }
.map-svg .pt-label { font: 600 13px var(--sans); fill: var(--navy); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.map-svg .arc { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 5; opacity: .7; }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: .9rem; list-style: none; padding: 0; }
.map-legend li { display: flex; gap: 8px; align-items: baseline; }
.map-legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; transform: translateY(1px); }

.conf-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.conf-item { padding: 16px 18px; }
.conf-item .conf-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.conf-item .short { font-family: var(--serif); font-weight: 650; font-size: 1.1rem; color: var(--navy); }
.conf-item .yr { font-weight: 650; color: var(--accent); font-variant-numeric: tabular-nums; }
.conf-item .full { font-size: .86rem; color: var(--text-muted); margin: 2px 0 8px; }
.conf-item ul { margin: 0; padding-left: 1.1em; font-size: .9rem; }
.conf-item .loc { font-size: .84rem; color: var(--text-faint); display: flex; gap: 5px; align-items: center; margin-top: 8px; }

/* ---------- Visitors + GitHub ---------- */
.visitors-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .visitors-grid { grid-template-columns: 1fr; } }
.visitor-total { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; color: var(--navy); line-height: 1; }
.country-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.country-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; font-size: .92rem; }
.country-row .flag { font-size: 1.2rem; line-height: 1; text-align: center; }
.country-row .flag.code { font-size: .65rem; font-weight: 700; border: 1px solid var(--border-strong); border-radius: 3px; padding: 2px 0; color: var(--text-muted); }
.country-row .bar { height: 4px; border-radius: 2px; background: var(--border); margin-top: 4px; overflow: hidden; }
.country-row .bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.country-row .n { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.dev-note { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 16px 18px; color: var(--text-muted); font-size: .9rem; background: var(--surface); }

.gh-stats { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 18px; }
.gh-stats div { font-size: .85rem; color: var(--text-muted); }
.gh-stats strong { display: block; font-family: var(--serif); font-size: 1.6rem; color: var(--navy); line-height: 1.1; }
.repo-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; text-decoration: none; color: inherit; }
.repo-card:hover { color: inherit; }
.repo-card .name { font-weight: 650; color: var(--link); display: flex; align-items: center; gap: 6px; font-size: .95rem; word-break: break-word; }
.repo-card .desc { font-size: .88rem; color: var(--text-muted); margin: 0; }
.repo-card .meta { display: flex; gap: 14px; font-size: .8rem; color: var(--text-faint); margin-top: auto; }
.repo-card .meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- CV / Contact ---------- */
.cv-frame { width: 100%; height: min(88vh, 1100px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); display: block; }
.cv-fallback { padding: 28px; text-align: center; }
@media (max-width: 760px) { .cv-embed { display: none; } }
@media (min-width: 761px) { .cv-mobile-note { display: none; } }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.contact-list a, .contact-list .row {
  display: flex; align-items: center; gap: 14px; padding: 12px 10px; border-radius: 10px; text-decoration: none; color: var(--text);
}
.contact-list a:hover { background: var(--surface-2); color: var(--navy); }
.contact-list .icon { width: 20px; height: 20px; color: var(--navy-2); }
.contact-list .lbl { display: block; font-size: .78rem; color: var(--text-faint); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.contact-list .val { display: block; font-weight: 550; word-break: break-word; }
address { font-style: normal; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 36px 0 44px; margin-top: 40px; font-size: .88rem; color: var(--text-muted); }
.footer-grid { display: flex; justify-content: space-between; gap: 18px; flex-wrap: wrap; align-items: center; }
.footer-grid .social a { padding: 6px 9px; }
.site-footer p { margin: 0; }

/* Reserve space for JSON-rendered content to avoid layout shift */
#pub-root, #timeline-root, #themes-root, #projects-root, #awards-root, #education-root, #latest-list { min-height: 100vh; }
#pub-types, #timeline-filters, #project-filters { min-height: 36px; }
#stats { min-height: 104px; }
#latest-list:not(:empty), #pub-root:not(:empty), #timeline-root:not(:empty), #themes-root:not(:empty),
#projects-root:not(:empty), #awards-root:not(:empty), #education-root:not(:empty) { min-height: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--navy); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: .9rem; font-weight: 550;
  z-index: 300; transition: opacity .2s ease, transform .2s ease; pointer-events: none; box-shadow: var(--shadow-hover);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Reveal animation (subtle) ---------- */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Print ---------- */
@media print {
  .site-header, .subnav, .site-footer, .pub-controls, .pub-actions, .theme-toggle, .hero-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
}
