:root {
  --bg: #ffffff;
  --bg-soft: #f5f7fa;
  --text: #17203a;
  --text-soft: #3d4860;
  --muted: #6b7587;
  --border: #e6eaf0;
  --accent: #0b3d91;
  --accent-hover: #1a56c4;
  --accent-soft: #eaf1fc;
  --success: #1f7a4d;
  --success-soft: #e9f6ee;
  --warn: #b35c00;
  --warn-soft: #fff4e6;
  --code-bg: #0f172a;
  --code-head: #1b2436;
  --code-text: #e2e8f0;
  --shadow: 0 1px 2px rgba(23, 32, 58, 0.06), 0 8px 24px -12px rgba(23, 32, 58, 0.12);
  --radius: 12px;
  --radius-sm: 6px;
  --measure: 44rem;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', Consolas, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1220;
    --bg-soft: #151b2c;
    --text: #e7eaf2;
    --text-soft: #c2c8d6;
    --muted: #8f99ad;
    --border: #252d40;
    --accent: #8db4ff;
    --accent-hover: #b4ccff;
    --accent-soft: #1a2542;
    --success: #6fcf97;
    --success-soft: #142a1f;
    --warn: #f2a65a;
    --warn-soft: #2e2113;
    --code-bg: #0a0e1a;
    --code-head: #131a2b;
    --code-text: #e2e8f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1220;
  --bg-soft: #151b2c;
  --text: #e7eaf2;
  --text-soft: #c2c8d6;
  --muted: #8f99ad;
  --border: #252d40;
  --accent: #8db4ff;
  --accent-hover: #b4ccff;
  --accent-soft: #1a2542;
  --success: #6fcf97;
  --success-soft: #142a1f;
  --warn: #f2a65a;
  --warn-soft: #2e2113;
  --code-bg: #0a0e1a;
  --code-head: #131a2b;
  --code-text: #e2e8f0;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text);
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-color: currentColor;
}

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

ul,
ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

li {
  margin: 0.3rem 0;
}

li::marker {
  color: var(--muted);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

strong {
  font-weight: 600;
}

table {
  width: 100%;
  margin: 1rem 0 1.5rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg-soft);
}

.container {
  width: 100%;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--accent);
}

.skip-link:focus {
  top: 0.5rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
}

.brand {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 0.25rem;
}

.site-nav a {
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  margin-left: 0.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-soft);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--bg-soft);
}

.theme-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle .icon-sun {
  display: none;
}

.theme-toggle .icon-moon {
  display: block;
}

.theme-toggle.is-dark .icon-sun {
  display: block;
}

.theme-toggle.is-dark .icon-moon {
  display: none;
}

.hero {
  padding: 4rem 0 2.5rem;
}

.hero h1 {
  margin-bottom: 0.6rem;
}

.hero .tagline {
  max-width: 34rem;
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  line-height: 1.5;
  color: var(--text-soft);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hero-links li {
  margin: 0;
}

.hero-links a {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.hero-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.page-title {
  padding: 3.5rem 0 1.5rem;
}

.page-title h1 {
  margin-bottom: 0.5rem;
}

.page-title .tagline {
  max-width: 36rem;
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-soft);
}

main {
  flex: 1 0 auto;
  padding-bottom: 4rem;
}

.site-footer {
  margin-top: auto;
}

.section {
  padding: 2.25rem 0;
  border-top: 1px solid var(--border);
}

.section:first-child {
  border-top: 0;
}

.section > h2 {
  margin-bottom: 1rem;
}

.section > h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.section > h3:first-of-type {
  margin-top: 0.25rem;
}

.section > p:last-child,
.section > ul:last-child {
  margin-bottom: 0;
}

.inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.inline-list li {
  margin: 0;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--text-soft);
  background: var(--bg-soft);
}

.work-list {
  display: flex;
  flex-direction: column;
}

.university,
.work-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.university:last-child,
.work-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.university:first-child,
.work-item:first-child {
  padding-top: 0;
}

.university img,
.work-item img {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
}

.edu-info,
.work-details {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.edu-info strong,
.work-details strong {
  font-size: 1rem;
  color: var(--text);
}

.edu-info span:not(.date),
.work-details span {
  font-size: 0.95rem;
  color: var(--text-soft);
}

.date {
  font-size: 0.85rem;
  color: var(--muted);
}

.awards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.awards div {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg-soft);
}

.highlight {
  font-weight: 500;
  color: var(--text);
}

.book-meta {
  margin-left: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.countries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.countries img {
  width: 48px;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--border);
  border-radius: 4px;
  object-fit: cover;
  transition: transform 0.15s ease;
}

.countries img:hover {
  transform: translateY(-2px);
}

.contact ul {
  padding: 0;
  list-style: none;
}

.contact li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.contact li:last-child {
  border-bottom: 0;
}

.contact .label {
  flex: 0 0 5.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.contact a {
  font-size: 0.97rem;
}

.site-footer {
  padding: 2rem 0 2.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--accent);
}

.post-list {
  display: flex;
  flex-direction: column;
}

.post-card {
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}

.post-card:first-of-type {
  border-top: 0;
  padding-top: 0.5rem;
}

