:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #1f2937;
  --heading: #111827;
  --muted: #6b7280;
  --soft: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --code-bg: #f8fafc;
  --code-border: #e2e8f0;
  --code-text: #0f172a;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  --radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", Georgia, serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --frame: min(1180px, calc(100vw - 48px));
  --sidebar: 260px;
  --measure: 760px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f172a;
  --surface: #111827;
  --surface-muted: #1f2937;
  --text: #e5e7eb;
  --heading: #f9fafb;
  --muted: #a6adbb;
  --soft: #808999;
  --border: #273244;
  --border-strong: #374151;
  --primary: #60a5fa;
  --primary-dark: #93c5fd;
  --primary-soft: #172554;
  --code-bg: #0b1120;
  --code-border: #253149;
  --code-text: #e5e7eb;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.68;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

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

button,
input,
select {
  font: inherit;
}

.sr-only,
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 30;
  width: auto;
  height: auto;
  padding: 10px 14px;
  clip: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.nav-shell {
  width: var(--frame);
  min-height: 58px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  color: var(--heading);
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-width: max-content;
}

.brand:hover {
  text-decoration: none;
}

.brand-name {
  font-weight: 750;
  letter-spacing: 0;
}

.brand-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.nav-panel {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-panel a,
.theme-button {
  color: var(--muted);
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 7px 9px;
  cursor: pointer;
  font-size: 0.92rem;
  white-space: nowrap;
}

.nav-panel a:hover,
.theme-button:hover,
.nav-panel a[aria-current="page"] {
  color: var(--heading);
  background: var(--surface-muted);
  text-decoration: none;
}

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.nav-toggle span:not(.sr-only) {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  background: var(--heading);
}

.site-frame {
  width: var(--frame);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

.profile-sidebar {
  position: sticky;
  top: 86px;
  min-width: 0;
  padding: 44px 0 32px;
}

.profile-card {
  color: var(--muted);
}

.profile-photo {
  width: 152px;
  height: 152px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
  margin-bottom: 18px;
}

.profile-card h2 {
  margin: 0;
  color: var(--heading);
  font-size: 1.35rem;
}

.profile-title,
.profile-affiliation {
  margin: 4px 0 0;
}

.profile-bio {
  margin: 16px 0;
  font-size: 0.95rem;
}

.profile-links {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.profile-links a {
  color: var(--text);
  font-size: 0.94rem;
}

.site-main {
  min-width: 0;
  padding: 44px 0 80px;
}

.page-shell,
.post-shell,
.home-shell {
  max-width: var(--measure);
}

.page-header,
.post-hero,
.home-hero {
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.05rem, 4vw, 3.15rem);
}

h2 {
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
}

h3 {
  font-size: 1.1rem;
}

.lead,
.page-subtitle {
  color: var(--muted);
  font-size: 1.06rem;
  line-height: 1.72;
}

.home-section,
.page-section {
  margin-top: 42px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.link-row,
.hero-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.button,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-weight: 650;
  font-size: 0.94rem;
}

.button-secondary {
  background: transparent;
  color: var(--primary);
}

.button:hover,
.button-secondary:hover {
  color: #fff;
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  text-decoration: none;
}

.button-secondary:hover {
  color: #fff;
}

.compact-list,
.post-list,
.publication-list,
.resource-list {
  display: grid;
  gap: 18px;
}

.compact-item,
.post-card,
.publication-card,
.resource-card,
.note-card {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.compact-item:last-child,
.post-card:last-child,
.publication-card:last-child,
.resource-card:last-child,
.note-card:last-child {
  border-bottom: 0;
}

.post-card h2,
.post-card h3,
.publication-card h3,
.resource-card h3,
.note-card h3 {
  font-size: 1.18rem;
}

.post-card h2 a,
.post-card h3 a,
.compact-item h3 a {
  color: var(--heading);
}

.post-card h2 a:hover,
.post-card h3 a:hover,
.compact-item h3 a:hover {
  color: var(--primary);
}

.post-card p,
.publication-card p,
.resource-card p,
.compact-item p,
.note-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.meta,
.post-meta,
.card-meta {
  color: var(--soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 0.88rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 0.82rem;
}

a.tag:hover {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 36%, var(--border));
  text-decoration: none;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px);
  gap: 12px;
  margin: 24px 0 20px;
}

.filters input,
.filters select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.94rem;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.resource-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.publication-card .paper-title {
  color: var(--heading);
  font-weight: 700;
}

.paper-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.paper-links a {
  font-size: 0.88rem;
  font-weight: 650;
}

.archive-year {
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.archive-list li {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 18px;
}

.archive-list time {
  color: var(--soft);
}

.back-link {
  display: inline-flex;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.92rem;
}

.post-hero h1 {
  font-size: clamp(2rem, 3.8vw, 3rem);
}

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 34px;
  align-items: start;
}

.post-toc {
  position: sticky;
  top: 86px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.86rem;
}

.post-toc-title {
  margin-bottom: 8px;
  color: var(--heading);
  font-weight: 750;
}

.post-toc a {
  display: block;
  margin: 6px 0;
  color: var(--muted);
}

.post-toc a:hover {
  color: var(--primary);
  text-decoration: none;
}

.post-toc .toc-h3 {
  padding-left: 12px;
}

.prose {
  max-width: var(--measure);
}

.prose > * + * {
  margin-top: 1.08em;
}

.post-content > h1:first-child {
  display: none;
}

.prose h2 {
  margin-top: 2.1em;
  padding-top: 0.2em;
  font-size: 1.55rem;
}

.prose h3 {
  margin-top: 1.6em;
}

.prose p,
.prose li {
  color: var(--text);
}

.prose blockquote {
  margin-left: 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--primary);
  color: var(--muted);
}

.prose pre,
.prose code {
  font-family: var(--font-mono);
}

.prose code {
  padding: 0.12em 0.32em;
  border: 1px solid var(--code-border);
  border-radius: 5px;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 0.92em;
}

.prose pre {
  overflow-x: auto;
  padding: 16px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--code-text);
  line-height: 1.55;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.94rem;
}

