:root {
  --accent: #0065c0;
  --accent-hover: #e07818;
  --text: #171a1f;
  --muted: #4f5863;
  --faint: #737d88;
  --border: #e0e4e8;
  --surface: #fff;
  --code: #f5f7f9;
  --max-width: 820px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --accent: #76adf1;
  --accent-hover: #f1a356;
  --text: #e7e8ea;
  --muted: #c2c6cc;
  --faint: #9ba2ab;
  --border: #3d4249;
  --surface: #1d1f22;
  --code: #272a2f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background: var(--surface);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.72;
  letter-spacing: -.005em;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; transition: color .16s ease; }
a:hover { color: var(--accent-hover); }

.skip-link { position: fixed; left: 1rem; top: -4rem; padding: .5rem .8rem; background: var(--accent); color: white; z-index: 20; }
.skip-link:focus { top: 1rem; }

.page-shell {
  display: grid;
  grid-template-columns: 210px minmax(0, 820px);
  align-items: start;
  gap: 56px;
  width: min(calc(100% - 48px), 1086px);
  margin-inline: auto;
}

.site-main { width: 100%; min-width: 0; }
.site-footer { width: min(calc(100% - 48px), 1086px); margin-inline: auto; }

.site-header { width: 100%; padding: 0 0 32px; }

.site-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  padding: 20px 35px;
  flex-wrap: wrap;
}

.nav-link,
.theme-toggle {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  padding: 6px 12px;
}

.nav-link { position: relative; font-weight: 500; transition: all .25s ease; }
.nav-link:hover { color: var(--accent-hover); background: color-mix(in srgb, var(--accent-hover) 8%, transparent); }
.nav-link.is-active { color: var(--accent-hover); font-weight: 600; }
.nav-link.is-active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 60%;
  height: 2px;
  border-radius: 1px;
  background: var(--accent-hover);
  transform: translateX(-50%);
}
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 6px;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: all .2s ease;
}
.theme-toggle:hover { color: var(--accent-hover); background: color-mix(in srgb, var(--accent-hover) 8%, transparent); }
.theme-toggle svg { width: 20px; height: 20px; }
.sun-icon { display: none; }
:root[data-theme="dark"] .moon-icon { display: none; }
:root[data-theme="dark"] .sun-icon { display: block; }

.site-main { min-height: calc(100vh - 230px); }

.profile-sidebar {
  position: sticky;
  top: 28px;
  color: var(--muted);
  font-size: 14px;
}

.sidebar-photo {
  display: block;
  width: 168px;
  height: 168px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 50%;
  object-fit: cover;
}

