/* ---------- Tokens ---------- */
:root {
  --bg: #0b0e13;
  --bg-2: #10141b;
  --surface: #151a22;
  --surface-2: #1b212b;
  --text: #eef1f5;
  --text-2: #b6bec9;
  --muted: #7d8794;
  --line: #232b36;
  --line-2: #2e3743;
  --accent: #ffb454;
  --accent-2: #62d4c6;
  --accent-ink: #1a1207;
  --glow-1: rgba(255, 180, 84, 0.22);
  --glow-2: rgba(98, 212, 198, 0.18);
  --shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 20px 40px -20px rgba(0,0,0,0.6);
  --radius: 16px;
  --max: 1040px;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f7f5f0;
    --bg-2: #f1eee7;
    --surface: #ffffff;
    --surface-2: #f4f1ea;
    --text: #17191d;
    --text-2: #3f454d;
    --muted: #6b7380;
    --line: #e4e0d6;
    --line-2: #d6d1c5;
    --accent: #d97a06;
    --accent-2: #0f8f82;
    --accent-ink: #ffffff;
    --glow-1: rgba(217, 122, 6, 0.16);
    --glow-2: rgba(15, 143, 130, 0.14);
    --shadow: 0 1px 2px rgba(20,20,20,0.04), 0 16px 32px -20px rgba(20,20,20,0.18);
  }
}
:root[data-theme="light"] {
  --bg: #f7f5f0;
  --bg-2: #f1eee7;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --text: #17191d;
  --text-2: #3f454d;
  --muted: #6b7380;
  --line: #e4e0d6;
  --line-2: #d6d1c5;
  --accent: #d97a06;
  --accent-2: #0f8f82;
  --accent-ink: #ffffff;
  --glow-1: rgba(217, 122, 6, 0.16);
  --glow-2: rgba(15, 143, 130, 0.14);
  --shadow: 0 1px 2px rgba(20,20,20,0.04), 0 16px 32px -20px rgba(20,20,20,0.18);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
p { margin: 0 0 14px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
strong { font-weight: 600; }

/* Background texture */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0);
  background-size: 28px 28px;
  opacity: 0.45;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.25) 40%, rgba(0,0,0,0.25));
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.25) 40%, rgba(0,0,0,0.25));
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(700px 420px at 15% -5%, var(--glow-1), transparent 60%),
    radial-gradient(600px 380px at 90% 5%, var(--glow-2), transparent 60%);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 0;
}
.nav .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  box-shadow: var(--shadow);
}
.nav .brand { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.nav .brand i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--glow-1); }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav ul::-webkit-scrollbar { display: none; }
.nav li a {
  display: block; padding: 7px 12px; border-radius: 999px;
  font-size: 13.5px; color: var(--text-2); white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav li a:hover, .nav li a.active { background: var(--surface-2); color: var(--text); }
.theme {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); cursor: pointer; display: grid; place-items: center; flex: none;
}
.theme svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme .sun { display: none; }
:root[data-theme="light"] .theme .sun { display: block; }
:root[data-theme="light"] .theme .moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme .sun { display: block; }
  :root:not([data-theme="dark"]) .theme .moon { display: none; }
}

/* ---------- Hero ---------- */
.hero { padding: 72px 0 40px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 40px; align-items: center; }
.status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em; color: var(--text-2);
}
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 0 var(--accent-2); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 55%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(44px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: -0.035em;
  margin: 18px 0 16px;
  font-weight: 700;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .tag {
  font-size: 20px; line-height: 1.5; color: var(--text-2); max-width: 560px; margin-bottom: 26px;
}
.hero .tag b { color: var(--text); font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--text); font-size: 14px; font-weight: 500;
  transition: transform .15s, border-color .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

.portrait { position: relative; justify-self: end; }
.portrait img {
  width: 260px; height: 260px; object-fit: cover; object-position: 50% 28%;
  border-radius: 28px; display: block;
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.7);
}
.portrait::before {
  content: ""; position: absolute; inset: -14px; z-index: -1; border-radius: 36px;
  background: conic-gradient(from 200deg, var(--accent), var(--accent-2), transparent 70%);
  opacity: 0.35; filter: blur(22px);
}
.portrait .chip {
  position: absolute; left: -18px; bottom: 22px;
  padding: 8px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); letter-spacing: 0.03em;
}
.portrait .chip b { color: var(--accent-2); font-weight: 600; }

/* ---------- Stats ---------- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  margin: 24px 0 8px;
}
.stats > div { background: var(--surface); padding: 18px 20px; }
.stats .n { font-family: var(--font-display); font-size: 32px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.stats .n small { font-size: 18px; color: var(--accent); margin-left: 2px; }
.stats .l { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------- Sections ---------- */
section { padding: 72px 0 8px; }
.sec-head { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 28px; }
.sec-head .mono::before { content: ""; display: inline-block; width: 22px; height: 1px; background: var(--accent); vertical-align: middle; margin-right: 10px; }
.sec-head h2 {
  font-family: var(--font-display); font-size: clamp(28px, 3.6vw, 40px); letter-spacing: -0.03em; line-height: 1.1; margin: 0;
}
.sec-head p.sub { color: var(--text-2); font-size: 17px; max-width: 680px; margin: 8px 0 0; }

