/* =========================================================
   Ziyan Song — personal site
   Minimalist editorial design system
   ========================================================= */

/* ---------- Theme tokens ---------- */
:root {
  --font-serif: "Fraunces", Georgia, "Songti SC", "Noto Serif SC", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  /* Latin letters and digits inside Chinese text come from Fraunces; the
     CJK glyphs fall through to the system Songti / Source Han Serif. */
  --font-zh-serif: "Fraunces", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC",
    "Noto Serif SC", "STSong", "SimSun", serif;
  --font-zh-kai: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "Noto Serif CJK SC", serif;

  --wrap: 1120px;
  --narrow: 720px;
  --radius: 16px;
  --radius-sm: 10px;

  --step: clamp(1rem, 0.92rem + 0.4vw, 1.125rem);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

:root,
[data-theme="light"] {
  --bg: #faf8f3;
  --bg-tint: #f4f0e6;
  --surface: #fffdf8;
  --surface-2: #f6f2e9;
  --ink: #1c1a17;
  --ink-soft: #3a352e;
  --muted: #6b6254;
  --faint: #7b7163;
  --line: #e7e0d1;
  --line-strong: #d8cfba;
  --accent: #b1542e;
  --accent-ink: #8f3f1f;
  --accent-soft: rgba(177, 84, 46, 0.1);
  --code-bg: #f6f1e7;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.04), 0 12px 32px -16px rgba(28, 26, 23, 0.18);
}

[data-theme="dark"] {
  --bg: #14120f;
  --bg-tint: #1a1813;
  --surface: #1d1a15;
  --surface-2: #232019;
  --ink: #ece6da;
  --ink-soft: #d3ccbd;
  --muted: #9c9282;
  --faint: #857c6c;
  --line: #2c2820;
  --line-strong: #3a352b;
  --accent: #e0794c;
  --accent-ink: #ed8a5f;
  --accent-soft: rgba(224, 121, 76, 0.14);
  --code-bg: #201d17;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -20px rgba(0, 0, 0, 0.7);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    transition: none !important;
    animation: none !important;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--step);
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

img {
  max-width: 100%;
  display: block;
}
a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* ---------- Layout helpers ---------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 3rem);
}
/* Shares the wide container's left edge; inner content is capped to a
   comfortable reading measure and left-aligned (no centering jump). */
