/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #efede6;
  --ink: #16181d;
  --ink-2: #4a4f5a;
  --ink-3: #7b808a;
  --line: #e2dfd6;
  --accent: #1f3a8a;
  --accent-ink: #ffffff;
  --accent-soft: #e6eaf7;
  --live: #15803d;

  --drug: #2563eb;
  --dose: #7c3aed;
  --indication: #0f766e;
  --adr: #dc2626;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 8px 24px -12px rgba(22, 24, 29, 0.12);
  --shadow-lg: 0 2px 4px rgba(22, 24, 29, 0.04), 0 24px 48px -20px rgba(22, 24, 29, 0.25);
  --nav-h: 68px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1d2128;
    --ink: #eceae4;
    --ink-2: #b4b7be;
    --ink-3: #868a93;
    --line: #2a2e37;
    --accent: #8fa8ff;
    --accent-ink: #0f1115;
    --accent-soft: #1d2540;
    --live: #4ade80;
    --drug: #60a5fa;
    --dose: #a78bfa;
    --indication: #2dd4bf;
    --adr: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 48px -20px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1d2128;
  --ink: #eceae4;
  --ink-2: #b4b7be;
  --ink-3: #868a93;
  --line: #2a2e37;
  --accent: #8fa8ff;
  --accent-ink: #0f1115;
  --accent-soft: #1d2540;
  --live: #4ade80;
  --drug: #60a5fa;
  --dose: #a78bfa;
  --indication: #2dd4bf;
  --adr: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 48px -20px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 600; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; }
strong { font-weight: 600; color: var(--ink); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.fill { fill: currentColor; stroke: none; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 14px; border-radius: 8px; transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--nav-h);
  transition: background-color 0.3s, border-color 0.3s, backdrop-filter 0.3s;
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: var(--line);
}
.nav__inner { height: 100%; display: flex; align-items: center; gap: 24px; }
.nav__brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.nav__brand:hover { text-decoration: none; }
.nav__mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: var(--bg);
  font-family: var(--font-display); font-size: 15px; letter-spacing: 0.02em;
}
.nav__links { margin-left: auto; display: flex; gap: 4px; }
.nav__links a {
  color: var(--ink-2); font-size: 14.5px; font-weight: 500; white-space: nowrap;
  padding: 8px 12px; border-radius: 8px; transition: color 0.2s, background-color 0.2s;
}
.nav__links a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav__links a.is-active { color: var(--ink); background: var(--surface-2); }
@media (max-width: 1100px) { .nav__inner { gap: 12px; } .nav__links { gap: 0; } .nav__links a { padding: 8px 9px; font-size: 14px; } }
.nav__actions { display: flex; gap: 6px; margin-left: auto; }
.nav__links + .nav__actions { margin-left: 0; }
@media (max-width: 1080px) { .nav__links + .nav__actions { margin-left: auto; } }

.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.icon-btn:hover { border-color: var(--ink-3); }
.icon-btn svg { width: 18px; height: 18px; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

.nav__burger { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.nav__burger span { display: block; width: 16px; height: 1.6px; background: currentColor; border-radius: 2px; transition: transform 0.25s var(--ease); }
.nav__burger[aria-expanded="true"] span:first-child { transform: translateY(3.3px) rotate(45deg); }
.nav__burger[aria-expanded="true"] span:last-child { transform: translateY(-3.3px) rotate(-45deg); }

/* ==========================================================================
   Buttons, pills, tags
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 20px; border-radius: 8px;
  font-size: 15px; font-weight: 500; line-height: 1;
  border: 1px solid transparent;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--ink); color: var(--bg); }
.btn--primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--bg)); }
.btn--ghost { color: var(--ink); border-color: var(--line); background: var(--surface); }
.btn--ghost:hover { border-color: var(--ink-3); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2);
}
.pill--live { background: var(--accent-soft); color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin-top: 14px; }
.tags li {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2);
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 6px;
}

.link-arrow { font-weight: 500; font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.link-arrow::after { content: "→"; transition: transform 0.2s var(--ease); }
.link-arrow:hover::after, .award:hover .link-arrow::after { transform: translateX(3px); }

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  min-height: min(100vh, 900px);
  display: grid; grid-template-columns: 1.25fr 1fr; align-items: center; gap: 64px;
  padding-top: calc(var(--nav-h) + 48px); padding-bottom: 48px;
}
.hero__title {
  margin-top: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(48px, 8vw, 92px);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 28px;
}
.hero__lead { font-size: clamp(18px, 2vw, 21px); color: var(--ink-2); max-width: 34em; line-height: 1.55; }
.hero__meta { font-size: 15px; color: var(--ink-3); max-width: 34em; }
.hero__cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 32px 0 28px; }

.socials { display: flex; gap: 8px; list-style: none; }
.socials a {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px;
  color: var(--ink-2); border: 1px solid var(--line); transition: color 0.2s, border-color 0.2s;
}
.socials a:hover { color: var(--ink); border-color: var(--ink-3); }
.socials svg { width: 18px; height: 18px; }

.hero__portrait { position: relative; margin: 0; justify-self: end; width: 100%; max-width: 420px; }
.hero__portrait img {
  width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; object-position: center 30%;
  border-radius: var(--radius);
  background: var(--surface-2);
}
/* ==========================================================================
   Sections
   ========================================================================== */
.section { padding-top: 120px; }
.section__head { margin-bottom: 40px; max-width: 760px; }
.section__head h2, .contact h2 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(32px, 4.4vw, 48px); letter-spacing: -0.02em;
}

/* About */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 64px; align-items: start; }
.about__text p { color: var(--ink-2); font-size: 18px; }
.about__focus { padding-top: 4px; }
.about__focus h3 { font-size: 15px; color: var(--ink-3); font-weight: 500; margin-bottom: 8px; }
.focus-list { list-style: none; }
.focus-list li { padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 500; }

