:root { color-scheme: light dark; --bg: light-dark(#ffffff, #0f1012); --surface: light-dark(#f3f4f6, #181a1e); --ink: light-dark(#141517, #ececeb); --muted: light-dark(#5f6268, #a7aab1); --faint: light-dark(#8a8d93, #777b83); --line: light-dark(#e4e5e8, #26282d); --accent: light-dark(#2145d8, #9db2ff); --rail-bg: light-dark(#15161a, #08090b); --rail-ink: #f4f4f2; --rail-muted: #a3a6ad; --rail-line: light-dark(#2a2c32, #23252a); --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace; }

:root[data-theme="light"] { color-scheme: light; }

:root[data-theme="dark"] { color-scheme: dark; }

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; background: var(--bg); }

body { margin: 0; height: 100dvh; display: grid; grid-template-columns: 14.5rem minmax(0, 1fr); background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.65; -webkit-font-smoothing: antialiased; }

::selection { background: var(--accent); color: #ffffff; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }

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

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.skip-link { position: absolute; top: -5rem; left: 1rem; z-index: 10; padding: 0.75rem 1rem; background: var(--ink); color: var(--bg); text-decoration: none; }

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

/* Rail */
.rail { display: flex; flex-direction: column; justify-content: space-between; gap: 2rem; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--rail-line) transparent; padding: 2.75rem 1.5rem 2rem; background: var(--rail-bg); color: var(--rail-ink); }

.rail a { color: inherit; }

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

.name { display: block; font-size: 1.75rem; font-weight: 650; line-height: 1.1; letter-spacing: -0.035em; text-decoration: none; }

.handle { display: inline-block; margin: 0.5rem 0 0; font-size: 0.95rem; color: var(--rail-muted); text-decoration: none; }

.role { margin: 1.75rem 0 0; font-size: 0.9rem; line-height: 1.55; color: var(--rail-muted); }

.rail-nav { display: flex; flex-direction: column; margin-top: 2rem; font-size: 0.95rem; }

.rail-nav a { display: inline-flex; align-items: center; min-height: 2.4rem; text-decoration: none; }

.rail-bottom { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; font-size: 0.82rem; color: var(--rail-muted); }

.rail-links { display: flex; flex-direction: column; }

.rail-links a { display: inline-flex; align-items: center; min-height: 2rem; text-decoration: none; }

.theme-toggle { min-height: 2.6rem; padding: 0; border: 0; background: none; color: var(--rail-muted); font: inherit; font-size: 0.82rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

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

/* Main pane */
.content { overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-color: var(--line) transparent; padding: 3.5rem clamp(1.25rem, 4vw, 4rem) 5rem; }

.content:focus { outline: none; }

.mobile-nav { display: none; }

.content > * { max-width: 46rem; }

.home-grid { width: 100%; max-width: 66rem; margin: 0 auto; }

h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; }

h1 { font-size: clamp(2rem, 3.6vw, 2.5rem); }

.block h2 { font-size: clamp(1.7rem, 2.6vw, 2.1rem); }

.block-lede { margin: 0.6rem 0 0; font-size: 0.95rem; color: var(--muted); }

.block { padding-bottom: 2.5rem; }

.block + .block { padding-top: 2.5rem; }

/* Home columns */
@media (min-width: 78rem) { .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 19rem); gap: 3rem; align-items: start; }
  .home-grid .block + .block { padding-top: 0; } }
/* Projects */
.project-carousel { position: relative; margin-top: 2rem; padding: 1.5rem; background: var(--surface); }

.project-carousel.has-controls { padding-bottom: 4.25rem; }

.project-face { padding: 0; }