.wrap--narrow {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 5vw, 3rem);
}
.wrap--narrow > * {
  max-width: var(--narrow);
  margin-inline: auto;
}
main {
  display: block;
  padding-bottom: clamp(4rem, 9vw, 8rem);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 100;
  background: var(--ink);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

.eyebrow {
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 1rem;
}
.eyebrow a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lang-zh,
.lang-zh * {
  font-family: var(--font-sans);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background-color 0.2s var(--ease),
    border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.btn--sm {
  padding: 0.45rem 0.95rem;
  font-size: 0.85rem;
}
.btn--primary {
  background: var(--ink);
  color: var(--bg);
}
.btn--primary:hover {
  background: var(--accent);
}
.btn--ghost {
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.4rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
}
.brand__name {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.site-nav {
  display: flex;
  align-items: center;
}
.nav-list {
  list-style: none;
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1.6vw, 1.5rem);
  padding: 0;
}
.nav-list a {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.35rem 0;
  position: relative;
  transition: color 0.2s var(--ease);
}
.nav-list a:hover {
  color: var(--ink);
}
.nav-list a[aria-current="page"] {
  color: var(--ink);
}
.nav-list a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.theme-toggle {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.theme-toggle:hover {
  border-color: var(--accent);
}
.theme-toggle__icon {
  width: 1rem;
  height: 1rem;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: inset -3px -3px 0 0 var(--surface);
  transition: background-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
[data-theme="dark"] .theme-toggle__icon {
  background: var(--accent);
  box-shadow: none;
}

.nav-toggle {
  display: none;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: clamp(2.5rem, 5vw, 4rem);
  margin-top: clamp(3rem, 8vw, 7rem);
}
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3rem;
  align-items: baseline;
  justify-content: space-between;
}
.site-footer__name {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
}
.site-footer__note {
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer__links {
  display: flex;
  gap: 1.4rem;
}
.site-footer__links a {
  font-size: 0.9rem;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}
.site-footer__links a:hover {
  color: var(--accent);
}
.site-footer__copy {
  width: 100%;
  font-size: 0.78rem;
  color: var(--faint);
  font-family: var(--font-mono);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding-top: clamp(2.5rem, 6vw, 4.75rem);
  padding-bottom: clamp(2.5rem, 6vw, 4.5rem);
  max-width: 920px;
}
.hero__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.7rem, 7vw, 5rem);
  line-height: 1.04;
  letter-spacing: -0.02em;
}
.hero__title em {
  font-style: italic;
  color: var(--accent);
}
.hero__lede {
  margin-top: 1.6rem;
  max-width: 60ch;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.25rem);
  color: var(--ink-soft);
  line-height: 1.7;
}
.hero__epigraph {
  margin-top: 1.5rem;
  padding-left: 1rem;
  border-left: 2px solid var(--accent);
  max-width: 48ch;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.2rem);
  line-height: 1.55;
  color: var(--muted);
}
@media (min-width: 760px) {
  .hero {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 4.4rem);
  }
  .hero__epigraph {
    align-self: flex-end;
    margin-top: auto;
    margin-bottom: clamp(2rem, 6vh, 4rem);
    margin-right: calc(-1 * clamp(0px, 4vw, 2.5rem));
    max-width: 34ch;
    padding-left: 0;
    padding-right: 1rem;
    border-left: 0;
    border-right: 2px solid var(--accent);
    text-align: right;
  }
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.8rem;
}

/* ---------- Section heads ---------- */
.home-section {
  margin-top: clamp(3rem, 7vw, 5.5rem);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.3rem;
  margin-bottom: 1.8rem;
  border-bottom: 1px solid var(--line);
}
.section-head__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.01em;
}
.section-head__more {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.2s var(--ease);
}
.section-head__more:hover {
  color: var(--accent);
}

