:root {
  --text: #222a37;
  --muted: #687387;
  --link: #567cad;
  --link-hover: #365f94;
  --rule: rgba(32, 45, 63, 0.13);
  --background: #f3f5f8;
  --background-secondary: #ffffff;
  --topbar-bg: rgba(244, 246, 249, 0.90);
  --accent: #7597c5;
  --accent-soft: #a8bfe0;
  --photo-ring: rgba(85, 121, 171, 0.22);
  --shadow: 0 14px 42px rgba(27, 42, 64, 0.08);
}

html[data-theme="dark"] {
  --text: #edf1f7;
  --muted: #a6afbd;
  --link: #9bb7de;
  --link-hover: #c3d5ee;
  --rule: rgba(179, 197, 222, 0.13);
  --background: #101722;
  --background-secondary: #151f2d;
  --topbar-bg: rgba(13, 20, 30, 0.90);
  --accent: #7f9fce;
  --accent-soft: #a9c0e2;
  --photo-ring: rgba(142, 170, 211, 0.30);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

html {
  overflow-y: scroll;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15.8px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(circle at 8% 0%, rgba(126, 160, 207, 0.16), transparent 31rem),
    radial-gradient(circle at 92% 18%, rgba(65, 104, 158, 0.11), transparent 33rem),
    linear-gradient(180deg, rgba(255,255,255,0.018), transparent 24rem),
    var(--background);
  transition: background-color 0.22s ease, color 0.22s ease;
}

/* ---------- Top navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  border-bottom: 1px solid var(--rule);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.025);
}

.topbar-inner {
  width: min(1080px, calc(100% - 52px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 32px;
}

.site-name {
  color: var(--text);
  font-size: 19px;
  font-weight: 680;
  line-height: 1;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
}

.site-name:hover { color: var(--accent-soft); text-decoration: none; }

.top-nav {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 6px;
}

.top-nav a {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  font-size: 15.8px;
  font-weight: 540;
  letter-spacing: 0.005em;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.top-nav a::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}

.top-nav a:hover {
  color: var(--text);
  background: rgba(142, 170, 211, 0.055);
  text-decoration: none;
}

.top-nav a.active {
  color: var(--accent-soft);
  font-weight: 650;
}

.top-nav a.active::after { background: var(--accent); }

.theme-toggle {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(142,170,211,0.045);
  color: var(--accent-soft);
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  background: rgba(142,170,211,0.11);
  border-color: rgba(142,170,211,0.30);
}

/* ---------- Main layout ---------- */
.site-shell {
  width: min(1040px, calc(100% - 52px));
  margin: 0 auto;
  padding: 58px 0 84px;
  display: grid;
  grid-template-columns: 205px minmax(0, 700px);
  gap: 72px;
  align-items: start;
}

.profile {
  position: sticky;
  top: 108px;
  color: var(--muted);
}

.profile-role {
  color: var(--text);
  font-size: 15.8px;
  font-weight: 620;
  margin-bottom: 3px;
}

.profile-affiliation {
  font-size: 14px;
  line-height: 1.48;
  margin-bottom: 13px;
}

.profile-photo {
  display: block;
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 0 20px;
  background: var(--background-secondary);
  border: 1px solid var(--photo-ring);
  box-shadow: var(--shadow);
}

.profile-meta {
  font-size: 13.7px;
  margin-bottom: 13px;
}

.profile-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-link {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: rgba(142,170,211,0.045);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-link img {
  width: 20px;
  height: 20px;
  display: block;
}

.icon-link:hover {
  transform: translateY(-1px);
  background: rgba(142,170,211,0.12);
  border-color: rgba(142,170,211,0.34);
  text-decoration: none;
}

.content {
  min-width: 0;
  padding-top: 1px;
}

.content h1,
.content h2,
.content h3 {
  color: var(--text);
  font-weight: 640;
  line-height: 1.25;
  letter-spacing: -0.018em;
}

.content h1 {
  font-size: 29px;
  margin: 0 0 30px;
}

.content h2 {
  font-size: 20px;
  margin: 43px 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}

.content h3 {
  font-size: 16.5px;
  margin: 29px 0 7px;
}

.content p { margin: 0 0 17px; }
.content strong { font-weight: 650; }
.content ul,
.content ol { padding-left: 22px; margin-top: 8px; }
.content li { margin-bottom: 9px; }

.lead {
  font-size: 17.2px;
  line-height: 1.66;
}

a {
  color: var(--link);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* ---------- News ---------- */
.news-list {
  list-style: none;
  padding: 0 !important;
  margin: 0;
}

.news-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 15px;
  margin: 0 0 16px !important;
}

.news-date {
  color: var(--accent-soft);
  font-size: 13.5px;
  font-weight: 580;
  white-space: nowrap;
}

/* ---------- Publications ---------- */
.pub-year { margin-top: 37px !important; }

.publication {
  margin-bottom: 25px;
  padding-left: 14px;
  border-left: 2px solid rgba(142,170,211,0.18);
}

.publication-title {
  color: var(--text);
  font-weight: 650;
  line-height: 1.46;
  margin-bottom: 2px;
}

.publication-authors,
.publication-venue {
  color: var(--muted);
  font-size: 14.4px;
  line-height: 1.55;
}

.publication-links {
  font-size: 13.4px;
  margin-top: 4px;
}

.publication-links a {
  display: inline-block;
  margin-right: 11px;
  font-weight: 570;
}

/* ---------- CV ---------- */
.cv-button {
  display: inline-block;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 8px 13px;
  margin: 2px 0 18px;
  color: var(--text);
  background: rgba(142,170,211,0.055);
  transition: transform 0.15s ease, background 0.15s ease;
}

.cv-button:hover {
  text-decoration: none;
  transform: translateY(-1px);
  background: rgba(142,170,211,0.12);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 35px 0;
}

@media (max-width: 840px) {
  .topbar-inner {
    width: calc(100% - 28px);
    min-height: 64px;
    gap: 12px;
  }

  .site-name { font-size: 17px; }

  .top-nav {
    overflow-x: auto;
    scrollbar-width: none;
    gap: 1px;
  }
  .top-nav::-webkit-scrollbar { display: none; }

  .top-nav a {
    font-size: 13.5px;
    padding: 0 9px;
    white-space: nowrap;
  }

  .top-nav a::after { left: 9px; right: 9px; }

  .theme-toggle {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .site-shell {
    width: min(680px, calc(100% - 36px));
    display: block;
    padding: 38px 0 62px;
  }

  .profile {
    position: static;
    margin-bottom: 42px;
  }

  .profile-photo {
    width: 145px;
    height: 145px;
  }

  .news-item {
    grid-template-columns: 1fr;
    gap: 1px;
  }
}

@media (max-width: 610px) {
  .topbar-inner {
    min-height: auto;
    padding: 10px 0 9px;
    flex-wrap: wrap;
  }

  .site-name { order: 1; }
  .theme-toggle { order: 2; margin-left: auto; }

  .top-nav {
    order: 3;
    width: 100%;
    height: 38px;
    margin-left: 0;
  }

  .top-nav a { padding: 0 10px; }
  .top-nav a:first-child { padding-left: 0; }
  .top-nav a:first-child::after { left: 0; }

  .site-shell { padding-top: 30px; }
}