/* About */
.about { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 40px; }
.about .lead { font-size: 21px; line-height: 1.5; color: var(--text); font-family: var(--font-display); letter-spacing: -0.01em; }
.about p { color: var(--text-2); }
.facts { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.facts li {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px; align-items: start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  font-size: 14.5px; color: var(--text-2);
}
.facts li b { color: var(--text); }
.facts svg { width: 18px; height: 18px; stroke: var(--accent-2); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-top: 2px; }

/* Pipeline diagram */
.pipeline {
  margin: 8px 0 28px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
}
.pipeline .row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.node {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0; color: var(--text-2); white-space: nowrap;
}
.node.mine { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); color: var(--text); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.arrow { color: var(--muted); font-size: 14px; }
.pipeline .legend { margin-top: 12px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.pipeline .legend i { width: 12px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--line-2)); }

/* Work cards */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 20px 18px; box-shadow: var(--shadow);
  transition: transform .2s, border-color .2s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-2); }
.card::before {
  content: ""; position: absolute; left: 0; top: 0; width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0; transition: opacity .2s;
}
.card:hover::before { opacity: 1; }
.card .idx { font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); letter-spacing: 0.1em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card .idx svg { width: 18px; height: 18px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card h3 { margin: 0 0 10px; font-family: var(--font-display); font-size: 18px; letter-spacing: -0.015em; line-height: 1.25; }
.card p { font-size: 14.5px; color: var(--text-2); margin-bottom: 10px; }
.card .stack { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.stack span, .tags span {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em;
  padding: 4px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2);
}

.callout {
  margin-top: 16px; padding: 18px 22px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent-2) 40%, var(--line));
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-2) 12%, var(--surface)), var(--surface));
  display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center;
}
.callout .big { font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -0.03em; color: var(--accent-2); line-height: 1; }
.callout p { margin: 0; color: var(--text-2); font-size: 15px; }
.callout p b { color: var(--text); }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 175px; top: 8px; bottom: 8px; width: 1px; background: var(--line-2); }
.timeline > li { display: grid; grid-template-columns: 150px 50px 1fr; padding: 18px 0; }
.timeline .when { font-family: var(--font-mono); font-size: 12px; color: var(--muted); padding-top: 4px; letter-spacing: 0.02em; }
.timeline .dot { position: relative; }
.timeline .dot::before {
  content: ""; position: absolute; left: 20px; top: 7px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.timeline h3 { margin: 0; font-family: var(--font-display); font-size: 18px; letter-spacing: -0.01em; }
.timeline .org { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.timeline .org b { color: var(--text-2); font-weight: 500; }
.timeline p { margin: 0; font-size: 15px; color: var(--text-2); }
.timeline ul { margin: 4px 0 0; padding-left: 18px; font-size: 15px; color: var(--text-2); }
.timeline ul li { padding: 2px 0; }
.timeline ul li::marker { color: var(--accent); }

/* Publications */
.pubs { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pubs li {
  display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: start;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  transition: border-color .2s;
}
.pubs li:hover { border-color: var(--line-2); }
.pubs .venue-badge {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.06em; text-align: center;
  padding: 8px 6px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text);
}
.pubs .venue-badge small { display: block; color: var(--muted); font-size: 10.5px; margin-top: 2px; letter-spacing: 0.04em; }
.pubs .title { font-weight: 600; margin: 0 0 3px; font-size: 15.5px; line-height: 1.4; }
.pubs .authors { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.pubs .authors b { color: var(--text-2); font-weight: 500; }
.pubs .out { display: flex; flex-wrap: wrap; gap: 6px; }
.pubs .out a {
  font-family: var(--font-mono); font-size: 11.5px; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--text-2); transition: border-color .15s, color .15s;
}
.pubs .out a:hover { border-color: var(--accent); color: var(--accent); }

/* Education */
.edu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.edu div { padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.edu .mono { margin-bottom: 8px; }
.edu h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 17px; letter-spacing: -0.01em; line-height: 1.3; }
.edu .org { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.edu p { font-size: 14px; color: var(--text-2); margin: 0; }
.edu a { color: var(--accent-2); }
.edu a:hover { text-decoration: underline; }

/* Skills */
.skills { display: grid; grid-template-columns: 140px 1fr; gap: 14px 20px; align-items: start; }
.skills dt { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-top: 6px; }
.skills dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span.hi { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); color: var(--text); }

/* Footer */
footer { margin-top: 72px; padding: 32px 0 48px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
footer a { color: var(--text-2); }
footer a:hover { color: var(--accent); }

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

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .hero { grid-template-columns: 1fr; gap: 28px; padding-top: 48px; }
  .portrait { justify-self: start; }
  .portrait img { width: 200px; height: 200px; }
  .about { grid-template-columns: 1fr; gap: 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .nav .brand span { display: none; }
  .nav .bar { padding: 6px 6px 6px 12px; }
  .cards { grid-template-columns: 1fr; }
  .timeline::before { left: 5px; }
  .timeline > li { grid-template-columns: 1fr; padding-left: 26px; position: relative; }
  .timeline .dot { position: static; }
  .timeline .dot::before { left: 0; top: 24px; }
  .timeline .when { margin-bottom: 4px; }
  .pubs li { grid-template-columns: 1fr; gap: 10px; }
  .pubs .venue-badge { width: max-content; }
  .edu { grid-template-columns: 1fr; }
  .skills { grid-template-columns: 1fr; gap: 6px 0; }
  .skills dd { margin-bottom: 12px; }
  .callout { grid-template-columns: 1fr; gap: 6px; }
  .hero .tag { font-size: 18px; }
  .portrait .chip { left: 8px; bottom: 8px; }
}