/* ---------- Project index (hover-preview list) ---------- */
.proj-index {
  display: grid;
  gap: clamp(1.5rem, 4vw, 3.5rem);
}
.proj-index__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.proj-index__row {
  border-bottom: 1px solid var(--line);
  transition: opacity 0.25s var(--ease);
}
.proj-index__link {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.6rem 1rem;
  padding: 1.15rem 0;
}
.proj-index__num {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--faint);
}
.proj-index__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  transition: color 0.2s var(--ease);
}
.proj-index__meta {
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--faint);
}
.proj-index__arrow {
  align-self: center;
  color: var(--faint);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.proj-index__row:hover .proj-index__title {
  color: var(--accent);
}
.proj-index__row:hover .proj-index__arrow {
  opacity: 1;
  color: var(--accent);
}

/* Mobile: inline thumbnail under each row */
.proj-index__thumb {
  display: block;
  margin-bottom: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.proj-index__thumb img {
  display: block;
  width: 100%;
  height: auto;
}
.proj-index__preview {
  display: none;
}

@media (min-width: 860px) {
  .proj-index {
    grid-template-columns: 1fr 1.05fr;
    align-items: start;
  }
  .proj-index__meta {
    grid-column: auto;
    justify-self: end;
    white-space: nowrap;
  }
  .proj-index__link {
    grid-template-columns: auto 1fr auto auto;
  }
  .proj-index__thumb {
    display: none;
  }
  .proj-index__preview {
    display: block;
    position: sticky;
    top: 6rem;
    /* matches the ~2:1 screenshots so the sides aren't cropped */
    aspect-ratio: 2 / 1;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
  }
  .proj-index__pv {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.35s var(--ease);
  }
  .proj-index__pv.is-active {
    opacity: 1;
  }
  .proj-index__pv img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
  }
  .proj-index__pv-ph {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(1.6rem, 4vw, 2.8rem);
  }
  .proj-index__pv-intro {
    font-family: var(--font-serif);
    font-size: clamp(1.25rem, 1.7vw, 1.7rem);
    line-height: 1.45;
    color: var(--ink-soft);
  }
}

/* Dim non-hovered rows (desktop, pointer devices) */
@media (min-width: 860px) and (hover: hover) {
  .proj-index__list:hover .proj-index__row {
    opacity: 0.4;
  }
  .proj-index__list:hover .proj-index__row:hover {
    opacity: 1;
  }
}

/* ---------- Bento grid ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(170px, auto);
  gap: 1.1rem;
}
.bento--preview {
  grid-auto-rows: minmax(190px, auto);
}
.bento-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1.3rem, 2.5vw, 1.8rem);
  transition: border-color 0.25s var(--ease), background-color 0.25s var(--ease);
  grid-column: span 2;
}
.bento-card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}
.bento-card:hover .bento-card__title {
  color: var(--accent);
}
.bento-card__title {
  transition: color 0.2s var(--ease);
}
/* Cards are links */
a.bento-card {
  color: inherit;
}
.bento-card__more {
  margin-top: 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
}
/* Card with a screenshot thumbnail */
.bento-card__media {
  height: clamp(160px, 22vw, 240px);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
  margin-bottom: 1.2rem;
}
.bento-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.bento-card--has-media .bento-card__top {
  margin-bottom: 0;
}
.bento-card--has-media .bento-card__title {
  margin-top: 0.9rem;
}
.bento-card--lg {
  grid-column: span 2;
  grid-row: span 2;
}
.bento-card--wide {
  grid-column: span 2;
}
.bento-card--tall {
  grid-column: span 2;
  grid-row: span 2;
}
.bento-card--sm {
  grid-column: span 2;
}
.bento--preview .bento-card {
  grid-column: span 2;
  grid-row: auto;
}
.bento--preview .bento-card--lg {
  grid-row: span 2;
}
.bento-card--accent {
  background: linear-gradient(150deg, var(--accent-soft), var(--surface) 60%);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}
.bento-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: auto;
}
.bento-card__cat {
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  font-weight: 600;
  color: var(--accent);
}
.bento-card__year {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--faint);
}
.bento-card__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.3rem, 2.5vw, 1.9rem);
  line-height: 1.15;
  margin-top: 1.4rem;
}
.bento-card--lg .bento-card__title,
.bento-card--tall .bento-card__title {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}
.bento-card__blurb {
  margin-top: 0.7rem;
  color: var(--ink-soft);
  font-size: 0.97rem;
  line-height: 1.55;
}
.bento-card__desc {
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}
.taglist {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0;
  margin-top: 1.1rem;
}
.taglist li {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.taglist--sm li {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  background: transparent;
}
.bento-card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.1rem;
}
.bento-card__links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  transition: opacity 0.2s var(--ease);
}
.bento-card__links a:hover {
  opacity: 0.7;
}

/* ---------- Home split (notes + notebook) ---------- */
.home-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
}
.mini-list {
  list-style: none;
  padding: 0;
}
.mini-list li + li {
  border-top: 1px solid var(--line);
}
.mini-list a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.95rem 0;
}
.mini-list a:hover .mini-list__title {
  color: var(--accent);
}
.mini-list__title {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  transition: color 0.2s var(--ease);
}
.mini-list--serif .mini-list__title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
}
.mini-list__date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--faint);
}
.home-fragment {
  margin-top: 1.8rem;
  padding: 1.4rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.home-fragment p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.home-fragment.lang-zh p {
  font-family: var(--font-zh-serif);
  font-style: normal;
}
.home-fragment cite {
  display: block;
  margin-top: 0.7rem;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--faint);
}