.post-card h3 {
  margin: 0.35rem 0 0.4rem;
  font-size: 1.25rem;
}

.post-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.post-card h3 a:hover {
  color: var(--accent);
}

.post-card p {
  margin: 0;
  color: var(--text-soft);
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
}

.recent-posts {
  padding: 0;
  list-style: none;
}

.recent-posts li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.recent-posts li:last-child {
  border-bottom: 0;
}

.recent-posts time {
  flex: 0 0 7.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.recent-posts a {
  text-decoration: none;
  font-weight: 500;
}

.recent-posts a:hover {
  text-decoration: underline;
}

.more-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}

.more-link:hover {
  text-decoration: underline;
}

.post-header {
  padding: 3.5rem 0 1.75rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  margin: 0.6rem 0 0.9rem;
  font-size: 2.1rem;
}

.post-header .lead {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text-soft);
}

.post h2 {
  margin: 3rem 0 1rem;
  font-size: 1.45rem;
}

.post h3 {
  margin: 2rem 0 0.75rem;
}

.post p {
  margin: 0 0 1.1rem;
}

.post ul,
.post ol {
  margin: 0 0 1.25rem;
}

.post li {
  margin: 0.4rem 0;
}

.post img {
  margin: 1.5rem 0;
  border-radius: var(--radius);
}

.post blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
}

.post blockquote p:last-child {
  margin-bottom: 0;
}

.toc {
  margin: 0 0 2.5rem;
  padding: 1.1rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.toc strong {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.toc ol {
  margin: 0;
  padding-left: 1.25rem;
  columns: 2;
  column-gap: 2rem;
}

.toc li {
  margin: 0.2rem 0;
  font-size: 0.95rem;
  break-inside: avoid;
}

.toc a {
  color: var(--text-soft);
  text-decoration: none;
}

.toc a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.step {
  position: relative;
  margin: 2.75rem 0;
  padding-left: 3.25rem;
}

.step-number {
  position: absolute;
  top: -0.1rem;
  left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}

.step > h3 {
  margin-top: 0;
  padding-top: 0.3rem;
  font-size: 1.3rem;
}

.note,
.tip,
.warning {
  margin: 1.5rem 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  font-size: 0.97rem;
  background: var(--bg-soft);
}

.note {
  border-left-color: var(--accent);
}

.tip {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.warning {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.note p:last-child,
.tip p:last-child,
.warning p:last-child {
  margin-bottom: 0;
}

.series-box {
  margin: 1.5rem 0;
  padding: 0.9rem 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.series-box ol {
  margin: 0.4rem 0 0;
}

.post-footer {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.author-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}

.author-box img {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

.author-box strong {
  display: block;
  margin-bottom: 0.2rem;
}

.author-box p {
  margin: 0;
  font-size: 0.93rem;
  color: var(--text-soft);
}

.post-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  font-size: 0.95rem;
}

.post-nav a {
  text-decoration: none;
  font-weight: 500;
}

.post-nav a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.875em;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

.post p code,
.post li code,
.post td code,
.post h3 code {
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--accent);
  background: var(--accent-soft);
}

.code-block {
  margin: 1.25rem 0 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: var(--shadow);
}

.code-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: #a9b4c9;
  background: var(--code-head);
}

.code-block pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--code-text);
  tab-size: 4;
}

.code-block pre code {
  font-size: inherit;
}

.copy-btn {
  padding: 0.2rem 0.6rem;
  border: 1px solid #3a4560;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.copy-btn:hover {
  border-color: #64748b;
  background: #253047;
}

.tok-kw { color: #c792ea; }
.tok-type { color: #82aaff; }
.tok-str { color: #c3e88d; }
.tok-num { color: #f78c6c; }
.tok-cmt { color: #7f8ea3; font-style: italic; }
.tok-fn { color: #ffcb6b; }
.tok-op { color: #89ddff; }
.tok-prompt { color: #7f8ea3; user-select: none; }
.tok-out { color: #cbd5e1; }

@media (max-width: 640px) {
  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.85rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .container {
    padding: 0 1rem;
  }

  .brand {
    font-size: 0.9rem;
  }

  .site-nav a {
    padding: 0.3rem 0.45rem;
    font-size: 0.85rem;
  }

  .hero {
    padding: 2.75rem 0 2rem;
  }

  .hero .tagline {
    font-size: 1.05rem;
  }

  .page-title,
  .post-header {
    padding-top: 2.5rem;
  }

  .post-header h1 {
    font-size: 1.65rem;
  }

  .toc ol {
    columns: 1;
  }

  .step {
    padding-left: 2.75rem;
  }

  .step-number {
    width: 2rem;
    height: 2rem;
    font-size: 0.82rem;
  }

  .code-block pre {
    padding: 0.85rem 0.9rem;
    font-size: 0.8rem;
  }

  .contact .label,
  .recent-posts time {
    flex-basis: 100%;
  }
}

@media (max-width: 420px) {
  .brand {
    display: none;
  }

  .nav-wrap {
    justify-content: center;
  }
}

.hero + .section,
.page-title + .section {
  border-top: 0;
  padding-top: 0.5rem;
}