/* Experience timeline */
.timeline { list-style: none; position: relative; }
.job {
  display: grid; grid-template-columns: 200px 1fr; gap: 40px;
  padding: 32px 0; border-top: 1px solid var(--line); position: relative;
}
.job:last-child { border-bottom: 1px solid var(--line); }
.job__when { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 4px; }
.job__body h3 { font-size: 22px; letter-spacing: -0.01em; margin-bottom: 4px; }
.job__org { color: var(--accent); font-weight: 500; font-size: 15px; margin-bottom: 14px; }
.job__body > p:not(.job__org) { color: var(--ink-2); }
.job__points { list-style: none; display: grid; gap: 8px; }
.job__points li { position: relative; padding-left: 20px; color: var(--ink-2); font-size: 16px; }
.job__points li::before { content: ""; position: absolute; left: 2px; top: 0.72em; width: 7px; height: 1.6px; background: var(--ink-3); }

/* Thesis */
.thesis {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 40px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px;
}
.thesis__main > p:not(.thesis__title):not(.thesis__meta) { color: var(--ink-2); }
.thesis__grade {
  float: right; margin: 0 0 16px 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 104px; height: 104px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
}
.thesis__grade-num { font-family: var(--font-display); font-size: 38px; line-height: 1; font-weight: 600; }
.thesis__grade-lbl { font-size: 11px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; margin-top: 4px; }
.thesis__title { font-family: var(--font-display); font-size: 22px; line-height: 1.35; margin-bottom: 8px; }
.thesis__meta { font-size: 14px; color: var(--ink-3); margin-bottom: 20px; }
.thesis__findings { list-style: none; display: grid; gap: 10px; margin: 20px 0 6px; clear: both; }
.thesis__findings li { position: relative; padding-left: 20px; font-size: 16px; color: var(--ink-2); }
.thesis__findings li::before { content: ""; position: absolute; left: 2px; top: 0.72em; width: 7px; height: 1.6px; background: var(--ink-3); }

