/* === Self-hosted fonts (no third-party requests) === */
/* Source Serif 4 variable font, weights 400-700, from Google Fonts v14. */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/source-serif-4-latin.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;
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/source-serif-4-latin-ext.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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-page: #fafaf8;
  --bg-alt: #f6f6f6;
  --bg-sidebar: #fafafa;
  --text: #000000;
  --text-secondary: #5c5c5c;
  --text-muted: #8a8a8a;
  --accent: #3a3a3a;
  --accent-hover: #000000;
  --border: #e2e2e2;
  --border-strong: #cfcfcf;
  --serif: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
  --mono: var(--serif);
  --sans: var(--serif);
  --max-width: 980px;
  --sidebar-width: 320px;
}

html {
  scroll-behavior: smooth;
  /* Disable mobile font boosting — with the CV page's fixed-width
   * viewport, browsers otherwise inflate some text blocks but not
   * others, making font sizes inconsistent. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--serif);
  color: var(--text);
  background: var(--bg-page);
  line-height: 1.7;
  font-size: 17px;
  font-weight: 450;
}

a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 2px; transition: color 0.2s; }
a:hover { color: var(--accent-hover); text-decoration-color: var(--accent-hover); }

/* === Navigation === */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-page);
  padding: 0.55rem 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.06);
}

nav .nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav .nav-name {
  font-weight: 700;
  font-size: 2rem;
  color: var(--text);
  font-family: var(--mono);
  text-decoration: none;
  letter-spacing: -0.01em;
}

nav .nav-links { display: flex; gap: 1.6rem; }
nav .nav-links a {
  font-family: var(--sans);
  color: var(--text-secondary);
  font-size: 1.2rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
nav .nav-links a:hover { color: var(--accent-hover); }
nav .nav-links a.active { color: var(--text); font-weight: 600; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.25rem; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; transition: 0.3s; }

/* === Page Layout === */
.layout {
  max-width: var(--max-width);
  margin: 2.5rem auto;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: 1.3rem;
  padding: 3.5rem 3.5rem 0.5rem;
  align-items: center;
  background: var(--bg-page);
  border-radius: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.06);
}

.layout.no-sidebar {
  grid-template-columns: 1fr;
  padding-left: 5rem;
  padding-right: 5rem;
}
.layout.no-sidebar main {
  max-width: 880px;
  margin: 0 auto;
  width: 100%;
}

/* === Sidebar === */
.sidebar {
  /* Stretch the sidebar to the grid row's full height (= main's height).
   * Without this, the sidebar's height is just its content (photo + info
   * + chat), which leaves no room for the sticky child to actually stick
   * — sticky disengages almost immediately. With stretch, the sticky
   * group inside has the entire main-content height to stick within. */
  align-self: stretch;
  padding-top: 0.4rem;
}

.sidebar-sticky {
  position: sticky;
  top: 5rem;
}

/* NOTE on short-viewport behavior: when the viewport is shorter than the
 * sidebar's content (photo + info + chat pill), the chat pill falls below
 * the fold while sticky-at-top pins the sidebar. Tried several
 * workarounds — sticky-at-bottom, position:fixed, internal scrollbar —
 * each had a worse trade-off (scrolling away with the grid track,
 * breaking the grid layout, or an ugly internal scrollbar). The current
 * default `top: 5rem` is the cleanest. On short viewports the user can
 * still reach the chat pill by scrolling to near the bottom of the page;
 * sticky disengages there and the sidebar moves up with the page. */

.sidebar-photo {
  width: 83%;
  height: auto;
  display: block;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  margin: 0 auto 0.6rem;
}

.sidebar-name {
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0 0 0.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
}
.sidebar-name .speak-btn {
  margin-left: 0.85rem;
  margin-right: 0.1rem;
}
.sidebar-lei {
  font-size: 1rem;
}

.speak-btn {
  background: none;
  border: none;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
  font-family: var(--serif);
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: background 0.1s, color 0.1s;
}
.speak-btn svg {
  color: var(--text-secondary);
  transition: color 0.1s, transform 0.1s;
}
.speak-btn:hover {
  background: rgba(0, 0, 0, 0.035);
  color: var(--accent-hover);
}
.speak-btn:hover svg {
  color: var(--accent-hover);
  transform: scale(1.15);
}
.speak-btn:active svg {
  transform: scale(0.97);
}
.speak-ipa {
  color: var(--text);
  display: inline-block;
  transition: transform 0.1s;
}
.speak-btn:active .speak-ipa {
  transform: scale(0.98);
}