/* ---------- Page intros ---------- */
.page-intro {
  padding-top: clamp(2.5rem, 6vw, 4.5rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
}
/* The intro shares the left edge of the list below it; only its text is capped */
.page-intro > * {
  max-width: 760px;
}
.page__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}
/* (was italic Fraunces — kept upright for consistency.
   Re-enable `font-style: italic;` here for the cursive look.) */
.page__title--serif {
  font-style: normal;
}
.page__lede {
  margin-top: 1.2rem;
  font-size: clamp(1.02rem, 1rem + 0.3vw, 1.18rem);
  color: var(--ink-soft);
  line-height: 1.7;
  max-width: 60ch;
}
.page-intro--warm .page__lede {
  font-family: var(--font-serif);
}

/* ---------- Doc list (technical notes index) ---------- */
.doc-list {
  list-style: none;
  padding: 0;
  border-top: 1px solid var(--line);
}
.doc-list__item {
  border-bottom: 1px solid var(--line);
}
.doc-list__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 0;
}
.doc-list__link:hover .doc-list__title {
  color: var(--accent);
}
.doc-list__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.1rem, 1.4vw, 1.3rem);
  line-height: 1.3;
  transition: color 0.2s var(--ease);
}
.doc-list__main .taglist {
  margin-top: 0.7rem;
}
.doc-list__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  text-align: right;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--faint);
}

/* ---------- Writing index (Essays | Notes) ---------- */
.writing-cols {
  display: grid;
  gap: clamp(2.2rem, 5vw, 4rem);
}
.writing-col__head {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  color: var(--accent);
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--line-strong);
}
.writing-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.writing-item {
  border-bottom: 1px solid var(--line);
}
.writing-item a {
  display: block;
  padding: 1.3rem 0;
}
.writing-item__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  line-height: 1.2;
  transition: color 0.2s var(--ease);
}
.writing-item.lang-zh .writing-item__title {
  font-family: var(--font-zh-serif);
}
.writing-item a:hover .writing-item__title {
  color: var(--accent);
}
.writing-item__title--sm {
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
  margin-top: 0.25rem;
}
.writing-item__lede {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}
.writing-item__date {
  display: block;
  margin-top: 0.7rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--faint);
}
.writing-item__date--lead {
  margin-top: 0;
  color: var(--accent);
}

@media (min-width: 820px) {
  .writing-cols {
    grid-template-columns: 1fr 1fr;
  }
  .writing-col--notes {
    border-left: 1px solid var(--line);
    padding-left: clamp(2rem, 4vw, 3.5rem);
  }
}

/* ---------- Prose (shared) ---------- */
.prose {
  --flow: 1.15em;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink-soft);
  overflow-wrap: break-word;
}
/* Vertical rhythm. Bilingual pages wrap each language in .note-version, so
   these rules apply at any depth, not only to direct children of .prose. */