/* NER illustration */
.ner {
  position: sticky; top: calc(var(--nav-h) + 24px);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.ner__bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ner__file { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.ner__replay {
  margin-left: auto; font: 500 12.5px var(--font-body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; cursor: pointer;
}
.ner__replay:hover { border-color: var(--ink-3); }
.ner__text { padding: 24px 22px 8px; font-family: var(--font-mono); font-size: 14.5px; line-height: 2.9; color: var(--ink-2); margin: 0; }
.ner__text mark {
  --c: var(--ink-3);
  position: relative; color: inherit; background: transparent;
  padding: 3px 4px; border-radius: 5px;
  transition: background-color 0.4s, color 0.4s, box-shadow 0.4s;
}
.ner__text mark::after {
  content: attr(data-label);
  position: absolute; left: 0; top: -1.15em;
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.05em; line-height: 1;
  color: var(--c); opacity: 0; transform: translateY(4px);
  transition: opacity 0.35s, transform 0.35s var(--ease);
  white-space: nowrap;
}
.ner__text mark[data-label="DRUG"], .ner__legend [data-label="DRUG"] { --c: var(--drug); }
.ner__text mark[data-label="DOSE"], .ner__legend [data-label="DOSE"] { --c: var(--dose); }
.ner__text mark[data-label="INDICATION"], .ner__legend [data-label="INDICATION"] { --c: var(--indication); }
.ner__text mark[data-label="ADR"], .ner__legend [data-label="ADR"] { --c: var(--adr); }
.ner__text mark.is-on {
  color: var(--ink);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: inset 0 -2px 0 var(--c);
}
.ner__text mark.is-on::after { opacity: 1; transform: none; }
.ner__legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 12px 22px; border-top: 1px dashed var(--line); }
.ner__legend li { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.ner__legend li::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.ner__note { font-size: 12px; color: var(--ink-3); padding: 0 22px 14px; margin: 0; }

/* Education */
.edu { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.edu__card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; display: flex; flex-direction: column; align-items: flex-start;
}
.edu__card h3 { font-size: 19px; margin: 16px 0 4px; }
.edu__org { color: var(--accent); font-weight: 500; font-size: 14.5px; margin-bottom: 10px; }
.edu__card p:last-child { color: var(--ink-2); font-size: 15px; margin: 0; }

/* Projects */
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.project {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color 0.2s;
}
.project:hover { border-color: var(--ink-3); }
.project__img { aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.project__img img { width: 100%; height: 100%; object-fit: cover; }
.project__body { padding: 22px 24px 24px; display: flex; flex-direction: column; flex: 1; }
.project__date { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.project__body h3 { font-size: 20px; margin: 6px 0 10px; }
.project__body p { color: var(--ink-2); font-size: 15.5px; }
.project__body .tags { margin: auto 0 18px; padding-top: 4px; }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.skills-row { margin-top: 16px; }
.skill-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.skill-group h3 { font-size: 15px; margin-bottom: 16px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  font-size: 14px; padding: 5px 10px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink);
}
.langs { list-style: none; display: flex; flex-wrap: wrap; gap: 12px 48px; }
.langs li { display: flex; flex-direction: column; font-size: 15px; font-weight: 500; }
.langs li span:last-child { color: var(--ink-3); font-size: 14px; font-weight: 400; }
.hobbies { margin-top: 24px; color: var(--ink-3); font-size: 15px; }
.hobbies span { color: var(--ink-2); }

/* Awards */
.awards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.award {
  display: flex; flex-direction: column; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; color: var(--ink);
  transition: border-color 0.2s;
}
.award:hover { text-decoration: none; border-color: var(--ink-3); }
.award__date { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.award h3 { font-size: 19px; margin: 4px 0 6px; }
.award p { color: var(--ink-2); font-size: 15px; margin-bottom: 18px; }
.award .link-arrow { margin-top: auto; color: var(--accent); }

/* Contact */
.contact {
  display: grid; grid-template-columns: 1fr 1.4fr; gap: 64px;
  border-top: 1px solid var(--line); padding-top: 48px;
}
.contact h2 { margin-bottom: 12px; }
.contact__intro p { color: var(--ink-2); }
.contact__list { margin: 0; }
.contact__list div { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.contact__list div:first-child { padding-top: 0; }
.contact__list dt { color: var(--ink-3); font-size: 15px; }
.contact__list dd { margin: 0; font-weight: 500; }

/* Footer */
.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px;
  padding-top: 48px; padding-bottom: 40px; font-size: 14px; color: var(--ink-3);
}
.footer p { margin: 0; }
.footer__top { color: var(--ink-2); }

/* ==========================================================================
   Motion
   ========================================================================== */
.js .reveal { opacity: 0; transform: translateY(10px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); transition-delay: var(--d, 0s); }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1080px) {
  .nav__links {
    position: fixed; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px 16px 20px;
    background: var(--bg); border-bottom: 1px solid var(--line);
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: opacity 0.2s, transform 0.2s var(--ease), visibility 0.2s;
  }
  .nav__links.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav__links a { padding: 12px 12px; font-size: 16px; border-radius: 10px; }
  .nav__burger { display: flex; }
  .nav { background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

}

@media (max-width: 1020px) {
  .hero { grid-template-columns: 1fr; gap: 48px; min-height: 0; padding-top: calc(var(--nav-h) + 40px); }
  .hero__portrait { justify-self: start; max-width: 340px; order: -1; }
  .about { grid-template-columns: 1fr; gap: 32px; }
  .ner { position: static; }
  .thesis { grid-template-columns: 1fr; }
  .edu, .skills { grid-template-columns: repeat(2, 1fr); }
  .projects { grid-template-columns: repeat(2, 1fr); }
  .contact { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .wrap { padding-left: 16px; padding-right: 16px; }
  .section { padding-top: 88px; }
  .section__head { margin-bottom: 32px; }
  .hero__portrait { max-width: 260px; }
  .job { grid-template-columns: 1fr; gap: 10px; padding: 28px 0; }
  .job__when { flex-direction: row; align-items: center; }
  .thesis { padding: 24px 20px; }
  .thesis__grade { width: 84px; height: 84px; margin-left: 16px; }
  .thesis__grade-num { font-size: 30px; }
  .ner__text { font-size: 13px; padding: 22px 16px 6px; }
  .ner__legend, .ner__note { padding-left: 16px; padding-right: 16px; }
  .edu, .skills, .projects, .awards { grid-template-columns: 1fr; }
  .contact__list div { grid-template-columns: 1fr; gap: 2px; }
  .footer { flex-direction: column; align-items: flex-start; }
}

.job__org a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; transition: text-decoration-color 0.2s; }
.job__org a:hover { text-decoration-color: currentColor; }

.lang-btn { font: 600 12.5px var(--font-body); letter-spacing: 0.04em; }