.sidebar-caption {
  font-size: 0.95rem;
  line-height: 1.25;
  margin: 0 0 0.3rem;
  text-align: center;
}

.sidebar-links {
  list-style: none;
  padding: 0;
  margin: 0 0 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
}
.sidebar-links li {
  position: relative;
  padding-left: 0.85rem;
  font-size: 0.95rem;
  line-height: 1.6;
}
.sidebar-links li::before {
  content: "\B7";
  position: absolute;
  left: 0;
  font-weight: 700;
}


.sidebar-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.1rem;
}

/* === Chat / AI Assistant Card === */
.sidebar-chat-slot {
  /* Reserves the pill's vertical space in the sidebar so the photo card
   * doesn't jump when the chat card flies out to position:fixed.
   * Flex-end aligns the card to the right edge so when its width grows
   * past the sidebar's width, it overflows leftward (right edge stays put). */
  margin-top: 1rem;
  min-height: 2.6rem;
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.sidebar-chat-card {
  background: rgba(237, 244, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  /* Anchored at the slot's top-right. Toggle pill is at the top of the
   * card; body grows DOWNWARD below it. The slot's min-height reserves
   * pill-sized space, and the card extends below the slot when expanded
   * (out of the sidebar's flow, so layout stays stable). */
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition:
    width 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    max-width 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    margin 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    background 0.4s ease,
    border-color 0.4s ease,
    box-shadow 0.4s ease;
}


.sidebar-chat-card:not(.collapsed) {
  /* Switch to position: fixed when expanded so the box stays pinned to
   * the viewport — once visible, it doesn't disappear when the user
   * scrolls up. JS sets `top` and `right` inline based on the pill's
   * natural position; on scroll-down it rises with the pill (sticky
   * engaging brings more space below), but on scroll-up it stays put,
   * even if it overlaps the photo or info card behind it. */
  position: fixed;
  background: rgba(237, 244, 255, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-color: var(--border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
  border-radius: 6px;
  z-index: 30;
}

.chat-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  color: var(--text);
  transition: background 0.15s;
  border-radius: 6px;
  position: relative;
  z-index: 2;
}

.chat-toggle:hover { background: transparent; }

.chat-toggle-text {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
}

.chat-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.3s ease, color 0.15s;
}

.sidebar-chat-card:not(.collapsed) .chat-toggle-icon {
  transform: rotate(45deg); /* "+" rotates 45° to look like "×" when expanded */
  color: var(--text);
}

.chat-toggle:hover .chat-toggle-icon { color: var(--text); }

.chat-body {
  /* Inline child of the card. Grows from 0 height via max-height so the
   * card itself appears to expand from the pill instead of a separate
   * panel popping over the top. */
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0 1rem;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
  transition:
    max-height 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    padding 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    opacity 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    visibility 0s linear 0.7s;
}

.sidebar-chat-card:not(.collapsed) .chat-body {
  /* Cap body so the box's top edge stays below the nav bar's bottom
   * border (i.e., never extends above the line under "leihuang.site").
   * 8rem reserves: bottom anchor (1.5rem) + pill (~2.6rem) + nav (~3.3rem)
   * + small buffer. */
  max-height: min(30rem, calc(100vh - 8rem));
  padding: 0.15rem 1rem 0.7rem;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    max-height 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    padding 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    opacity 0.7s cubic-bezier(0.45, 0, 0.2, 1),
    visibility 0s linear 0s;
}

.chat-badge {
  font-size: 0.62rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  padding: 0.05rem 0.35rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.chat-messages {
  height: 320px;
  max-height: 100%;
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.7rem 0.75rem;
  font-size: 0.85rem;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-msg {
  padding: 0.4rem 0.55rem;
  border-radius: 4px;
  word-wrap: break-word;
  white-space: pre-wrap;
  max-width: 92%;
}

.chat-msg-bot {
  background: var(--bg-alt);
  color: var(--text);
  align-self: flex-start;
  text-align: left;
}

.chat-msg-user {
  background: var(--text);
  color: #fff;
  align-self: flex-end;
  text-align: left;
}

.chat-msg-error {
  color: #8a3a3a;
  font-style: italic;
  background: #fbeaea;
}

.chat-msg-thinking {
  color: var(--text-muted);
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 0.4rem;
}

.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 0.82rem;
  background: var(--bg);
  color: var(--text);
}

.chat-form input:focus {
  outline: none;
  border-color: var(--text);
}

.chat-form button {
  padding: 0.42rem 0.7rem;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-form button:hover { background: #000; }
.chat-form button:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-disclaimer {
  font-size: 0.8rem;
  color: #ffffff;
  background: #1a1a1a;
  text-align: center;
  font-family: var(--mono);
  letter-spacing: 0.02em;
  padding: 0.55rem 0.7rem;
  border-radius: 3px;
  line-height: 1.45;
}

.chat-disclaimer-icon {
  color: #f5c542;
  margin-right: 0.25rem;
  font-family: var(--sans);
}

.sidebar-title {
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 600;
  line-height: 1.4;
}

.sidebar-affil {
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.sidebar-contact {
  list-style: none;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.sidebar-contact li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.sidebar-contact li svg {
  flex-shrink: 0;
  margin-top: 0.18rem;
  color: var(--text-muted);
}

.sidebar-contact a {
  color: var(--text-secondary);
  text-decoration: none;
  word-break: break-word;
}

.sidebar-contact a:hover { color: var(--accent-hover); text-decoration: underline; }

/* === Main Content === */
main {
  min-width: 0;
}

main section {
  padding: 0 0 2.5rem;
}

main section:last-of-type {
  padding-bottom: 2.5rem;
}

main section + section {
  border-top: 1px solid var(--border);
  padding-top: 2.25rem;
}

main section h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -0.01em;
  color: var(--text);
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--text);
  display: inline-block;
}

main section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.research-subhead {
  font-size: 0.95rem !important;
  font-weight: 400 !important;
  color: var(--text) !important;
  letter-spacing: 0.08em !important;
  margin-top: 0.5rem;
  margin-bottom: 0.6rem !important;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid var(--border);
}

.research-subhead:not(:first-of-type) {
  margin-top: 2rem;
}

main #about p {
  font-size: 1.03rem;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 0.9rem;
}

main #about strong { font-weight: 700; color: var(--text); }

.sidebar .jm-notice {
  background: #ffffff;
  border-left: 2px solid var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.915rem;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: calc(83% - 0.08rem);
  margin: 0.8rem 8.5% 0 auto;
  box-sizing: border-box;
}

main #cv > .jm-notice {
  text-align: center;
  margin: 0.4rem 0 1.5rem;
}

main #about .about-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
}
main #about .about-list li {
  font-size: 0.94rem;
  color: var(--text);
  line-height: 1.6;
  padding: 0.25rem 0;
  border-bottom: 1px dashed var(--border);
}
main #about .about-list li:last-child { border-bottom: none; }

/* === Papers (minimal list) === */
.paper {
  margin-bottom: 1.1rem;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.55;
}

.paper-line {
  margin: 0;
  padding-left: 1.1rem;
  position: relative;
}

.paper-line::before {
  content: "\25E6";
  position: absolute;
  left: 0;
  font-weight: 700;
}
.paper-line:has(.paper-num)::before { content: none; }
.paper-num { position: absolute; left: 0; font-weight: 600; }

.paper .paper-title {
  font-weight: 700;
}

.paper .paper-venue {
  font-style: italic;
}

.paper .jmp-label {
  font-weight: 700;
}

.paper .paper-link {
  cursor: pointer;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  white-space: nowrap;
}
.paper .paper-link:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
}

