/* Self-hosted web fonts in latin and latin-ext subsets. Sun Serif is built by
   tools/sun-serif/build.py. The other families come from Google Fonts, with
   the variable axes of Cormorant Garamond limited to the range this site uses. */
/* Cormorant Garamond, latin-ext */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-ext-f10a78f1.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Cormorant Garamond, latin */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-9e844510.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Cormorant Garamond, latin-ext */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-ext-f10a78f1.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Cormorant Garamond, latin */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-9e844510.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Cormorant Garamond, latin-ext */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-ext-f10a78f1.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Cormorant Garamond, latin */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-9e844510.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Cormorant Garamond, latin-ext */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-ext-7286adf6.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Cormorant Garamond, latin */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-5c238bcf.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Cormorant Garamond, latin-ext */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-ext-7286adf6.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Cormorant Garamond, latin */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-5c238bcf.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Cormorant Garamond, latin-ext */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-ext-7286adf6.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Cormorant Garamond, latin */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/cormorant-garamond-latin-5c238bcf.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono, latin-ext */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/ibm-plex-mono-latin-ext-f1050dc5.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono, latin */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/ibm-plex-mono-latin-c36f509c.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* IBM Plex Mono, latin-ext */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/ibm-plex-mono-latin-ext-77f03e26.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* IBM Plex Mono, latin */
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(/assets/fonts/ibm-plex-mono-latin-a76f53ca.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Sun Serif, latin-ext */
@font-face {
  font-family: "Sun Serif";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/sun-serif-latin-ext-4a77d123.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Sun Serif, latin */
@font-face {
  font-family: "Sun Serif";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/sun-serif-latin-e5958fac.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Sun Serif, latin-ext */
@font-face {
  font-family: "Sun Serif";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/sun-serif-italic-latin-ext-b375dbeb.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Sun Serif, latin */
@font-face {
  font-family: "Sun Serif";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url(/assets/fonts/sun-serif-italic-latin-4aba490c.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Petit Formal Script, latin-ext */
@font-face {
  font-family: "Petit Formal Script";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/petit-formal-script-latin-ext-70abbbc1.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Petit Formal Script, latin */
@font-face {
  font-family: "Petit Formal Script";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/petit-formal-script-latin-afba44cd.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Noto Serif SC, sc */
@font-face {
  font-family: "Noto Serif SC";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/assets/fonts/noto-serif-sc-sc-c9d8f15d.woff2) format("woff2");
  unicode-range: U+5b59, U+71a0, U+8283;
}

@layer tokens, base, layout, components, overrides;

/* ==== tokens ==== */

/* Colour scheme. The page follows the system unless the reader picked a
   scheme with the toggle: an inline script in <head> writes that choice into
   <meta name="color-scheme">, and these rules map the meta back onto the
   color-scheme property, which light-dark() follows. */
@layer tokens {
  :root {
    color-scheme: light dark;

    &:has(> head > meta[name="color-scheme"][content="dark"]) {
      color-scheme: dark;
    }

    &:has(> head > meta[name="color-scheme"][content="light"]) {
      color-scheme: light;
    }

    /* Raw values for each scheme. */
    --surface-light: #f7f5f0;
    --surface-dark: #161b22;
    --ink-light: #292b29;
    --ink-dark: #e6edf3;
    --body-light: #4e534f;
    --body-dark: #c9d1d9;
    /* One step darker than on plain paper so it keeps 4.5:1 over the moving
       colour seen through the glass. */
    --muted-light: #5f655f;
    --muted-dark: #8b949e;
    --metadata-light: #626a60;
    --metadata-dark: #9198a1;
    --news-marker-light: #858d80;
    --news-marker-dark: #6e7681;
    --rule-light: #d9ddd3;
    --rule-dark: #21262d;
    --signal-light: #526b59;
    --signal-dark: #58a6ff;
    --signal-text-light: #46604d;
    --signal-text-dark: #58a6ff;
    /* Page text and paper in dark mode keep their own, slightly warmer
       values. */
    --bg-dark: #0d1117;
    --text-dark: #e6edf3;
    --mid-dark: #c9d1d9;
    --light-dark: #8b949e;
    --glass-fill-light: color-mix(in oklab, var(--surface-light) 58%, transparent);
    --glass-fill-dark: color-mix(in oklab, var(--surface-dark) 52%, transparent);
    --glass-fill-strong-light: color-mix(in oklab, var(--surface-light) 56%, transparent);
    --glass-fill-strong-dark: color-mix(in oklab, var(--surface-dark) 62%, transparent);
    --glass-edge-light: rgba(255, 255, 255, 0.45);
    --glass-edge-dark: rgba(240, 246, 252, 0.07);
    --glass-highlight-light: rgba(255, 255, 255, 0.5);
    --glass-highlight-dark: rgba(240, 246, 252, 0.08);
    --shadow-tone-light: rgba(31, 36, 33, 0.12);
    --shadow-tone-dark: rgba(0, 0, 0, 0.5);
    --pill-fill-light: rgba(255, 255, 255, 0.72);
    --pill-fill-dark: rgba(255, 255, 255, 0.1);
    --fluid-1-light: rgba(178, 202, 170, 0.51);
    --fluid-1-dark: rgba(56, 139, 253, 0.16);
    --fluid-2-light: rgba(226, 206, 168, 0.47);
    --fluid-2-dark: rgba(137, 87, 229, 0.13);
    --fluid-3-light: rgba(224, 186, 176, 0.43);
    --fluid-3-dark: rgba(46, 160, 67, 0.08);
    --fluid-4-light: rgba(170, 192, 214, 0.49);
    --fluid-4-dark: rgba(110, 118, 129, 0.18);

    /* Colours in use. */
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --ink: light-dark(var(--ink-light), var(--ink-dark));
    --body: light-dark(var(--body-light), var(--body-dark));
    --muted: light-dark(var(--muted-light), var(--muted-dark));
    --metadata: light-dark(var(--metadata-light), var(--metadata-dark));
    --news-marker: light-dark(var(--news-marker-light), var(--news-marker-dark));
    --rule: light-dark(var(--rule-light), var(--rule-dark));
    --signal: light-dark(var(--signal-light), var(--signal-dark));
    --signal-text: light-dark(var(--signal-text-light), var(--signal-text-dark));
    --bg: light-dark(var(--surface-light), var(--bg-dark));
    --text: light-dark(var(--ink-light), var(--text-dark));
    --mid: light-dark(var(--body-light), var(--mid-dark));
    --light: light-dark(var(--muted-light), var(--light-dark));
    --glass-fill: light-dark(var(--glass-fill-light), var(--glass-fill-dark));
    --glass-fill-strong: light-dark(var(--glass-fill-strong-light), var(--glass-fill-strong-dark));
    --glass-edge: light-dark(var(--glass-edge-light), var(--glass-edge-dark));
    --glass-highlight: light-dark(var(--glass-highlight-light), var(--glass-highlight-dark));
    --shadow-tone: light-dark(var(--shadow-tone-light), var(--shadow-tone-dark));
    --pill-fill: light-dark(var(--pill-fill-light), var(--pill-fill-dark));
    --fluid-1: light-dark(var(--fluid-1-light), var(--fluid-1-dark));
    --fluid-2: light-dark(var(--fluid-2-light), var(--fluid-2-dark));
    --fluid-3: light-dark(var(--fluid-3-light), var(--fluid-3-dark));
    --fluid-4: light-dark(var(--fluid-4-light), var(--fluid-4-dark));

    --glass-shadow: 0 24px 64px -24px var(--shadow-tone);
    --pill-shadow: 0 2px 12px -4px light-dark(rgba(31, 36, 33, 0.14), rgba(1, 4, 9, 0.5)), inset 0 1px 0 light-dark(rgba(255, 255, 255, 0.7), rgba(240, 246, 252, 0.08));
    --depth-shadow: 0 18px 48px -24px light-dark(rgba(31, 36, 33, 0.16), rgba(0, 0, 0, 0.5));
    --grain-opacity: 0.035;

    --serif: "Sun Serif", Georgia, serif;
    --display-serif: "Sun Serif", Georgia, serif;
    --mono: "IBM Plex Mono", "SFMono-Regular", "Cascadia Mono", Menlo, monospace;

    --rail: 116px;
    --gutter: 32px;
    --measure: 700px;
    --page-inline: clamp(16px, 5vw, 32px);
    --nav-anchor-offset: 72px;
    --nav-top: 12px;
    --scroll-edge: calc(var(--nav-top) + 48px + 20px);

    --glass-blur: blur(28px) saturate(130%);
    --glass-radius: 32px;
    --glass-pad: clamp(24px, 4vw, 48px);
    --sheet-gap: 56px;

    --ease-editorial: cubic-bezier(.22, 1, .36, 1);
    --ease-settle: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-lead: cubic-bezier(0.2, 0.9, 0.25, 1);
    --ease-trail: cubic-bezier(0.6, 0, 0.2, 1);

    @media (max-width: 640px) {
      --rail: 76px;
      --gutter: 16px;
      --nav-anchor-offset: 60px;
      --nav-top: 8px;
      --glass-radius: 24px;
      --glass-pad: 18px;
      --sheet-gap: 44px;
    }

    @media (max-width: 360px) {
      --rail: 68px;
      --gutter: 14px;
    }
  }

  /* Values that are not colours change with the rendered scheme through
     these two selectors: an explicit dark choice, or the dark system scheme
     without an explicit light choice. */
  :root:has(> head > meta[name="color-scheme"][content="dark"]) {
    --grain-opacity: 0.05;
  }

  @media (prefers-color-scheme: dark) {
    :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
      --grain-opacity: 0.05;
    }
  }

  /* Browsers without light-dark() switch the same tokens with the system
     scheme and, where :has() works, with the reader's stored choice. */
  @supports not (color: light-dark(#000, #fff)) {
    :root {
      --surface: var(--surface-light);
      --ink: var(--ink-light);
      --body: var(--body-light);
      --muted: var(--muted-light);
      --metadata: var(--metadata-light);
      --news-marker: var(--news-marker-light);
      --rule: var(--rule-light);
      --signal: var(--signal-light);
      --signal-text: var(--signal-text-light);
      --bg: var(--surface-light);
      --text: var(--ink-light);
      --mid: var(--body-light);
      --light: var(--muted-light);
      --glass-fill: var(--glass-fill-light);
      --glass-fill-strong: var(--glass-fill-strong-light);
      --glass-edge: var(--glass-edge-light);
      --glass-highlight: var(--glass-highlight-light);
      --shadow-tone: var(--shadow-tone-light);
      --pill-fill: var(--pill-fill-light);
      --fluid-1: var(--fluid-1-light);
      --fluid-2: var(--fluid-2-light);
      --fluid-3: var(--fluid-3-light);
      --fluid-4: var(--fluid-4-light);
      --pill-shadow: 0 2px 12px -4px rgba(31, 36, 33, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
      --depth-shadow: 0 18px 48px -24px rgba(31, 36, 33, 0.16);
    }

    @media (prefers-color-scheme: dark) {
      :root {
        --surface: var(--surface-dark);
        --ink: var(--ink-dark);
        --body: var(--body-dark);
        --muted: var(--muted-dark);
        --metadata: var(--metadata-dark);
        --news-marker: var(--news-marker-dark);
        --rule: var(--rule-dark);
        --signal: var(--signal-dark);
        --signal-text: var(--signal-text-dark);
        --bg: var(--bg-dark);
        --text: var(--text-dark);
        --mid: var(--mid-dark);
        --light: var(--light-dark);
        --glass-fill: var(--glass-fill-dark);
        --glass-fill-strong: var(--glass-fill-strong-dark);
        --glass-edge: var(--glass-edge-dark);
        --glass-highlight: var(--glass-highlight-dark);
        --shadow-tone: var(--shadow-tone-dark);
        --pill-fill: var(--pill-fill-dark);
        --fluid-1: var(--fluid-1-dark);
        --fluid-2: var(--fluid-2-dark);
        --fluid-3: var(--fluid-3-dark);
        --fluid-4: var(--fluid-4-dark);
        --pill-shadow: 0 2px 12px -4px rgba(1, 4, 9, 0.5), inset 0 1px 0 rgba(240, 246, 252, 0.08);
        --depth-shadow: 0 18px 48px -24px rgba(0, 0, 0, 0.5);
      }
    }

    :root:has(> head > meta[name="color-scheme"][content="light"]) {
      --surface: var(--surface-light);
      --ink: var(--ink-light);
      --body: var(--body-light);
      --muted: var(--muted-light);
      --metadata: var(--metadata-light);
      --news-marker: var(--news-marker-light);
      --rule: var(--rule-light);
      --signal: var(--signal-light);
      --signal-text: var(--signal-text-light);
      --bg: var(--surface-light);
      --text: var(--ink-light);
      --mid: var(--body-light);
      --light: var(--muted-light);
      --glass-fill: var(--glass-fill-light);
      --glass-fill-strong: var(--glass-fill-strong-light);
      --glass-edge: var(--glass-edge-light);
      --glass-highlight: var(--glass-highlight-light);
      --shadow-tone: var(--shadow-tone-light);
      --pill-fill: var(--pill-fill-light);
      --fluid-1: var(--fluid-1-light);
      --fluid-2: var(--fluid-2-light);
      --fluid-3: var(--fluid-3-light);
      --fluid-4: var(--fluid-4-light);
      --pill-shadow: 0 2px 12px -4px rgba(31, 36, 33, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
      --depth-shadow: 0 18px 48px -24px rgba(31, 36, 33, 0.16);
    }

    :root:has(> head > meta[name="color-scheme"][content="dark"]) {
      --surface: var(--surface-dark);
      --ink: var(--ink-dark);
      --body: var(--body-dark);
      --muted: var(--muted-dark);
      --metadata: var(--metadata-dark);
      --news-marker: var(--news-marker-dark);
      --rule: var(--rule-dark);
      --signal: var(--signal-dark);
      --signal-text: var(--signal-text-dark);
      --bg: var(--bg-dark);
      --text: var(--text-dark);
      --mid: var(--mid-dark);
      --light: var(--light-dark);
      --glass-fill: var(--glass-fill-dark);
      --glass-fill-strong: var(--glass-fill-strong-dark);
      --glass-edge: var(--glass-edge-dark);
      --glass-highlight: var(--glass-highlight-dark);
      --shadow-tone: var(--shadow-tone-dark);
      --pill-fill: var(--pill-fill-dark);
      --fluid-1: var(--fluid-1-dark);
      --fluid-2: var(--fluid-2-dark);
      --fluid-3: var(--fluid-3-dark);
      --fluid-4: var(--fluid-4-dark);
      --pill-shadow: 0 2px 12px -4px rgba(1, 4, 9, 0.5), inset 0 1px 0 rgba(240, 246, 252, 0.08);
      --depth-shadow: 0 18px 48px -24px rgba(0, 0, 0, 0.5);
    }
  }

  @property --pill-left {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
  }

  @property --pill-right {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
  }
}

/* ==== base ==== */

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

  html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--nav-anchor-offset);

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

  body {
    position: relative;
    isolation: isolate;
    margin: 0;
    background: var(--surface);
    color: var(--text);
    font-family: var(--serif);
    font-size: 1.125rem;
    line-height: 1.7;
    font-optical-sizing: auto;
    -webkit-font-smoothing: antialiased;
  }

  a {
    color: var(--text);
    text-decoration: none;
    box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--light) 26%, transparent);
    transition: color 180ms ease, box-shadow 180ms ease, text-decoration-color 180ms ease;

    &:hover {
      box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--signal) 70%, transparent);
    }
  }

  :is(a, button):focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 3px;
  }

  ::selection {
    background: color-mix(in oklab, var(--signal) 36%, var(--bg));
    color: var(--text);
  }

  p {
    margin: 0;
    color: var(--mid);
    overflow-wrap: break-word;

    & + p {
      margin-top: 16px;
    }

    & a {
      overflow-wrap: anywhere;
    }
  }

  time {
    color: var(--metadata);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.55;
    letter-spacing: .01em;
    padding-top: 2px;
  }

  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* ==== layout ==== */

@layer layout {
  .page {
    width: min(100%, calc(1040px + 2 * var(--glass-pad)));
    margin: 0 auto;
    padding: 24px calc(var(--page-inline) + var(--glass-pad)) 96px;

    @media (max-width: 640px) {
      padding-block: 16px 88px;
    }

    @media (max-width: 360px) {
      padding-bottom: 72px;
    }
  }

  /* Content sheet. Every section paints one slice of the same glass sheet on a
     pseudo-element that extends past the section box, so content geometry is
     unchanged; the first and last slices carry the rounded ends. The page has
     the same inline padding to keep the sheet inside the viewport. Slices abut
     without a gap; the divider between sections is drawn above them by
     ::after. */
  .page > section {
    position: relative;
    isolation: isolate;
    padding-block: var(--sheet-gap);

    &.bio {
      padding-top: var(--glass-pad);
    }

    &:last-of-type {
      padding-bottom: var(--glass-pad);
    }

    &:not(:last-of-type)::after {
      content: "";
      position: absolute;
      inset: auto 0 0;
      height: 1px;
      background: var(--rule);
    }

    &::before {
      content: "";
      position: absolute;
      inset: 0 calc(-1 * var(--glass-pad));
      z-index: -1;
      pointer-events: none;
      border-inline: 1px solid var(--glass-edge);
      background-color: var(--glass-fill);
      -webkit-backdrop-filter: var(--glass-blur);
      backdrop-filter: var(--glass-blur);
    }

    &.bio::before {
      border-top: 1px solid var(--glass-edge);
      border-radius: var(--glass-radius) var(--glass-radius) 0 0;
      box-shadow: inset 0 1px 0 var(--glass-highlight);
    }

    &:last-of-type::before {
      border-bottom: 1px solid var(--glass-edge);
      border-radius: 0 0 var(--glass-radius) var(--glass-radius);
      box-shadow: inset 0 -1px 0 rgba(31, 36, 33, 0.03), var(--glass-shadow);
    }

    /* Prose sits in the content column, beside the date rail. */
    &:not(.bio) > p {
      width: min(var(--measure), calc(100% - var(--rail) - var(--gutter)));
      margin-left: calc(var(--rail) + var(--gutter));

      @media (max-width: 640px) {
        width: auto;
        margin-left: 0;
      }
    }
  }

  /* Paper grain over the whole page. */
  body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  /* Fluid colour: four soft muted shapes drift on long, offset loops, so the
     field changes slowly and never repeats a frame you notice. Scrolling only
     turns the whole field a little. It is the fallback for the water light
     drawn by assets/field.js. */
  .fluid {
    position: fixed;
    inset: -10vh -10vw;
    z-index: -2;
    pointer-events: none;
    background:
      radial-gradient(ellipse 95% 72% at 16% 18%, var(--fluid-1), transparent 64%),
      radial-gradient(ellipse 88% 68% at 86% 14%, var(--fluid-2), transparent 62%),
      radial-gradient(ellipse 92% 74% at 80% 86%, var(--fluid-3), transparent 64%),
      radial-gradient(ellipse 86% 68% at 14% 84%, var(--fluid-4), transparent 62%),
      var(--surface);

    :root[data-bg] & {
      display: none;
    }

    @media (prefers-reduced-motion: no-preference) {
      @supports (animation-timeline: scroll()) {
        animation: fluid-turn linear both;
        animation-timeline: scroll(root block);
      }
    }

    > i {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 56vw;
      height: 66vh;
      margin: -33vh 0 0 -28vw;
      border-radius: 50%;
      background: radial-gradient(closest-side, var(--shade), transparent);

      @media (prefers-reduced-motion: no-preference) {
        animation: fluid-drift var(--loop) cubic-bezier(0.45, 0, 0.55, 1) var(--offset) infinite;
      }

      /* With reduced motion each shape rests at a different keyframe
         position, so the four colours stay apart. */
      &:nth-child(1) { --shade: var(--fluid-1); --loop: 84s; --offset: 0s; }
      &:nth-child(2) { --shade: var(--fluid-2); --loop: 102s; --offset: -30s; }
      &:nth-child(3) { --shade: var(--fluid-3); --loop: 118s; --offset: -64s; }
      &:nth-child(4) { --shade: var(--fluid-4); --loop: 136s; --offset: -101s; }

      @media (prefers-reduced-motion: reduce) {
        &:nth-child(1) { transform: translate(-24vw, -18vh); }
        &:nth-child(2) { transform: translate(22vw, -22vh) scale(1.08); }
        &:nth-child(3) { transform: translate(24vw, 20vh) scale(0.94); }
        &:nth-child(4) { transform: translate(-20vw, 22vh) scale(1.04); }
      }
    }
  }

  @keyframes fluid-drift {
    0%, 100% { transform: translate(-24vw, -18vh) scale(1); }
    25% { transform: translate(22vw, -22vh) scale(1.08); }
    50% { transform: translate(24vw, 20vh) scale(0.94); }
    75% { transform: translate(-20vw, 22vh) scale(1.04); }
  }

  @keyframes fluid-turn {
    to { transform: rotate(18deg) translateY(-4vh); }
  }

  /* Water-light page field drawn by assets/field.js. The canvas covers the
     large viewport, so a phone toolbar sliding in or out never resizes it. */
  .field {
    position: fixed;
    inset: 0 0 auto;
    z-index: -1;
    width: 100%;
    height: 100vh;
    height: 100lvh;
    pointer-events: none;
    opacity: 0;
  }

  .field.is-ready {
    opacity: 1;
    transition: opacity 800ms ease-out;
  }

  @media (prefers-reduced-motion: reduce) {
    .field.is-ready {
      transition: none;
    }
  }

  /* Scroll edge: content that scrolls up past the floating navigation softens
     and fades into the page colour, so the window edge never cuts a line of
     text in half. The page script sets is-scrolled; pages without it never
     show the band. */
  body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    z-index: 5;
    height: var(--scroll-edge);
    pointer-events: none;
    background: linear-gradient(
      to bottom,
      color-mix(in oklab, var(--bg) 94%, transparent),
      color-mix(in oklab, var(--bg) 40%, transparent)
    );
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(var(--nav-top) + 24px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(var(--nav-top) + 24px), transparent);
    opacity: 0;
    transition: opacity 240ms var(--ease-settle);
  }

  /* Kept outside the rule above: the nesting selector cannot stand for a
     pseudo-element, so a nested `:root.is-scrolled &` never matches. */
  :root.is-scrolled body::before {
    opacity: 1;
  }

  /* The theme cross-fade (a view transition where supported). */
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 380ms;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
  }

  ::view-transition-old(root) {
    animation-name: theme-fade-out;
  }

  ::view-transition-new(root) {
    animation-name: theme-fade-in;
  }

  @keyframes theme-fade-out {
    to { opacity: 0; }
  }

  @keyframes theme-fade-in {
    from { opacity: 0; }
  }

  :root.theme-transitioning :is(body, .site-nav, .identity, .page > section) {
    transition:
      background-color 180ms ease,
      border-color 180ms ease,
      color 180ms ease;
  }

  /* Scroll reveal: content below the first screen fades up and comes into
     focus as it enters the viewport. The script adds reveal-ready only when
     motion is allowed, so without it every element stays visible. */
  @media (prefers-reduced-motion: no-preference) {
    :root.reveal-ready .reveal {
      transition:
        opacity 1000ms var(--ease-settle) var(--reveal-delay, 0ms),
        transform 1200ms var(--ease-settle) var(--reveal-delay, 0ms),
        filter 900ms var(--ease-settle) var(--reveal-delay, 0ms);

      &:not(.is-in) {
        opacity: 0;
        transform: translateY(14px);
        filter: blur(4px);
      }
    }
  }
}

/* ==== components ==== */

@layer components {
  /* -- Navigation capsule -- */

  .site-nav {
    position: sticky;
    top: var(--nav-top);
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: clamp(12px, 2vw, 24px);
    align-items: center;
    min-height: 48px;
    margin: 0 calc(-1 * var(--glass-pad)) 8px;
    padding: 0 clamp(8px, 1.5vw, 16px) 0 clamp(16px, 2vw, 24px);
    border: 1px solid var(--glass-edge);
    border-radius: 999px;
    background-color: var(--glass-fill-strong);
    box-shadow: inset 0 1px 0 var(--glass-highlight), var(--depth-shadow);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);

    /* Equal side columns centre the section links in the capsule whatever
       the width of the theme label. */
    @media (min-width: 900px) {
      grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
      padding-inline: 20px;
    }

    /* Phones: the links and the toggle share one row spread across the
       capsule. */
    @media (max-width: 640px) {
      display: flex;
      justify-content: space-between;
      gap: 0;
      padding-inline: 14px;
    }

    @media (max-width: 539px) {
      min-height: 44px;
    }
  }

  .site-nav-home,
  .site-nav-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    text-decoration: none;
    text-transform: none;
    white-space: nowrap;
    box-shadow: none;
    transition: color 180ms ease, box-shadow 180ms ease;

    &:hover,
    &.is-active {
      color: var(--text);
      box-shadow: none;
    }

    /* The rail scrolls sideways, so an outside focus ring would be clipped to
       two vertical bars; draw it inside the link instead. */
    &:focus-visible {
      outline-offset: -8px;
      border-radius: 999px;
    }
  }

  /* Nav mark: Petit Formal Script initial with a Cormorant small-cap
     surname. */
  .site-nav-home {
    justify-self: start;
    gap: 0.08em;
    padding-right: 12px;
    color: var(--text);
    font-family: var(--display-serif);
    font-size: 1.125rem;
    font-weight: 400;
    font-variation-settings: "opsz" 48;
    line-height: 1;
    letter-spacing: -0.025em;

    @media (max-width: 640px) {
      display: none;
    }
  }

  .site-nav-initial {
    font-family: "Petit Formal Script", cursive;
    font-size: 1.22em;
    letter-spacing: -0.1em;
    transform: translateY(-0.02em);
  }

  .site-nav-dot {
    margin: 0 0.08em 0 0.035em;
    color: var(--signal);
    font-family: "Petit Formal Script", cursive;
    font-size: 0.48em;
    letter-spacing: 0;
    vertical-align: 0.46em;
  }

  .site-nav-surname {
    margin-left: 0.08em;
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 0.78em;
    font-variant-caps: small-caps;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    transform: translateY(0.02em);
  }

  /* The rail is the indicator's containing block, so the indicator scrolls
     and clips with the links when the rail scrolls on narrow screens. */
  .site-nav-links {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(2px, 0.6vw, 8px);
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;

    @supports not (scrollbar-width: none) {
      &::-webkit-scrollbar {
        display: none;
      }
    }

    @media (max-width: 640px) {
      display: contents;
    }

    a {
      position: relative;
      justify-content: center;
      min-width: 44px;
      padding: 0 clamp(4px, 1.6vw - 6px, 12px);
      color: var(--mid);
      font-family: var(--mono);
      font-size: 0.8125rem;
      line-height: 1.5;
      letter-spacing: 0.045em;

      @media (max-width: 640px) {
        flex: 0 0 auto;
        min-width: 0;
        padding: 0 1px;
        font-size: clamp(0.5625rem, 2.8vw, 0.6875rem);
        letter-spacing: 0;
      }

      /* Hover gives an inactive link a fainter capsule of its own. */
      &::after {
        content: "";
        position: absolute;
        inset: 9px 0;
        border-radius: 999px;
        background: color-mix(in oklab, var(--ink) 4%, transparent);
        opacity: 0;
        transform: scale(0.92);
        transition: opacity 260ms var(--ease-settle), transform 360ms var(--ease-settle);

        @media (max-width: 640px) {
          inset: 9px -6px;
        }

        @media (prefers-reduced-motion: reduce) {
          transform: none;
          transition: opacity 260ms var(--ease-settle);
        }
      }

      &:not(.is-active):hover::after {
        opacity: 1;
        transform: scale(1);
      }
    }
  }

  .nav-label-compact {
    display: none;
  }

  @media (max-width: 640px) {
    .nav-label-full {
      display: none;
    }

    .nav-label-compact {
      display: inline;
    }
  }

  /* The active link sits on one travelling capsule, raised like a segmented
     control thumb. Moving right, the right edge leads and the left edge
     trails; moving left, the reverse. */
  .nav-indicator {
    --pill-bleed: 0px;
    position: absolute;
    top: calc(var(--pill-top, 0px) + 9px);
    left: calc(var(--pill-left) - var(--pill-bleed));
    width: calc(var(--pill-right) - var(--pill-left) + 2 * var(--pill-bleed));
    height: calc(var(--pill-height, 44px) - 18px);
    border-radius: 999px;
    background: var(--pill-fill);
    box-shadow: var(--pill-shadow);
    opacity: 0;
    pointer-events: none;
    transition:
      --pill-left 600ms var(--ease-trail) 30ms,
      --pill-right 440ms var(--ease-lead),
      opacity 280ms ease,
      background-color 180ms ease;

    &[data-direction="left"] {
      transition:
        --pill-left 440ms var(--ease-lead),
        --pill-right 600ms var(--ease-trail) 30ms,
        opacity 280ms ease,
        background-color 180ms ease;
    }

    &.is-instant {
      transition: none;
    }

    &.is-visible {
      opacity: 1;
    }

    @media (max-width: 640px) {
      --pill-bleed: 6px;
    }

    @media (prefers-reduced-motion: reduce) {
      transition: opacity 280ms ease, background-color 180ms ease;
    }
  }

  /* -- Theme toggle -- */

  .theme-toggle {
    position: static;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 2px 0 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--mid);
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.55;
    letter-spacing: 0.05em;
    white-space: nowrap;
    cursor: pointer;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    transition: color 180ms ease, border-color 180ms ease, transform 120ms ease;

    &:hover {
      color: var(--text);
    }

    &:active {
      transform: translateY(1px);

      @media (hover: none), (pointer: coarse) {
        transform: none;
      }

      @media (prefers-reduced-motion: reduce) {
        transform: none;
      }
    }

    &:focus-visible {
      outline-offset: -8px;
      border-radius: 999px;
    }

    @media (max-width: 640px) {
      flex: 0 0 auto;
      gap: 4px;
      min-width: 0;
      padding: 0;
      font-size: clamp(0.5625rem, 2.8vw, 0.6875rem);
      letter-spacing: 0;
    }

    /* Without :has() the stored choice cannot reach the colours. */
    @supports not selector(:has(a)) {
      display: none;
    }
  }

  .theme-toggle-label {
    display: inline-flex;
    align-items: center;
    min-width: 5ch;
    height: 16px;
    line-height: 16px;
    text-align: left;
  }

  /* Inline SVG keeps the toggle independent of font loading on mobile. Both
     icons remain mounted, and the fixed frame prevents layout movement. */
  .theme-toggle-icon {
    position: relative;
    display: inline-block;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
  }

  .theme-icon {
    position: absolute;
    inset: 0;
    display: block;
    width: 16px;
    height: 16px;
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
    transform: rotate(-35deg) scale(0.85);
    transition:
      color 180ms ease,
      opacity 180ms ease,
      transform 240ms cubic-bezier(0.22, 1, 0.36, 1);

    .theme-toggle:focus-visible & {
      color: var(--signal);
    }

    @media (prefers-reduced-motion: reduce) {
      transition: color 180ms ease, opacity 180ms ease;
    }
  }

  /* The toggle shows the rendered scheme: its icon, its label, and the
     action that names the other scheme. */
  .theme-toggle [data-scheme="dark"] {
    display: none;
  }

  .theme-icon-sun {
    opacity: 1;
    transform: none;
  }

  :root:has(> head > meta[name="color-scheme"][content="dark"]) {
    .theme-toggle [data-scheme="light"] { display: none; }
    .theme-toggle .theme-toggle-label[data-scheme="dark"] { display: inline-flex; }
    .theme-toggle .visually-hidden[data-scheme="dark"] { display: inline; }
    .theme-icon-sun { opacity: 0; transform: rotate(-35deg) scale(0.85); }
    .theme-icon-moon { opacity: 1; transform: none; }
  }

  @media (prefers-color-scheme: dark) {
    :root:not(:has(> head > meta[name="color-scheme"][content="light"])) {
      .theme-toggle [data-scheme="light"] { display: none; }
      .theme-toggle .theme-toggle-label[data-scheme="dark"] { display: inline-flex; }
      .theme-toggle .visually-hidden[data-scheme="dark"] { display: inline; }
      .theme-icon-sun { opacity: 0; transform: rotate(-35deg) scale(0.85); }
      .theme-icon-moon { opacity: 1; transform: none; }
    }
  }

  @media (hover: hover) and (pointer: fine) {
    .theme-toggle:hover .theme-icon {
      color: var(--signal);
    }
  }

  /* -- Identity -- */

  .identity {
    position: relative;
    min-height: 192px;
    padding: 56px 0 0;
    margin: 0 0 32px;

    @media (max-width: 980px) {
      min-height: 0;
      margin-bottom: clamp(28px, 4vw, 36px);
      text-align: center;
    }

    @media (max-width: 640px) {
      padding-top: 44px;
      margin-bottom: clamp(22px, 6vw, 28px);
    }

    h1 {
      position: relative;
      display: flex;
      align-items: baseline;
      gap: clamp(32px, 4.5vw, 52px);
      max-width: 900px;
      margin: 0;
      font-family: var(--display-serif);
      font-size: inherit;
      font-weight: 400;
      line-height: 1;
      letter-spacing: 0;
      font-optical-sizing: auto;
      text-wrap: balance;

      @media (max-width: 980px) {
        justify-content: center;
      }

      @media (max-width: 640px) {
        display: block;
        text-align: center;
      }
    }

    .name-en {
      font-size: clamp(3.625rem, 5.2vw, 4.75rem);
      line-height: 1.04;
      letter-spacing: -.035em;
      white-space: nowrap;

      @media (max-width: 640px) {
        display: block;
        font-size: clamp(3rem, 14.3vw, 3.5rem);
      }

      @media (max-width: 360px) {
        font-size: 2.875rem;
      }
    }

    .name-zh {
      color: var(--body);
      font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
      font-size: clamp(2.625rem, 3.8vw, 3.5rem);
      line-height: 1;
      letter-spacing: .055em;
      white-space: nowrap;

      @media (max-width: 640px) {
        display: block;
        margin: 14px 0 0;
        font-size: clamp(2.25rem, 10.4vw, 2.625rem);
      }

      @media (max-width: 360px) {
        font-size: 2.25rem;
      }
    }
  }

  /* The first screen settles in: name, text, then portrait. */
  :is(.identity .name-en, .identity .name-zh, .bio-copy, .bio-portrait-frame) {
    @media (prefers-reduced-motion: no-preference) {
      animation: editorial-enter 480ms var(--ease-editorial) both;
    }
  }

  @media (prefers-reduced-motion: no-preference) {
    .identity .name-zh { animation-delay: 60ms; }
    .bio-copy { animation-delay: 100ms; }
    .bio-portrait-frame { animation-name: portrait-enter; animation-delay: 80ms; }
  }

  @keyframes editorial-enter {
    from { opacity: .45; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
  }

  @keyframes portrait-enter {
    from { opacity: .5; transform: translateY(5px); }
    to { opacity: 1; transform: none; }
  }

  /* -- Biography -- */

  .bio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 208px;
    gap: clamp(36px, 4vw, 48px);
    justify-content: start;
    align-items: start;

    @media (max-width: 980px) {
      grid-template-columns: minmax(0, 38rem);
      justify-content: center;
      gap: 0;
    }

    @media (max-width: 640px) {
      display: block;
    }

    img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      object-position: center;
    }
  }

  .bio-portrait-frame {
    grid-column: 2;
    grid-row: 1;
    width: 208px;
    height: 208px;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;

    @media (max-width: 980px) {
      --portrait-size: clamp(148px, 17vw, 168px);
      grid-column: 1;
      width: var(--portrait-size);
      height: var(--portrait-size);
      margin: 0 auto 32px;
    }

    @media (max-width: 640px) {
      --portrait-size: clamp(128px, 36vw, 144px);
      margin-bottom: 26px;
    }
  }

  .bio-copy {
    display: grid;
    grid-column: 1;
    grid-row: 1;
    gap: 12px;
    width: 100%;

    @media (max-width: 980px) {
      grid-row: 2;
      max-width: 38rem;
    }

    /* Editorial justification on wider measures; narrow phone columns fall
       back to ragged-right text before justification creates rivers. */
    p {
      font-size: 1.125rem;
      line-height: 1.68;
      text-align: justify;
      text-justify: inter-word;
      -webkit-hyphens: auto;
      hyphens: auto;

      @media (max-width: 640px) {
        text-align: left;
        text-wrap: pretty;
        hyphens: none;
      }
    }

    p + p {
      margin-top: 0;
    }
  }

  /* -- Contact links and the Ask entry -- */

  .contact-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    width: 100%;
    margin-top: 4px;
    color: var(--light);
    font-family: var(--mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    letter-spacing: 0.045em;

    @media (max-width: 640px) {
      column-gap: 10px;
    }

    /* Each entry keeps a 44px touch target through an invisible hit area, so
       wrapped rows on narrow screens sit close together. */
    a {
      position: relative;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 3px 0;

      &::before {
        content: "";
        position: absolute;
        inset: -12px -6px;
      }
    }

    a {
      justify-content: center;
      min-width: 44px;
      color: var(--mid);
      text-decoration: none;
      box-shadow: none;
      white-space: nowrap;
      transition: color 180ms ease, transform 220ms var(--ease-editorial);

      &::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        top: calc(50% + 7px);
        height: 1px;
        background: color-mix(in oklab, var(--light) 52%, transparent);
        pointer-events: none;
        transition: background-color 180ms ease;
      }

      &:hover {
        color: var(--text);
        box-shadow: none;
      }

      &:hover::after {
        background: var(--signal);
      }

      &:active {
        transform: translateY(1px);

        @media (prefers-reduced-motion: reduce) {
          transform: none;
        }
      }

      .icon {
        flex: 0 0 auto;
        height: 0.95em;
        fill: currentColor;
      }

      .icon-ai {
        height: 1.05em;
      }
    }
  }

  /* -- Sections and lists -- */

  /* Section heads are display type by default; ?labels=mono restores the
     tracked mono micro-labels. */
  .label {
    display: block;
    margin: 0 0 20px;
    color: var(--text);
    font-family: var(--display-serif);
    font-size: clamp(1.5rem, 1.35rem + 0.6vw, 1.75rem);
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -.015em;
    text-wrap: balance;
  }

  :root[data-labels="mono"] .label {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: .095em;
  }

  .items,
  .papers {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .items li,
  .papers li {
    display: grid;
    align-items: first baseline;

    &:not(:last-child) {
      padding-bottom: 28px;
      margin-bottom: 28px;
      border-bottom: 1px solid var(--rule);
    }

    > div {
      max-width: var(--measure);
    }

    time {
      padding-top: 0;
    }

  }

  .items li {
    grid-template-columns: var(--rail) minmax(0, 1fr);
    gap: var(--gutter);
  }

  .papers li {
    grid-template-columns: clamp(68px, calc(15vw + 20px), 116px) minmax(0, 1fr);
    gap: clamp(14px, calc(5.625vw - 4px), 32px);
  }

  /* Phones: dates move above their entry so the text column gets the
     width. */
  @media (max-width: 640px) {
    .items li,
    .papers li {
      grid-template-columns: minmax(0, 1fr);
      row-gap: 4px;
    }
  }

  /* -- News -- */

  .news-list {
    li {
      grid-template-columns: 10px calc(var(--rail) - 10px) minmax(0, 1fr);
      column-gap: calc(var(--gutter) / 2);

      &:not(:last-child) {
        padding-bottom: 15px;
        margin-bottom: 15px;
      }

      /* News dates start on the same rail as every other date; the marker
         sits in the gutter to their left. */
      @media (min-width: 641px) {
        position: relative;
        grid-template-columns: var(--rail) minmax(0, 1fr);
        column-gap: var(--gutter);
      }

      @media (max-width: 640px) {
        grid-template-columns: minmax(0, 1fr);
      }

      /* Open markers; only the latest entry receives a solid state signal. */
      &::before {
        content: "";
        display: block;
        width: 8px;
        height: 8px;
        margin-top: 7px;
        border: 1px solid var(--news-marker);
        border-radius: 999px;
        align-self: start;
        justify-self: center;

        @media (min-width: 641px) {
          position: absolute;
          left: -18px;
          top: 0;
        }

        @media (max-width: 640px) {
          display: none;
        }
      }

      &.is-latest::before {
        border-color: color-mix(in oklab, var(--signal) 72%, var(--ink));
        background: var(--signal);
      }

      &.is-latest time {
        color: var(--signal-text);
        font-weight: 500;
      }
    }

    time {
      display: block;
      line-height: 1.45;
    }

    p {
      max-width: var(--measure);
      font-size: 1rem;
      line-height: 1.45;
      text-wrap: pretty;
    }
  }

  .full-list {
    margin-top: 32px;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;

    a {
      box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--light) 26%, transparent);
      /* "More" links break between phrases, never inside one. */
      white-space: nowrap;

      &:hover {
        box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--signal) 70%, transparent);
      }
    }

    .as-typed {
      letter-spacing: 0;
      text-transform: none;
    }
  }

  .chev {
    margin: 0 0 0 3px;
    color: var(--signal);
    font-family: var(--mono);
    letter-spacing: 0;
    text-transform: none;
  }

  /* Older news opens and closes by height, and its items fade in one by one.
     The gap above the list belongs to the list, so opening the disclosure
     moves nothing before the height starts to change. */
  .news-older {
    > summary {
      width: min(var(--measure), calc(100% - var(--rail) - var(--gutter)));
      margin-top: 34px;
      margin-left: calc(var(--rail) + var(--gutter));
      list-style: none;
      cursor: pointer;

      &::-webkit-details-marker {
        display: none;
      }

      &:focus-visible {
        outline: 2px solid var(--signal);
        outline-offset: 3px;
        border-radius: 4px;
      }

      @media (max-width: 640px) {
        width: auto;
        margin-left: 0;
      }

      .chev {
        display: inline-block;

        @media (prefers-reduced-motion: no-preference) {
          transition: transform 460ms var(--ease-settle);
        }
      }
    }

    &[open] > summary .chev {
      transform: rotate(90deg);
    }

    @media (hover: hover) and (pointer: fine) {
      &:not([open]) > summary:hover .chev {
        transform: translateX(3px);
      }
    }

    /* Clipped vertically only: the news markers sit left of the column.
       Layout containment stays constant across states, so the list margin
       is part of the animated height. */
    &::details-content {
      overflow: visible clip;
      contain: layout;
    }

    &:not([open])::details-content {
      block-size: 0;
    }

    > .news-list {
      margin-top: 24px;
    }

    @media (prefers-reduced-motion: no-preference) {
      &::details-content {
        interpolate-size: allow-keywords;
        transition: block-size 380ms var(--ease-settle), content-visibility 380ms;
        transition-behavior: allow-discrete;
      }

      &[open]::details-content {
        transition-duration: 520ms;
      }

      > .news-list > li {
        transition: opacity 200ms ease-out, translate 0s 380ms;
      }

      &:not([open]) > .news-list > li {
        opacity: 0;
        translate: 0 8px;
      }

      &[open] > .news-list > li {
        transition: opacity 460ms var(--ease-settle), translate 460ms var(--ease-settle);
        transition-delay: calc(20ms + var(--sibling-index, 1) * 40ms);
        transition-delay: calc(20ms + sibling-index() * 40ms);

        /* Closed content is not rendered, so opening starts from here. */
        @starting-style {
          opacity: 0;
          translate: 0 8px;
        }
      }
    }
  }

  /* -- Publications -- */

  .papers {
    h3 {
      min-width: 0;
      margin: 0 0 6px;
      font-family: var(--display-serif);
      font-size: clamp(1.3125rem, 1.229rem + 0.417vw, 1.5rem);
      font-weight: 400;
      line-height: 1.32;
      letter-spacing: -.015em;
      text-wrap: balance;
    }

    h3 a {
      color: var(--text);
      overflow-wrap: break-word;
      box-shadow: none;
      text-decoration-line: underline;
      text-decoration-color: color-mix(in oklab, var(--ink) 18%, transparent);
      text-decoration-thickness: 2px;
      text-underline-offset: .2em;

      &:hover {
        box-shadow: none;
        text-decoration-color: var(--signal);
      }
    }

    p {
      color: var(--light);
      font-size: 1rem;
      line-height: 1.65;
      text-wrap: pretty;
    }

    p + p {
      margin-top: 4px;
    }

    .pub-links {
      display: flex;
      flex-wrap: wrap;
      align-items: baseline;
      gap: 4px 14px;
      margin-top: 10px;
      font-family: var(--mono);
      font-size: 0.8125rem;
      letter-spacing: 0.01em;
    }
  }

  .pub-me {
    color: var(--text);
    font-weight: 600;
  }

  .bibtex {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    letter-spacing: inherit;
    line-height: inherit;
    cursor: pointer;
    box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--light) 26%, transparent);

    &:hover,
    &.is-copied {
      box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--signal) 70%, transparent);
    }
  }

  /* -- Experience and education -- */

  .stacked-list {
    h3 {
      margin: 0 0 2px;
      color: var(--text);
      font-family: var(--display-serif);
      font-size: clamp(1.3125rem, 1.229rem + 0.417vw, 1.5rem);
      font-weight: 400;
      line-height: 1.3;
      letter-spacing: -.015em;
      text-wrap: balance;
    }

    p {
      text-wrap: pretty;
    }

    .place,
    .place-detail {
      font-size: 1rem;
      line-height: 1.45;
    }

    .place {
      color: var(--text);
    }

    :is(.place, .place-detail) + p,
    h3 + p + p {
      margin-top: 8px;
    }

    .date-range {
      padding-top: 4px;
      line-height: 1.45;

      @media (max-width: 640px) {
        display: flex;
        gap: 0.4em;

        span + span::before {
          content: "– ";
        }
      }

      span {
        display: block;
      }

      &.is-current span:last-child {
        color: var(--signal-text);
        font-weight: 500;
      }
    }
  }

  :is(.place, .place-detail) a {
    box-shadow: none;

    &::after {
      content: "↗";
      margin-left: 2px;
      color: var(--light);
      font-family: var(--mono);
      font-size: 0.78em;
      vertical-align: 0.12em;
    }

    &:hover {
      box-shadow: inset 0 -2px 0 color-mix(in oklab, var(--signal) 70%, transparent);
    }
  }

  #service p {
    text-wrap: pretty;
  }

  /* -- Link previews -- */

  .preview-card {
    position: fixed;
    z-index: 40;
    /* The card fits its content: an address or an iD needs less room than a
       profile with counters. */
    width: max-content;
    min-width: 232px;
    max-width: min(312px, calc(100vw - 24px));
    padding: 14px 18px 15px;
    border: 1px solid var(--glass-edge);
    border-radius: 16px;
    /* Nearly opaque: page text behind the card must not read through it. */
    background-color: color-mix(in oklab, var(--surface) 95%, transparent);
    box-shadow: inset 0 1px 0 var(--glass-highlight), 0 1px 2px rgba(31, 36, 33, 0.05), 0 18px 40px -18px rgba(31, 36, 33, 0.3);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    color: var(--ink);
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.97);
    transform-origin: 50% 0;
    transition: opacity 160ms ease, transform 220ms ease;

    &[data-side="above"] {
      transform: translateY(-6px) scale(0.97);
      transform-origin: 50% 100%;
    }

    &.is-visible {
      pointer-events: auto;
      opacity: 1;
      transform: none;
      transition: opacity 240ms cubic-bezier(0.2, 0, 0, 1), transform 480ms var(--ease-settle);
    }

    /* Between neighbouring links the card slides across and its content
       cross-fades. */
    &.is-moving {
      transition:
        opacity 240ms cubic-bezier(0.2, 0, 0, 1),
        transform 480ms var(--ease-settle),
        left 420ms var(--ease-settle),
        top 420ms var(--ease-settle);
    }

    &.is-moving .preview-body {
      animation: preview-swap 280ms ease;
    }

    p {
      margin: 0;
    }

    @media (prefers-reduced-transparency: reduce) {
      background-color: var(--surface);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }

    @media (prefers-reduced-motion: reduce) {
      &,
      &[data-side="above"] {
        transform: none;
      }

      &,
      &.is-visible,
      &.is-moving {
        transition: opacity 160ms ease;
      }
    }
  }

  @keyframes preview-swap {
    from { opacity: 0; }
  }

  .preview-source {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--metadata);
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    line-height: 1.4;

    .preview-card & {
      margin-bottom: 9px;
    }

    svg {
      flex: 0 0 auto;
      width: 12px;
      height: 12px;
      fill: currentColor;
    }
  }

  .preview-name {
    font-family: var(--display-serif);
    font-size: 1.125rem;
    line-height: 1.25;
    text-wrap: balance;
  }

  .preview-address {
    font-size: 1.0625rem;
    overflow-wrap: anywhere;
  }

  .preview-line {
    color: var(--body);
    font-size: 0.875rem;
    line-height: 1.4;
    text-wrap: pretty;

    .preview-card & {
      margin-top: 3px;
    }
  }

  .preview-action {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    margin: 12px 0 0;
    padding: 10px 0 0;
    border: 0;
    border-top: 1px solid var(--rule);
    background: none;
    color: var(--metadata);
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.03em;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: color 160ms ease;

    &:hover {
      color: var(--ink);
    }

    .preview-card.is-copied & {
      color: var(--signal-text);

      @media (prefers-reduced-motion: no-preference) {
        animation: preview-copied 360ms var(--ease-settle);
      }
    }
  }

  .preview-action-icon {
    flex: 0 0 auto;
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;

    .preview-card.is-copied & path {
      stroke-dasharray: 14;

      @media (prefers-reduced-motion: no-preference) {
        animation: preview-check 320ms 60ms var(--ease-settle) backwards;
      }
    }
  }

  @keyframes preview-copied {
    from { opacity: 0.4; transform: translateY(2px); }
  }

  @keyframes preview-check {
    from { stroke-dashoffset: 14; }
  }

  /* Research interests and bios are plain metadata lines, not chips. */
  .preview-tags {
    color: var(--body);
    font-size: 0.84375rem;
    line-height: 1.45;
    text-wrap: pretty;

    .preview-card & {
      margin-top: 10px;
    }
  }

  .preview-stats {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    margin-top: 12px;
    border-top: 1px solid var(--rule);
  }

  .preview-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 10px;
  }

  .preview-stat-value {
    font-family: var(--display-serif);
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
  }

  .preview-stat-label,
  .preview-meta,
  .preview-foot {
    color: var(--metadata);
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.03em;
    line-height: 1.4;
  }

  .preview-foot {
    .preview-card & {
      margin-top: 12px;
    }
  }

  .preview-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    .preview-card & {
      margin-top: 6px;
    }
  }

  .preview-title {
    font-family: var(--display-serif);
    font-size: 1rem;
    line-height: 1.35;
    text-wrap: balance;
  }

  .preview-authors {
    color: var(--body);
    font-size: 0.8125rem;
    line-height: 1.45;
    text-wrap: pretty;

    .preview-card & {
      margin-top: 8px;
    }

    strong {
      color: var(--ink);
      font-weight: 600;
    }
  }
}

/* ==== overrides ==== */

/* Material fallbacks and print outrank the component styles they replace. */
@layer overrides {
  /* Without backdrop blur, or when the reader asks for less transparency, the
     glass becomes opaque so text contrast never depends on the background. */
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .site-nav,
    .page > section::before {
      background-color: var(--surface);
    }
  }

  @media (prefers-reduced-transparency: reduce) {
    .site-nav,
    .page > section::before {
      background-color: var(--surface);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }

    body::before {
      background: var(--bg);
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }

  @media print {
    body::before,
    body::after,
    .fluid,
    .field {
      display: none;
    }

    .reveal {
      opacity: 1 !important;
      transform: none !important;
      filter: none !important;
    }

    .site-nav,
    .page > section::before {
      border: 0;
      box-shadow: none;
      background: none;
      -webkit-backdrop-filter: none;
      backdrop-filter: none;
    }
  }
}