.prose :where(p, ul, ol, dl, blockquote, pre, table, figure) {
  margin-top: var(--flow);
}
.prose :where(h2, h3, h4) + * {
  margin-top: 0.65em;
}
.prose > :first-child,
.prose > div > :first-child,
.prose :where(li, blockquote, td, th) > :first-child {
  margin-top: 0;
}
.prose h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-top: 2.2em;
  text-align: start;
}
.prose h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--ink);
  margin-top: 1.8em;
  text-align: start;
}
.prose h4 {
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
  margin-top: 1.5em;
  text-align: start;
}
.prose h2 + h3,
.prose h3 + h4 {
  margin-top: 0.8em;
}
.prose p,
.prose ul,
.prose ol {
  max-width: 70ch;
}
.prose a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s var(--ease);
}
.prose a:hover {
  text-decoration-color: var(--accent);
}
.prose strong {
  color: var(--ink);
  font-weight: 600;
}
.prose ul,
.prose ol {
  padding-left: 1.4em;
}
.prose li + li {
  margin-top: 0.4em;
}
/* Loose lists (blank lines between items): each item is a small paragraph */
.prose li:has(> p) + li {
  margin-top: 0.8em;
}
.prose li > :where(ul, ol) {
  margin-top: 0.4em;
}
.prose li::marker {
  color: var(--muted);
}
.prose blockquote {
  border-left: 2px solid var(--line-strong);
  padding-left: 1.25rem;
  color: var(--ink-soft);
}
/* An aside: a paragraph written entirely in *emphasis* */
.prose .aside {
  color: var(--muted);
}
/* Chinese has no italic. Emphasis, asides and quotations switch to Kaiti. */
.prose :where(:lang(zh)) :where(em, i) {
  font-style: normal;
  font-family: "Inter", var(--font-zh-kai);
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5em 0;
}
.prose img {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* footnotes */
.prose sup {
  line-height: 0;
}
.prose .footnote-ref a {
  font-family: var(--font-sans);
  font-size: 0.72em;
  font-weight: 500;
  letter-spacing: 0;
  text-decoration: none;
  padding: 0 0.15em;
}
.prose .footnote-ref a:hover {
  text-decoration: underline;
}
.prose .footnotes-sep {
  display: none;
}
.prose .footnotes {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.6;
  letter-spacing: 0;
  text-align: start;
  color: var(--muted);
}
.prose .footnotes ol {
  max-width: none;
}
.prose .footnotes p {
  max-width: none;
}
.prose .footnote-item:target {
  color: var(--ink);
}
.prose .footnote-backref {
  font-family: var(--font-sans);
  text-decoration: none;
  margin-left: 0.25em;
}

/* inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: 0.1em 0.4em;
  border-radius: 6px;
  color: var(--accent-ink);
  word-break: break-word;
}

/* tables */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}
.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.6em 0.9em;
  text-align: left;
}
.prose th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--ink);
}

/* anchored headings */
.prose .header-anchor {
  color: inherit;
  text-decoration: none;
}
.prose h2:hover .header-anchor::after,
.prose h3:hover .header-anchor::after {
  content: " #";
  color: var(--faint);
  font-weight: 400;
}

/* ---------- Note (technical) page ---------- */
.note {
  padding-top: clamp(2.5rem, 6vw, 4rem);
}
.note__head {
  max-width: var(--narrow);
  margin-bottom: 3rem;
}
.note__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
}
.note__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--faint);
}
.note__meta .dot {
  color: var(--line-strong);
}
.note__tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  color: var(--muted);
}

/* Bilingual language switch (segmented control) */
.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px;
  margin-left: auto;
}
.note__meta {
  flex-wrap: wrap;
}
.lang-switch button {
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}
.lang-switch button:hover {
  color: var(--ink);
}
.lang-switch button.is-active {
  background: var(--ink);
  color: var(--bg);
}

.note-version[hidden] {
  display: none;
}

/* Chinese body inside a technical note: a touch more line-height */
.prose--zh-note {
  line-height: 1.85;
  line-break: strict;
}