.abstract-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.paper-abstract-content {
  display: none;
  margin-top: 0.4rem;
  margin-left: 1.5rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--border-strong);
}
.paper-abstract-content p { margin: 0; }

.abstract-toggle:checked ~ .paper-abstract-content {
  display: block;
}

.paper-meta {
  margin-top: 0.3rem;
  margin-left: 1.5rem;
  padding: 0;
  list-style: none;
}
.paper-meta li {
  position: relative;
  padding-left: 0.85rem;
}
.paper-meta li::before {
  content: "\B7";
  position: absolute;
  left: 0;
  font-weight: 700;
}

/* === CV Section === */
.cv-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  background: var(--text);
  color: #fff;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: var(--mono);
  text-decoration: none;
  transition: background 0.2s;
  margin-bottom: 1.5rem;
}

.cv-download:hover { background: #000; color: #fff; }

.cv-grid {
  display: grid;
  gap: 1.5rem;
}

.cv-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.05rem;
  font-size: 0.95rem;
  line-height: 1.35;
  padding-left: 1rem;
}

.edu-school + .edu-school { margin-top: 0.9rem; }

.edu-school-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.2rem;
}

.cv-item .date { white-space: nowrap; margin-left: 1rem; }

.cv-subitem { padding-left: 1.5rem; }

