:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-soft: #fbf7f1;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: #fffdf8;
  --ink: #18212d;
  --muted: #576575;
  --line: rgba(24, 33, 45, 0.14);
  --accent: #c55a34;
  --accent-strong: #8f3413;
  --accent-cool: #1b7f86;
  --shadow: 0 18px 60px rgba(31, 33, 38, 0.12);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --body-bg:
    radial-gradient(circle at top left, rgba(197, 90, 52, 0.12), transparent 32%),
    radial-gradient(circle at top right, rgba(27, 127, 134, 0.12), transparent 26%),
    linear-gradient(180deg, #f1ebe1 0%, #f7f4ed 46%, #fbf8f2 100%);
  --code-bg: rgba(24, 33, 45, 0.08);
  --hero-border: rgba(255, 255, 255, 0.45);
  --hero-bg:
    radial-gradient(circle at 0% 0%, rgba(197, 90, 52, 0.18), transparent 24%),
    radial-gradient(circle at 100% 0%, rgba(27, 127, 134, 0.18), transparent 24%),
    linear-gradient(135deg, #121922 0%, #1a2431 55%, #121a22 100%);
  --hero-text: #f7f3ea;
  --hero-subtle: rgba(247, 243, 234, 0.72);
  --hero-lede: rgba(247, 243, 234, 0.88);
  --hero-detail-text: rgba(247, 243, 234, 0.78);
  --hero-card-bg: rgba(255, 255, 255, 0.08);
  --hero-card-line: rgba(255, 255, 255, 0.12);
  --hero-portrait-line: rgba(255, 255, 255, 0.16);
  --tag-bg: rgba(24, 33, 45, 0.06);
  --hero-tag-bg: rgba(255, 255, 255, 0.08);
  --timeline-line: linear-gradient(180deg, rgba(24, 33, 45, 0.1), rgba(24, 33, 45, 0.3), rgba(24, 33, 45, 0.1));
  --footer-bg: linear-gradient(135deg, #141d28 0%, #1d2836 100%);
  --footer-kicker-text: rgba(247, 243, 234, 0.68);
  --footer-body-text: rgba(247, 243, 234, 0.76);
  --footer-link-text: #f7f3ea;
  --theme-toggle-bg: rgba(255, 255, 255, 0.06);
  --theme-toggle-line: rgba(255, 255, 255, 0.14);
  --theme-toggle-text: #f7f3ea;
  --theme-toggle-dot: #5fcdd3;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141c;
  --bg-soft: #141b25;
  --surface: rgba(22, 30, 42, 0.78);
  --surface-strong: #172130;
  --ink: #edf3f8;
  --muted: #a8b6c5;
  --line: rgba(226, 234, 241, 0.14);
  --accent: #d46c45;
  --accent-strong: #ff9d73;
  --accent-cool: #60ccd2;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --body-bg:
    radial-gradient(circle at top left, rgba(212, 108, 69, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(96, 204, 210, 0.14), transparent 22%),
    linear-gradient(180deg, #0c1118 0%, #111720 48%, #151d27 100%);
  --code-bg: rgba(255, 255, 255, 0.08);
  --hero-border: rgba(255, 255, 255, 0.08);
  --hero-bg:
    radial-gradient(circle at 0% 0%, rgba(212, 108, 69, 0.16), transparent 22%),
    radial-gradient(circle at 100% 0%, rgba(96, 204, 210, 0.14), transparent 22%),
    linear-gradient(135deg, #0d141d 0%, #131d29 55%, #0d141b 100%);
  --hero-text: #f7f3ea;
  --hero-subtle: rgba(247, 243, 234, 0.68);
  --hero-lede: rgba(247, 243, 234, 0.86);
  --hero-detail-text: rgba(247, 243, 234, 0.76);
  --hero-card-bg: rgba(255, 255, 255, 0.05);
  --hero-card-line: rgba(255, 255, 255, 0.08);
  --hero-portrait-line: rgba(255, 255, 255, 0.12);
  --tag-bg: rgba(255, 255, 255, 0.08);
  --hero-tag-bg: rgba(255, 255, 255, 0.08);
  --timeline-line: linear-gradient(180deg, rgba(226, 234, 241, 0.1), rgba(226, 234, 241, 0.26), rgba(226, 234, 241, 0.1));
  --footer-bg: linear-gradient(135deg, #0d141d 0%, #162231 100%);
  --footer-kicker-text: rgba(247, 243, 234, 0.64);
  --footer-body-text: rgba(247, 243, 234, 0.74);
  --footer-link-text: #f7f3ea;
  --theme-toggle-bg: rgba(255, 255, 255, 0.05);
  --theme-toggle-line: rgba(255, 255, 255, 0.1);
  --theme-toggle-text: #f7f3ea;
  --theme-toggle-dot: #d46c45;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--body-bg);
  font-family: "Source Sans 3", sans-serif;
  line-height: 1.6;
  transition: background 0.28s ease, color 0.28s ease;
}

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

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
}

code {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--code-bg);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.92rem;
}

.page-frame {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 24px 72px;
}

.hero,
.section,
.footer {
  scroll-margin-top: 96px;
}

.hero {
  padding: 76px 24px 42px;
  border: 1px solid var(--hero-border);
  border-radius: 36px;
  background: var(--hero-bg);
  color: var(--hero-text);
  box-shadow: var(--shadow);
  transition: border-color 0.28s ease, background 0.28s ease, color 0.28s ease;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 1000;
  width: min(calc(100% - 48px), 1132px);
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 28px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transform: translateX(-50%);
  transition:
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    backdrop-filter 0.22s ease,
    top 0.22s ease;
}

.topbar.is-floating {
  top: 10px;
  border-color: var(--hero-border);
  background: rgba(18, 30, 46, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.nav-link-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--theme-toggle-line);
  border-radius: 50%;
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-toggle-dot);
  font-size: 1.1rem;
  line-height: 1;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.1);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--theme-toggle-dot);
  outline-offset: 3px;
}

.nav-links a {
  color: rgba(247, 243, 234, 0.82);
  font-size: 0.96rem;
}

.nav-links a:hover {
  color: #ffffff;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.88fr);
  gap: 32px;
  align-items: start;
}

.eyebrow,
.section-kicker,
.panel-kicker,
.repo-kicker,
.footer-kicker {
  margin: 0 0 12px;
  color: var(--hero-subtle);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.8rem, 4.8vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.lede {
  margin: 22px 0 0;
  max-width: 62ch;
  color: var(--hero-lede);
  font-size: 1.14rem;
}

.hero-detail {
  margin: 18px 0 0;
  max-width: 68ch;
  color: var(--hero-detail-text);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.78rem 1.15rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff8f2;
  font-weight: 700;
  transition: transform 0.22s ease, background 0.22s ease;
}

.button:hover {
  color: #fff8f2;
  background: var(--accent-strong);
  transform: translateY(-2px);
}

.button-secondary {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f7f3ea;
}

.button-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.icon-button {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
}

.icon-button img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
  filter: brightness(0) saturate(100%) invert(95%) sepia(16%) saturate(211%) hue-rotate(313deg) brightness(104%) contrast(94%);
}

.hero-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 0;
  margin: 30px 0 0;
  list-style: none;
}