.project-face + .project-face { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

.project-face-inner { display: block; text-align: left; text-decoration: none; }

.work-title { display: block; font-size: 1.35rem; font-weight: 620; line-height: 1.25; letter-spacing: -0.02em; }

.work-meta { display: block; margin-top: 0.15rem; font-size: 0.82rem; color: var(--muted); }

.project-face-inner p { margin: 0.7rem 0 0; font-size: 0.94rem; color: var(--muted); }

.work-stack { display: block; margin-top: 0.7rem; font-size: 0.82rem; color: var(--faint); }

.work-link { display: inline-block; margin-top: 0.8rem; font-size: 0.85rem; font-weight: 500; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.project-face-inner:hover .work-title { color: var(--accent); }

.carousel-stage { position: relative; }

.project-carousel.is-ready .carousel-stage { overflow: hidden; }

.project-carousel.is-ready .project-face { position: absolute; inset: 0; display: block; margin: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }

.project-carousel.is-animated .project-face { transition: opacity 220ms ease; }

.project-carousel.is-ready .project-face.is-active { opacity: 1; pointer-events: auto; }

.carousel-controls { display: none; position: absolute; right: 1.5rem; bottom: 1rem; }

.project-carousel.is-ready .carousel-controls { display: block; }

.carousel-next { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--bg); color: var(--ink); cursor: pointer; }

.carousel-next:hover { border-color: var(--accent); color: var(--accent); }

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

@media (scripting: none) { .project-face + .project-face { display: block; }
  .project-carousel.has-controls { padding-bottom: 1.5rem; } }
/* Writing */
.post-tools { display: grid; gap: 0.9rem; margin-top: 1.75rem; }

.search-field label { display: block; margin-bottom: 0.35rem; font-size: 0.82rem; color: var(--muted); }

.search-line { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.search-field input { flex: 1; min-width: 12rem; max-width: 26rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 0.95rem; }

.search-field input:focus-visible { outline-offset: 0; }

.surprise-button { min-height: 2.4rem; padding: 0 0.9rem; border: 0; background: var(--accent); color: var(--bg); font: inherit; font-size: 0.85rem; cursor: pointer; }

.surprise-button:hover { opacity: 0.88; }

.surprise-button:disabled { opacity: 0.6; cursor: wait; }

.surprise-button:focus-visible { outline-color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.filter-chip { min-height: 2rem; padding: 0.25rem 0.65rem; border: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 0.8rem; cursor: pointer; transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease; }

.filter-chip:hover { color: var(--ink); border-color: var(--ink); }

.filter-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.filter-chip:active { transform: scale(0.96); }

@keyframes chip-pop { 0% { transform: scale(1); }
  45% { transform: scale(0.94); }
  100% { transform: scale(1); } }
.filter-chip.chip-pop { animation: chip-pop 160ms ease; }

.result-count { margin: 0; font-size: 0.8rem; color: var(--faint); }

.post-list { margin-top: 1.25rem; }

.post-item { display: block; padding: 1.25rem 0; text-decoration: none; }

.post-item + .post-item { border-top: 1px solid var(--line); }

.post-date { display: block; font-size: 0.78rem; color: var(--faint); }

.post-title { display: block; margin-top: 0.1rem; font-size: 1.1rem; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; }

.post-item:hover .post-title { color: var(--accent); }

.post-item p { max-width: 36rem; margin: 0.3rem 0 0; font-size: 0.92rem; color: var(--muted); }

.post-empty { margin-top: 1.25rem; color: var(--muted); }

/* Articles */
.post { max-width: 40rem; margin: 0 auto; }

.post-header { margin-bottom: 2rem; }

.post-header h1 { margin-top: 0.5rem; font-size: clamp(1.8rem, 3vw, 2.35rem); text-wrap: balance; }

.post-meta { display: block; font-size: 0.8rem; color: var(--faint); }

.dek { margin: 0.8rem 0 0; font-size: 1rem; color: var(--muted); }

.post-repo { margin: 0.7rem 0 0; font-size: 0.88rem; }

.post-content { font-size: 1.02rem; line-height: 1.72; }

.post-content > * + * { margin-top: 1.2em; }

.post-content p { margin: 0; }

.post-content h2 { margin: 2.6rem 0 0.8rem; font-size: 1.45rem; font-weight: 650; line-height: 1.25; }

.post-content h3 { margin: 2rem 0 0.5rem; font-size: 1.1rem; font-weight: 600; line-height: 1.35; }

.post-content h4 { margin: 1.6rem 0 0.4rem; font-size: 1rem; font-weight: 600; }

.post-content ul, .post-content ol { padding-left: 1.3rem; }

.post-content li + li { margin-top: 0.35em; }

.post-content a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.post-content blockquote { margin: 1.8rem 0; padding-left: 1.1rem; border-left: 3px solid var(--accent); color: var(--muted); }

.post-content blockquote p + p { margin-top: 1em; }

.post-content code { font-family: var(--mono); font-size: 0.84em; padding: 0.12em 0.32em; background: var(--surface); }

.post-content pre { margin: 1.8rem 0; padding: 1.1rem 1.25rem; overflow-x: auto; background: var(--surface); font-size: 0.8rem; line-height: 1.65; }

.post-content pre code { padding: 0; background: none; font-size: inherit; }

.post-content table { width: 100%; border-collapse: collapse; margin: 1.8rem 0; font-size: 0.9rem; }

.post-content th, .post-content td { padding: 0.5rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; }

.post-content th { font-size: 0.85rem; font-weight: 600; color: var(--muted); }

.post-content img { max-width: 100%; height: auto; }

.post-content hr { margin: 2.5rem 0; border: 0; border-top: 1px solid var(--line); }

.post-content strong { font-weight: 600; }

.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font-size: 0.95rem; }

.post-nav a { text-decoration: none; line-height: 1.35; }

.post-nav .post-meta { margin-bottom: 0.35rem; }

.post-nav-next { text-align: right; }

/* CV */
.cv-skills { display: grid; grid-template-columns: 10rem 1fr; gap: 0.6rem 1.5rem; margin: 1.4rem 0 0; }

.cv-skills dt { padding-top: 0.1rem; font-size: 0.85rem; color: var(--muted); }

.cv-skills dd { margin: 0; font-size: 0.95rem; }

.post-content .cv-meta { margin: 0.1rem 0 0.7rem; font-size: 0.85rem; color: var(--muted); }

.post-content h3 + .cv-meta { margin-top: -0.1rem; }

/* CV and About */
.post.post-wide { max-width: 62rem; }

.about-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 3rem; align-items: start; }

.about-left > h2:first-child, .about-right > h2:first-child { margin-top: 0; }

.about-right { border-left: 1px solid var(--line); padding-left: 3rem; }

.about-links { list-style: none; margin: 1rem 0 0; padding: 0; }

.about-links li + li { margin-top: 0.35rem; }

/* Math and diagrams */
.post-content mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: 0.25rem 0; }