.prose th,
.prose td {
  padding: 9px 11px;
  border: 1px solid var(--border);
}

.prose th {
  background: var(--surface-muted);
}

.prose img {
  margin: 1.4em auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.post-footer-nav {
  margin: 48px 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.post-nav-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.post-nav-card span {
  display: block;
  color: var(--soft);
  font-size: 0.84rem;
}

.site-footer {
  border-top: 1px solid var(--border);
}

.footer-shell {
  width: var(--frame);
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 0.92rem;
}

.footer-shell p {
  max-width: 680px;
  margin: 4px 0 0;
}

.footer-links {
  display: flex;
  gap: 12px;
  align-items: start;
}

.muted {
  color: var(--muted);
}

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

  .nav-panel a,
  .theme-button {
    padding-inline: 7px;
  }
}

@media (max-width: 860px) {
  :root {
    --frame: min(100vw - 28px, 1180px);
  }

  .nav-toggle {
    display: block;
  }

  .nav-panel {
    position: absolute;
    top: 58px;
    left: 14px;
    right: 14px;
    display: none;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
  }

  .nav-panel.is-open {
    display: grid;
  }

  .nav-panel a,
  .theme-button {
    width: 100%;
    text-align: left;
    border-radius: 6px;
  }

  .site-frame {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .profile-sidebar {
    position: static;
    padding: 30px 0 8px;
  }

  .profile-card {
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 0 16px;
    align-items: center;
  }

  .profile-photo {
    width: 78px;
    height: 78px;
    grid-row: span 4;
    margin: 0;
  }

  .profile-bio,
  .profile-links {
    grid-column: 1 / -1;
  }

  .site-main {
    padding-top: 26px;
  }

  .resource-grid,
  .filters,
  .post-layout,
  .post-footer-nav {
    grid-template-columns: 1fr;
  }

  .post-toc {
    position: static;
    order: -1;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
  }

  .archive-list li {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .footer-shell {
    display: grid;
  }
}