.hero-facts li,
.metric-card,
.panel-card,
.repo-card,
.archive-card,
.publication-item,
.timeline-card,
.profile-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.hero-facts li {
  padding: 16px 18px;
  background: var(--hero-card-bg);
  border-color: var(--hero-card-line);
}

.fact-label {
  display: block;
  color: var(--hero-subtle);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.fact-value {
  display: block;
  margin-top: 6px;
  color: var(--hero-text);
  font-weight: 600;
}

.profile-panel {
  padding: 18px;
  background: var(--hero-card-bg);
  border-color: var(--hero-card-line);
}

.portrait {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 24px;
  object-fit: cover;
  border: 1px solid var(--hero-portrait-line);
}

.profile-panel-body {
  margin-top: 18px;
}

.profile-panel h2 {
  margin: 0 0 10px;
  color: var(--hero-text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.55rem;
  line-height: 1.05;
}

.profile-panel p {
  margin: 0;
  color: var(--hero-detail-text);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.tag {
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  background: var(--tag-bg);
  color: inherit;
  font-size: 0.86rem;
  font-weight: 600;
}

.hero .tag {
  background: var(--hero-tag-bg);
}

.metric-strip,
.split-grid,
.repo-grid,
.archive-grid {
  display: grid;
  gap: 18px;
}

.metric-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 24px;
}

.metric-card {
  padding: 22px 20px;
  background: var(--surface-strong);
}

.metric-value {
  display: block;
  color: var(--accent-strong);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.metric-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.section {
  margin-top: 72px;
}

.section-heading {
  margin-bottom: 26px;
}

.section-heading .section-kicker,
.repo-kicker,
.footer-kicker,
.panel-kicker {
  color: var(--accent-cool);
}

.section-heading h2,
.footer h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.section-heading p,
.footer p {
  max-width: 70ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
}

.timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: var(--timeline-line);
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 88px 1fr;
  gap: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: calc(50% - 8px);
  top: 28px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px rgba(24, 33, 45, 0.08);
}

.timeline-item.work::before {
  background: var(--accent-cool);
}

.timeline-item.education::before {
  background: var(--accent);
}

.timeline-card {
  padding: 22px 22px 20px;
  background: var(--surface-strong);
}

.timeline-item.left .timeline-card {
  grid-column: 1;
  text-align: right;
}

.timeline-item.right .timeline-card {
  grid-column: 3;
  text-align: left;
}

.timeline-date {
  margin: 0;
  color: var(--accent-cool);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.timeline-item.education .timeline-date {
  color: var(--accent-strong);
}

.timeline-card h3 {
  margin: 8px 0 4px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
  line-height: 1.1;
}

.timeline-role {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.timeline-card p:last-child {
  margin-top: 12px;
  color: var(--muted);
}

.split-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-card,
.repo-card,
.publication-item {
  padding: 24px;
  background: var(--surface-strong);
}

.panel-card h3,
.repo-card h3,
.archive-copy h3,
.publication-item h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.45rem;
  line-height: 1.1;
}

.bullet-list {
  margin: 18px 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
}

.bullet-list li + li {
  margin-top: 10px;
}

.repo-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.repo-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.repo-card:hover,
.archive-card:hover,
.publication-item:hover,
.panel-card:hover,
.metric-card:hover,
.timeline-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 64px rgba(24, 33, 45, 0.14);
}

.repo-kicker {
  margin-bottom: 8px;
}

.repo-card p {
  margin: 12px 0 0;
  color: var(--muted);
}

.inline-link,
.inline-links a,
.footer-links a {
  color: var(--accent-strong);
  font-weight: 700;
}

.inline-link {
  display: inline-block;
  margin-top: 16px;
}

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

.archive-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.archive-card {
  overflow: hidden;
  background: var(--surface-strong);
}

.archive-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.archive-copy {
  padding: 20px 22px 24px;
}

.year-badge,
.publication-year {
  margin: 0 0 8px;
  color: var(--accent-cool);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.archive-copy p,
.publication-item p {
  margin: 12px 0 0;
  color: var(--muted);
}

.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
}

.publication-list {
  display: grid;
  gap: 18px;
}

.publication-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.publication-year {
  margin: 4px 0 0;
}

.footer {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(220px, 0.8fr);
  gap: 24px;
  align-items: end;
  margin-top: 72px;
  padding: 28px 28px 32px;
  border-radius: 32px;
  background: var(--footer-bg);
  color: var(--footer-link-text);
  box-shadow: var(--shadow);
}

.footer-kicker {
  color: var(--footer-kicker-text);
}

.footer p {
  color: var(--footer-body-text);
}

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

.footer-links a {
  color: var(--footer-link-text);
}

.footer-links a:hover {
  color: #ffffff;
}

.hero-article {
  padding-bottom: 26px;
}

.article-header {
  max-width: 820px;
  padding-top: 12px;
}

.article-lede {
  max-width: 44rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--hero-subtle);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.back-link::before {
  content: "←";
}

.back-link:hover {
  color: #ffffff;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
}

.article-meta span {
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--hero-card-line);
  border-radius: 999px;
  background: var(--hero-card-bg);
  color: var(--hero-detail-text);
  font-size: 0.92rem;
  font-weight: 600;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.article-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--hero-card-line);
  border-radius: 999px;
  background: var(--hero-card-bg);
  color: var(--hero-detail-text);
  font-size: 0.92rem;
  font-weight: 600;
}