/* === Teaching === */
.teaching-item { font-size: 0.95rem; }
.teaching-item .date { margin-top: 0.2rem; }

.cv-note {
  font-size: 0.95rem;
  line-height: 1.35;
  margin: 0.3rem 0 0.5rem;
  padding-left: 1rem;
}

.cv-gpa {
  padding-left: 0;
  margin-bottom: 0.7rem;
}

.cv-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cv-list li {
  position: relative;
  padding-left: 0.85rem;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.05rem;
}
.cv-list li::before {
  content: "\B7";
  position: absolute;
  left: 0;
}

.references-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.2rem;
  margin-top: 0.3rem;
  padding-left: 1rem;
}
.references-grid .reference:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}
.reference {
  font-size: 0.95rem;
  line-height: 1.35;
}
.ref-name { font-weight: 700; }
.ref-name .ref-role { font-size: 0.95rem; font-weight: 450; }
.ref-email { margin-top: 0.15rem; }

/* === Skills === */
.skills-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.skill-tag {
  padding: 0.25rem 0.6rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--text);
}

/* === Footer === */
footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* === Responsive === */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem 1.5rem 0;
    margin: 1.5rem 1rem;
    border-radius: 0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(0, 0, 0, 0.05);
  }

  /* Keep mobile padding tight; the wider .no-sidebar desktop padding
   * would otherwise win on specificity. */
  .layout.no-sidebar {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  /* Mobile sidebar is wider than the desktop one, so the forced
   * two-line break in the job-market notice wraps badly — let the
   * text wrap naturally instead. */
  .sidebar .jm-notice br { display: none; }

  /* Wider notice box on mobile (desktop aligns it to the photo). */
  .sidebar .jm-notice {
    width: 92%;
    margin-left: auto;
    margin-right: auto;
  }

  /* CV page (body.cv-fixed): keep the desktop card layout — fixed
   * 980px width, desktop paddings, no wrapping — and let the inline
   * script zoom the card down to fit the screen. Nav/footer stay at
   * normal mobile scale. */
  body.cv-fixed { overflow-x: hidden; }
  body.cv-fixed .layout.no-sidebar {
    /* Narrower than desktop (720px content) so the text-to-date gap
     * shrinks and the scaled-down type ends up larger on screen. */
    width: 784px;
    max-width: 784px;
    margin: 1.5rem auto;
    padding: 3.5rem 2rem 0.5rem;
  }
  body.cv-fixed .layout.no-sidebar main {
    max-width: 720px;
  }
  /* The download link shrinks with the scaled card — boost it so it
   * stays comfortably tappable/readable on phones. */
  body.cv-fixed #cv > .jm-notice {
    font-size: 1.6rem;
  }

  .sidebar {
    position: static;
    max-width: 360px;
    margin: 0 auto;
    text-align: center;
  }

  .sidebar-sticky {
    /* On mobile we want the desktop's photo + sticky-group split to be
     * transparent — children behave as if direct children of .sidebar. */
    display: contents;
  }

  .sidebar-card {
    position: static;
    text-align: center;
  }

  /* Mobile: chat box is hidden entirely. */
  .sidebar-chat-slot {
    display: none;
  }

  .sidebar-contact li { justify-content: center; }

  main section h2 { display: block; }

  nav { padding: 0.4rem 1.25rem; }
  nav .nav-links { display: none; }
  nav .nav-links.active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.98);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
  }
  .nav-toggle { display: block; }
}