.profile-sidebar h2 { margin: 0; color: var(--text); font-size: 20px; font-weight: 650; line-height: 1.3; letter-spacing: -.015em; }
.sidebar-role { margin: 3px 0 12px; color: var(--faint); font-size: 13px; }
.sidebar-affiliation { margin: 0 0 16px; line-height: 1.5; }
.sidebar-links { list-style: none; margin: 0; padding: 0; }
.sidebar-links li { margin: 7px 0; }
.sidebar-links a { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.sidebar-links a:hover { color: var(--accent); }
.sidebar-links svg {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.intro { margin: 0 0 36px; }
.intro h1 { margin: 0 0 12px; font-size: 30px; font-weight: 700; line-height: 1.25; letter-spacing: -.025em; }
.intro p { margin: 0 0 12px; color: var(--muted); }

.profile { display: flex; align-items: flex-start; gap: 34px; margin: 2px 0 42px; }
.profile-copy { flex: 1; }
.profile h1 { margin: 0 0 1px; font-size: 30px; line-height: 1.2; letter-spacing: -.02em; }
.role { margin: 0 0 18px; color: var(--faint); font-size: 13px; }
.bio { margin: 0 0 14px; color: var(--muted); }
.profile-links { margin: 0; font-size: 14px; }
.profile-links span { color: var(--faint); margin-inline: 5px; }
.profile-photo { width: 160px; height: 160px; object-fit: cover; border: 1px solid var(--border); box-shadow: 0 4px 12px rgb(0 0 0 / 8%); }

.home-section { margin: 0 0 32px; }
.home-section h2,
.section-heading h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .075em; text-transform: uppercase; }
.home-section > h2,
.section-heading { padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; }
.section-heading > a { font-size: 12px; }

.compact-list { margin: 11px 0 0; padding-left: 20px; color: var(--muted); }
.compact-list li { margin: 2px 0; }

.featured-publication { padding: 13px 0 2px; }
.featured-publication p { margin: 2px 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.featured-publication .publication-title { color: var(--text); font-size: 16px; font-weight: 620; }
.home-cv-link { margin: 42px 0 0; font-size: 14px; }

.vulnerability-list { list-style: none; margin: 11px 0 0; padding: 0; }
.vulnerability-list li { display: grid; grid-template-columns: 205px 1fr; gap: 18px; padding: 7px 0; }
.vulnerability-list strong { color: var(--text); font-size: 14px; }
.vulnerability-list strong span { color: var(--faint); font-weight: 400; }
.vulnerability-list p { margin: 0; color: var(--muted); font-size: 14px; }

.expandable-list.is-collapsed > .expandable-item:nth-child(n + 4) { display: none; }
.expandable-list:not(.is-collapsed) > .expandable-item:nth-child(n + 4) { animation: reveal-item .2s ease both; }
.expand-button {
  margin: 11px 0 0;
  padding: 4px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.expand-button:hover { color: var(--accent-hover); border-bottom-color: currentColor; }
.expand-button::after { content: " ↓"; }
.expand-button[aria-expanded="true"]::after { content: " ↑"; }

@keyframes reveal-item {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.writing-list { list-style: none; margin: 8px 0 0; padding: 0; }
.writing-list li { display: grid; grid-template-columns: 96px 1fr; gap: 16px; padding: 7px 0; }
.writing-list time { color: var(--faint); font-size: 13px; padding-top: 2px; }
.writing-title { color: var(--text); font-weight: 620; line-height: 1.5; }
.writing-title:hover { color: var(--accent); }
.writing-list p { margin: 0; color: var(--faint); font-size: 13px; }

.timeline-row { display: grid; grid-template-columns: 128px 1fr; gap: 18px; padding-top: 12px; }
.timeline-row > span { color: var(--faint); font-size: 13px; }
.timeline-row p { margin: 0; color: var(--muted); }
.timeline-row strong { color: var(--text); }

.page-header { margin-bottom: 30px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.page-header h1 { margin: 0; font-size: 25px; }
.page-header p { margin: 4px 0 0; color: var(--muted); }

.post { max-width: 760px; margin-inline: auto; }
.back-link { display: inline-block; margin-bottom: 18px; font-size: 13px; }
.post-header { margin-bottom: 34px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.post-header h1 { margin: 0 0 12px; font-size: clamp(28px, 5vw, 40px); line-height: 1.18; letter-spacing: -.025em; }
.post-meta { display: flex; gap: 10px; color: var(--faint); font-size: 13px; }
.post-meta span::before { content: "·"; margin-right: 10px; }

.prose { color: var(--muted); line-height: 1.78; }
.prose h2, .prose h3, .prose h4 { color: var(--text); line-height: 1.3; scroll-margin-top: 20px; }
.prose h2 { margin-top: 2.3em; font-size: 24px; }
.prose h3 { margin-top: 1.8em; font-size: 19px; }
.prose p { margin: 1em 0; }
.prose strong { color: var(--text); }
.prose img { max-width: 100%; height: auto; }
.prose blockquote { margin: 1.5em 0; padding: .1em 1.1em; border-left: 3px solid var(--accent); }
.prose code { padding: .14em .34em; border-radius: 3px; background: var(--code); font-family: "SFMono-Regular", Consolas, monospace; font-size: .88em; color: var(--text); }
.prose pre { overflow: auto; margin: 1.5em 0; padding: 18px; border: 1px solid var(--border); border-radius: 4px; background: var(--code); font-size: 13px; line-height: 1.55; }
.prose pre code { padding: 0; background: transparent; }
.prose hr { border: 0; border-top: 1px solid var(--border); }
.prose table { display: block; overflow-x: auto; width: 100%; border-collapse: collapse; }
.prose th, .prose td { padding: 8px 10px; border: 1px solid var(--border); }

/* Rouge renders numbered code blocks as a table inside a pre element. */
.prose .highlighter-rouge { margin: 1.5em 0; }
.prose .highlighter-rouge .highlight {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--code);
}
.prose .highlighter-rouge .highlight > pre.highlight {
  overflow-x: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.prose .rouge-table {
  display: table;
  width: max-content;
  min-width: 100%;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  background: transparent;
}
.prose .rouge-table td {
  padding: 0;
  border: 0;
  vertical-align: top;
}
.prose .rouge-table pre {
  overflow: visible;
  margin: 0;
  padding: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: pre;
}
.prose .rouge-table .rouge-gutter {
  width: 1%;
  border-right: 1px solid var(--border);
  color: var(--faint);
  text-align: right;
  user-select: none;
}
.prose .rouge-table .rouge-gutter pre { padding-right: 11px; padding-left: 11px; }
.prose .rouge-table .rouge-code { width: 99%; }
.prose .rouge-table .rouge-code pre { padding-left: 15px; }

/* Compact syntax palette with sufficient contrast in both themes. */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cp, .highlight .cs { color: #6a737d; font-style: italic; }
.highlight .k, .highlight .kc, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt { color: #9c36b5; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .se, .highlight .sh, .highlight .si, .highlight .sx { color: #1769aa; }
.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .mo, .highlight .il { color: #b15c00; }
.highlight .na, .highlight .nb, .highlight .nc, .highlight .nf, .highlight .nn, .highlight .nt { color: #005cc5; }
.highlight .o, .highlight .ow { color: #444d56; }
.highlight .err, .highlight .gd { color: #b31d28; }
.highlight .gi { color: #22863a; }

:root[data-theme="dark"] .highlight .c,
:root[data-theme="dark"] .highlight .c1,
:root[data-theme="dark"] .highlight .cm,
:root[data-theme="dark"] .highlight .cp,
:root[data-theme="dark"] .highlight .cs { color: #8b949e; }
:root[data-theme="dark"] .highlight .k,
:root[data-theme="dark"] .highlight .kc,
:root[data-theme="dark"] .highlight .kd,
:root[data-theme="dark"] .highlight .kn,
:root[data-theme="dark"] .highlight .kp,
:root[data-theme="dark"] .highlight .kr,
:root[data-theme="dark"] .highlight .kt { color: #d2a8ff; }
:root[data-theme="dark"] .highlight .s,
:root[data-theme="dark"] .highlight .s1,
:root[data-theme="dark"] .highlight .s2,
:root[data-theme="dark"] .highlight .sb,
:root[data-theme="dark"] .highlight .sc,
:root[data-theme="dark"] .highlight .sd,
:root[data-theme="dark"] .highlight .se,
:root[data-theme="dark"] .highlight .sh,
:root[data-theme="dark"] .highlight .si,
:root[data-theme="dark"] .highlight .sx { color: #a5d6ff; }
:root[data-theme="dark"] .highlight .m,
:root[data-theme="dark"] .highlight .mb,
:root[data-theme="dark"] .highlight .mf,
:root[data-theme="dark"] .highlight .mh,
:root[data-theme="dark"] .highlight .mi,
:root[data-theme="dark"] .highlight .mo,
:root[data-theme="dark"] .highlight .il { color: #ffa657; }
:root[data-theme="dark"] .highlight .na,
:root[data-theme="dark"] .highlight .nb,
:root[data-theme="dark"] .highlight .nc,
:root[data-theme="dark"] .highlight .nf,
:root[data-theme="dark"] .highlight .nn,
:root[data-theme="dark"] .highlight .nt { color: #79c0ff; }
:root[data-theme="dark"] .highlight .o,
:root[data-theme="dark"] .highlight .ow { color: #c9d1d9; }

.empty-state { margin-top: 38px; padding: 28px; border: 1px solid var(--border); color: var(--muted); text-align: center; }
.empty-state p { margin: 0; }

.cv-section { margin: 0 0 34px; }
.cv-section h2 { padding-bottom: 6px; border-bottom: 1px solid var(--border); font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
.cv-item { display: grid; grid-template-columns: 135px 1fr; gap: 20px; margin: 14px 0; }
.cv-item time { color: var(--faint); font-size: 13px; }
.cv-item p { margin: 0; color: var(--muted); }
.cv-item strong { color: var(--text); }

.site-footer { margin-top: 70px; padding: 28px 0 38px; border-top: 1px solid var(--border); color: var(--faint); font-size: 12px; text-align: center; }
.footer-links { display: flex; justify-content: center; gap: 18px; margin-bottom: 7px; }
.site-footer p { margin: 0; }

@media (max-width: 860px) {
  .page-shell { grid-template-columns: 180px minmax(0, 1fr); gap: 32px; }
  .sidebar-photo { width: 145px; height: 145px; }
}

@media (max-width: 640px) {
  .page-shell { display: block; width: min(calc(100% - 32px), var(--max-width)); }
  .profile-sidebar { position: static; display: grid; grid-template-columns: 96px 1fr; column-gap: 18px; margin-bottom: 38px; }
  .sidebar-photo { grid-row: 1 / span 4; width: 96px; height: 96px; margin: 0; }
  .profile-sidebar h2 { align-self: end; }
  .sidebar-role { margin-bottom: 3px; }
  .sidebar-affiliation { margin-bottom: 0; font-size: 13px; }
  .sidebar-links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 14px; }
  .sidebar-links li { margin: 0; }
  .site-footer { width: min(calc(100% - 32px), var(--max-width)); }
  .site-header { padding-bottom: 28px; }
  .site-nav { justify-content: center; gap: 7px 10px; padding: 12px 16px; }
  .nav-link { padding: 8px 10px; font-size: 15px; }
  .theme-toggle { order: -1; width: 32px; height: 32px; }
  .theme-toggle svg { width: 18px; height: 18px; }
  .profile { flex-direction: column-reverse; align-items: center; gap: 20px; }
  .profile-copy { width: 100%; }
  .profile h1, .role, .profile-links { text-align: center; }
  .profile-photo { width: 145px; height: 145px; }
  .writing-list li { grid-template-columns: 72px 1fr; gap: 10px; }
  .timeline-row, .cv-item { grid-template-columns: 1fr; gap: 2px; }
  .vulnerability-list li { grid-template-columns: 1fr; gap: 0; }
}