.article-shell {
  margin-top: 32px;
}

.article-card {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.article-card > :first-child {
  margin-top: 0;
}

.article-card > :last-child {
  margin-bottom: 0;
}

.article-card h2 {
  margin: 30px 0 10px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.65rem;
  line-height: 1.08;
}

.article-card p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.article-card em {
  color: var(--ink);
}

.equation-block {
  overflow-x: auto;
  margin: 22px 0;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  text-align: center;
}

.equation-block mjx-container {
  margin: 0 auto !important;
}

.comments-card {
  padding-bottom: 24px;
}

.comment-note {
  margin: 0;
}

.comments-host {
  min-height: 200px;
  margin-top: 20px;
}

@media (max-width: 980px) {
  .hero-grid,
  .split-grid,
  .repo-grid,
  .archive-grid,
  .footer {
    grid-template-columns: 1fr;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-facts {
    grid-template-columns: 1fr;
  }

  .timeline::before {
    left: 20px;
  }

  .timeline-item {
    grid-template-columns: 40px 1fr;
    gap: 14px;
  }

  .timeline-item::before {
    left: 12px;
  }

  .timeline-item.left .timeline-card,
  .timeline-item.right .timeline-card {
    grid-column: 2;
    text-align: left;
  }

  .publication-item {
    grid-template-columns: 1fr;
  }

  .article-header {
    max-width: none;
  }
}

@media (max-width: 720px) {
  .page-frame {
    padding: 14px 16px 56px;
  }

  .hero {
    padding: 20px 18px 28px;
    border-radius: 28px;
  }

  .topbar {
    position: static;
    flex-direction: column;
    align-items: flex-start;
    width: auto;
    padding: 0 0 24px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    transform: none;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .archive-card img {
    height: 190px;
  }

  .article-card {
    padding: 22px 20px;
  }

  .article-meta {
    gap: 8px;
  }

  .article-meta span {
    font-size: 0.88rem;
  }
}