/* "EN · 中文" marker in the index */
.bilingual-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  white-space: nowrap;
}
.note__body {
  display: grid;
  grid-template-columns: 1fr;
  max-width: var(--narrow);
  position: relative;
}
.toc {
  display: none;
}
.note__foot {
  max-width: var(--narrow);
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.back-link {
  font-size: 0.9rem;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}
.back-link:hover {
  color: var(--accent);
}

/* Doc-style code blocks */
.prose pre[class*="language-"] {
  margin-block: 1.5em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* Fenced blocks without a language (e.g. plain traces) get the same box */
.prose pre:not([class*="language-"]) {
  margin-block: 1.5em;
  padding: 1.1rem 1.3rem;
  overflow: auto;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre;
  tab-size: 2;
}
.prose pre:not([class*="language-"]) code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  padding: 0;
}
.prose pre:not([class*="language-"])::-webkit-scrollbar {
  height: 8px;
}
.prose pre:not([class*="language-"])::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

/* TOC sidebar on wide screens */
@media (min-width: 1080px) {
  .note__body {
    grid-template-columns: minmax(0, 1fr) 220px;
    max-width: 1000px;
    gap: 3.5rem;
    align-items: start;
  }
  .prose--doc {
    order: 1;
  }
  .toc {
    display: block;
    order: 2;
    position: sticky;
    top: 6rem;
    align-self: start;
  }
  .toc__title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    color: var(--faint);
    margin-bottom: 0.9rem;
  }
  .toc__nav {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    border-left: 1px solid var(--line);
  }
  .toc__link {
    font-size: 0.85rem;
    color: var(--muted);
    padding: 0.32rem 0 0.32rem 0.9rem;
    margin-left: -1px;
    border-left: 2px solid transparent;
    line-height: 1.35;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
  }
  .toc__link--h3 {
    padding-left: 1.7rem;
    font-size: 0.8rem;
  }
  .toc__link:hover {
    color: var(--ink);
  }
  .toc__link.is-active {
    color: var(--accent);
    border-color: var(--accent);
  }
}

/* ---------- Essay page ---------- */
.essay {
  padding-top: clamp(2.5rem, 6vw, 4.5rem);
}
/* One reading column: title, meta and body share the same two edges */
.essay.wrap--narrow > * {
  max-width: 40rem;
}
.essay__head {
  margin-bottom: 2.5rem;
}
.essay__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.7rem, 3.2vw, 2.4rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
/* Songti has no medium weight, so a Chinese title needs the bold cut to hold
   its place above the text */
.essay__title:lang(zh),
.note__title:lang(zh) {
  font-family: var(--font-zh-serif);
  font-weight: 600;
  /* CJK glyphs fill the em box, so the same size reads larger than Latin */
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  line-height: 1.35;
  letter-spacing: 0;
  word-break: auto-phrase;
}
.essay__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
}
.prose--essay,
.prose--note {
  --flow: 1em;
  font-family: var(--font-serif);
  font-size: 1.1875rem;
  line-height: 1.7;
  color: var(--ink);
}
.prose--essay :where(p, ul, ol),
.prose--note :where(p, ul, ol) {
  max-width: none;
}
.prose--essay h2,
.prose--note h2 {
  font-size: 1.5rem;
}
/* Drop cap on the opening paragraph of an English essay only */
.prose--essay > div:not(.prose--zh) > p:first-child::first-letter {
  font-size: 3.1em;
  float: left;
  line-height: 0.82;
  padding: 0.07em 0.1em 0 0;
  font-weight: 500;
  color: var(--accent);
}
.prose--zh {
  font-family: var(--font-zh-serif);
  font-size: 1.125rem;
  line-height: 1.9;
  letter-spacing: 0.02em;
  text-align: justify;
  line-break: strict;
  /* Fraunces at 400 is darker than Songti Regular; thin the Latin letters so
     names and numbers don't read as bold. Songti has no such axis and ignores it. */
  font-variation-settings: "wght" 340;
}
.prose--zh :where(h2, h3, h4) {
  font-family: var(--font-zh-serif);
  letter-spacing: 0.02em;
}
.prose--zh :where(h2, h3, h4, strong, b) {
  font-variation-settings: "wght" 560;
}
.prose--zh :where(.footnotes, .footnote-ref) {
  font-variation-settings: normal;
}
.prose--zh :where(em, i),
.prose--zh blockquote {
  font-family: "Fraunces", var(--font-zh-kai);
}
.prose--essay .aside,
.prose--note .aside {
  font-size: 0.94em;
}
/* Kaiti is drawn small in its box; keep it at body size and untracked */
.prose--zh .aside,
.prose--zh blockquote {
  font-size: 1.05em;
  letter-spacing: 0;
}
@media (max-width: 480px) {
  .prose--essay,
  .prose--note {
    font-size: 1.125rem;
  }
  .prose--zh {
    font-size: 1.0625rem;
  }
}
.essay__foot {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

/* ---------- About ---------- */
.about {
  padding-top: clamp(2.5rem, 6vw, 4.5rem);
}
.about__intro {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  align-items: center;
  margin-bottom: 3rem;
}
.about__lede {
  margin-top: 1.2rem;
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 1.1rem + 0.6vw, 1.5rem);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 36ch;
}
.about__portrait-frame {
  width: clamp(150px, 32vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.about__portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
.about__body {
  max-width: var(--narrow);
}
.about__contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

/* Social icon links */
.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}
.social-link:hover {
  color: var(--accent);
}
.social-link svg {
  width: 20px;
  height: 20px;
  display: block;
}
.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}
.resume__social {
  display: flex;
  gap: 0.9rem;
  justify-content: flex-end;
}
@media (min-width: 720px) {
  .about__intro {
    grid-template-columns: 1fr auto;
  }
  .about__portrait {
    justify-self: end;
  }
}