.mermaid { margin: 1.8rem 0; padding: 1rem; background: var(--surface); overflow-x: auto; text-align: center; }

.mermaid svg { max-width: 100%; height: auto; }

/* Mobile */
@media (max-width: 52rem) { body { display: block; height: auto; }
  .rail { position: sticky; top: 0; z-index: 20; flex-direction: row; align-items: center; justify-content: space-between; gap: 1rem; overflow: visible; padding: 0.7rem 1.25rem; border-bottom: 1px solid var(--rail-line); }
  .rail-top { display: flex; align-items: baseline; gap: 0.5rem; }
  .name { font-size: 1.3rem; }
  .handle { margin: 0; font-size: 0.85rem; }
  .role, .rail-nav, .rail-links { display: none; }
  .rail-bottom { flex-direction: row; align-items: center; margin-left: auto; }
  .theme-toggle { min-height: 2rem; font-size: 0.8rem; }
  .content { overflow: visible; padding: 2rem 1.25rem 6rem; }
  section[id] { scroll-margin-top: 4.5rem; }
  .mobile-nav { position: fixed; inset: auto 0 0; z-index: 20; display: flex; background: var(--rail-bg); border-top: 1px solid var(--rail-line); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a { display: flex; flex: 1; align-items: center; justify-content: center; min-height: 3.25rem; color: var(--rail-muted); font-size: 0.82rem; text-decoration: none; }
  .mobile-nav a:hover, .mobile-nav a:focus-visible { color: var(--rail-ink); }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav-next { text-align: left; }
  .about-grid { display: block; }
  .about-right { margin-top: 2rem; padding-top: 2rem; padding-left: 0; border-top: 1px solid var(--line); border-left: 0; }
  .cv-skills { grid-template-columns: 1fr; gap: 0; }
  .cv-skills dt { margin-top: 0.85rem; }
  .cv-skills dd { margin-top: 0.1rem; } }
/* Reader preferences */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; }
  .content { scroll-behavior: auto; } }
@media (prefers-contrast: more) { :root { --muted: light-dark(#3b362e, #efe8db); --faint: light-dark(#3b362e, #efe8db); --line: #7d766a; } }
@media (forced-colors: active) { .rail, .post-item, .post-header, .post-nav, .post-content blockquote { border-color: CanvasText; }
  .theme-toggle { padding: 0.4rem 0.6rem; border: 1px solid ButtonText; } }
@media print { body { display: block; height: auto; background: #fff; color: #000; }
  .rail, .post-nav, .theme-toggle, .skip-link, .post-tools { display: none; }
  .post-item[hidden] { display: block !important; }
  .content { overflow: visible; padding: 0; } }