/* Experience (About) */
.about__exp {
  max-width: 72ch;
  margin-top: clamp(2.5rem, 6vw, 3.5rem);
}
.about__exp-title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 1.6rem;
}
.exp + .exp {
  margin-top: 1.9rem;
  padding-top: 1.9rem;
  border-top: 1px solid var(--line);
}
.exp__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem 1rem;
}
.exp__head h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}
.exp__head h3 span {
  color: var(--accent);
  font-weight: 500;
}
.exp__when {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--faint);
  white-space: nowrap;
}
.exp__loc {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.exp ul {
  margin-top: 0.75rem;
  padding-left: 1.2rem;
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.6;
}
.exp li + li {
  margin-top: 0.4rem;
}
.exp li::marker {
  color: var(--faint);
}

/* ---------- Skills ---------- */
.skills {
  max-width: 72ch;
  margin-top: clamp(2.5rem, 6vw, 3.5rem);
}
.skills__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.6rem 2.4rem;
}
.skills__group--wide {
  grid-column: 1 / -1;
}
.skills__label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
.skills__tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0;
  margin: 0;
}
.skills__tags li {
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.42rem 0.72rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease),
    background 0.18s var(--ease), transform 0.18s var(--ease);
}
.skills__tags li:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  transform: translateY(-1px);
}
.skills__tags--accent li {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.skills__tags--accent li:hover {
  border-color: var(--accent);
}
.skills__note {
  margin-top: 1.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- Résumé ---------- */
.resume {
  padding-top: clamp(2.5rem, 6vw, 4rem);
}
.resume__head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  padding-bottom: 1.8rem;
  border-bottom: 2px solid var(--ink);
}
.resume__name {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2rem, 5vw, 2.8rem);
  line-height: 1.05;
}
.resume__role {
  color: var(--muted);
  margin-top: 0.4rem;
}
.resume__head-actions {
  text-align: right;
}
.resume__contact {
  margin-top: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}
.resume__contact a:hover {
  color: var(--accent);
}
.resume__embed {
  margin-top: 2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}
.resume__embed object {
  display: block;
  width: 100%;
  height: 85vh;
  min-height: 600px;
  border: 0;
}
.resume__embed-fallback {
  padding: 2.5rem;
  color: var(--muted);
}
.resume__embed-fallback a {
  color: var(--accent);
  text-decoration: underline;
}
.resume__placeholder {
  margin-top: 1.5rem;
  color: var(--faint);
  font-size: 0.9rem;
}
.resume__section {
  margin-top: 2.5rem;
}
.resume__section-title {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  color: var(--accent);
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.5rem;
}
.resume__entry + .resume__entry {
  margin-top: 1.6rem;
}
.resume__entry-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}
.resume__entry-head h3 {
  font-size: 1.1rem;
  font-weight: 600;
}
.resume__entry-head h3 span {
  color: var(--accent);
  font-weight: 500;
}
.resume__when {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--faint);
  white-space: nowrap;
}
.resume__entry ul {
  margin-top: 0.7rem;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}
.resume__entry li + li {
  margin-top: 0.35rem;
}
.resume__skills {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.resume__skills h4 {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.resume__writing {
  list-style: none;
  padding: 0;
}
.resume__writing li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.resume__writing a:hover {
  color: var(--accent);
}

/* ---------- Project detail page ---------- */
.project {
  padding-top: clamp(2.5rem, 6vw, 4rem);
}
.project__head {
  max-width: 760px;
}
.project__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.1rem, 4.5vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: -0.02em;
}
.project__summary {
  margin-top: 1rem;
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem);
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 46ch;
}
.project__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.6rem;
}

/* Browser-framed live demo */
.project__demo {
  margin-top: 2.5rem;
}
.browser {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.browser__bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.browser__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
}
.browser__url {
  margin-left: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.browser__open {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}
.browser__open:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
/* Screenshot preview */
.browser__shot-link {
  display: block;
}
.browser__shot {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg);
}
/* Scaled live iframe (for sites that allow embedding) */
.browser__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg);
}
.browser__frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 800px;
  border: 0;
  transform-origin: top left;
}
.project__demo-note {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: var(--faint);
}
.project__gallery {
  margin-top: 1.6rem;
  display: grid;
  gap: 1.5rem;
}
.shot {
  margin: 0;
}
.shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.shot figcaption {
  margin-top: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--faint);
}
.project__demo-note a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Body: facts sidebar + prose */
.project__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.2rem;
  margin-top: 2.8rem;
}
.project__facts dl {
  display: grid;
  gap: 1.1rem;
  margin: 0;
}
.project__facts dt {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--faint);
  margin-bottom: 0.25rem;
}
.project__facts dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}
.project__stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.project__stack span {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.related-notes {
  list-style: none;
  padding: 0;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}
.related-notes li {
  border-bottom: 1px solid var(--line);
}
.related-notes a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}
.related-notes a:hover .related-notes__title {
  color: var(--accent);
}
.related-notes__title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  transition: color 0.2s var(--ease);
}
.related-notes__arrow {
  color: var(--faint);
}

.project__foot {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

@media (min-width: 880px) {
  .project__body {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 3.5rem;
    align-items: start;
  }
  .project__facts {
    position: sticky;
    top: 6rem;
    padding-top: 0.4rem;
    border-right: 1px solid var(--line);
    padding-right: 1.5rem;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .bento {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: minmax(160px, auto);
  }
  .bento-card,
  .bento-card--lg,
  .bento-card--wide,
  .bento-card--tall,
  .bento-card--sm,
  .bento--preview .bento-card,
  .bento--preview .bento-card--lg {
    grid-column: span 2;
    grid-row: auto;
  }
  .home-split {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 680px) {
  .site-nav {
    position: relative;
  }
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
  }
  .nav-toggle span {
    display: block;
    height: 2px;
    width: 1.1rem;
    margin-inline: auto;
    background: var(--ink);
    transition: transform 0.2s var(--ease);
  }
  .nav-toggle[aria-expanded="true"] span:first-child {
    transform: translateY(3.5px) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"] span:last-child {
    transform: translateY(-3.5px) rotate(-45deg);
  }
  .nav-list {
    position: absolute;
    top: calc(100% + 0.8rem);
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1.2rem;
    box-shadow: var(--shadow);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease),
      visibility 0.2s;
  }
  .nav-list.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .nav-list a {
    font-size: 1rem;
    padding: 0.5rem 0;
  }
  .nav-list a[aria-current="page"]::after {
    display: none;
  }
  .nav-list__theme {
    margin-top: 0.4rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--line);
    width: 100%;
  }
}

/* ---------- Print (résumé) ---------- */
@media print {
  .site-header,
  .site-footer,
  .resume__head-actions .btn,
  .resume__placeholder {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }
  .resume {
    padding-top: 0;
  }
}
