/* =====================================================================
   Open Notes on Visible Aging — qinwenhuang.com
   A flip-through lab notebook. Tabs turn pages; a build-a-peptide app
   is the signature. Sketch icons, ruled paper. Pure static.
   ===================================================================== */

:root {
  --desk:     #ECE7D8;   /* the desk under the notebook */
  --page:     #FBFAF2;   /* notebook paper */
  --page-2:   #FFFFFF;
  --ink:      #21221C;
  --ink-soft: #4A4A40;
  --muted:    #837E6C;
  --line:     #E7E2D0;
  --line-2:   #D8D2BD;
  --rule:     #EAE6D6;   /* ruled lines on paper */
  --margin-red: #E7B9AE; /* the red margin line */

  --c-core: #1F9E84;
  --c-teal: #16A99A;
  --c-bio:  #2FA66A;
  --c-ai:   #2E6FE6;
  --c-tool: #E0A02E;
  --c-skin: #E25E92;
  --c-self: #7E5BD6;
  --c-coral:#F26A3D;

  --primary: #4A4A40;
  --primary-d: #21221C;

  --font-body: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --font-hand: "Caveat", "Bradley Hand", cursive;

  --r: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --flip: cubic-bezier(0.36, 0.1, 0.2, 1);
}

* , *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  background-color: var(--desk);
  background-image:
    radial-gradient(rgba(33,34,28,0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  min-height: 100vh;
}

@media (hover: hover) and (pointer: fine) {
  body { cursor: url("../img/pencil-cursor.svg") 4 28, auto; }
  body a, body button, body [role="button"], body summary { cursor: url("../img/pencil-cursor-active.svg") 4 28, pointer; }
  input, textarea, [contenteditable="true"] { cursor: text; }
}

a { color: var(--primary-d); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
::selection { background: rgba(31,158,132,0.18); }
:focus-visible { outline: 2px solid var(--muted); outline-offset: 3px; border-radius: 5px; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.2; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); }

/* sketch filters */
.sk { filter: url(#sketch); }
.sk-soft { filter: url(#sketchSoft); }

/* =====================================================================
   Top bar
   ===================================================================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.55rem clamp(0.9rem, 3vw, 1.6rem);
  max-width: 1120px; margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .brand-mark { width: 25px; height: 25px; color: var(--primary); flex: none; }
.brand b { font-weight: 650; font-size: 0.92rem; }
.brand .brand-sub { font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); letter-spacing: 0.04em; }
.top-right { display: flex; align-items: center; gap: 1rem; }
.top-right a { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }
.top-right a:hover { color: var(--ink); text-decoration: none; }
@media (max-width: 560px) { .top-right a.hide-sm { display: none; } }

/* =====================================================================
   Notebook shell
   ===================================================================== */
.notebook {
  max-width: 1120px;
  margin: 0.4rem auto 2rem;
  padding: 0 clamp(0.6rem, 3vw, 1.6rem);
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}
@media (max-width: 820px) { .notebook { grid-template-columns: 1fr; } }

/* ---- bookmark tabs (the divider tabs) ---- */
.nb-tabs { display: flex; flex-direction: column; gap: 6px; padding-top: 1.4rem; position: relative; z-index: 3; }
.bm {
  position: relative;
  display: grid; grid-template-columns: 28px 1fr; align-items: center; gap: 0.55rem;
  text-align: left;
  padding: 0.6rem 0.7rem; margin-right: -1px;
  background: color-mix(in srgb, var(--desk) 60%, var(--page));
  border: 1px solid var(--line-2); border-right: none;
  border-radius: 9px 0 0 9px;
  color: var(--ink-soft); font-size: 0.86rem; font-weight: 550;
  transition: background .25s, transform .25s var(--ease), color .25s;
}
.bm:hover { background: color-mix(in srgb, var(--ink) 7%, var(--page)); transform: translateX(2px); }
.bm .bm-ico { width: 22px; height: 22px; color: var(--accent); transition: color .25s, transform .25s var(--ease); }
.bm .bm-no { font-family: var(--font-mono); font-size: 0.6rem; color: var(--muted); }
.bm.active {
  background: var(--page); color: var(--ink); transform: translateX(0);
  box-shadow: -1px 0 0 var(--ink) inset;
}
.bm.active .bm-ico { color: var(--accent); transform: rotate(-4deg) scale(1.06); }
.bm.active .bm-no { color: var(--ink); }

/* mobile: tabs become a horizontal strip */
@media (max-width: 820px) {
  .nb-tabs {
    flex-direction: row; gap: 4px; padding: 0.4rem 0; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .bm {
    grid-template-columns: 20px auto; margin-right: 0; white-space: nowrap;
    border: 1px solid var(--line-2); border-radius: 9px;
  }
  .bm .bm-label { display: none; }
  .bm .bm-no { display: none; }
  .bm.active { box-shadow: 0 0 0 1px var(--ink) inset; }
}

/* ---- the book ---- */
.nb-book {
  position: relative; z-index: 2;
  background: var(--page);
  border: 1px solid var(--line-2);
  border-radius: 2px 12px 12px 2px;
  box-shadow:
    inset 9px 0 14px -12px rgba(33,34,28,0.5),
    0 20px 50px -28px rgba(33,34,28,0.45);
  display: flex; flex-direction: column;
  min-width: 0;
}
/* spiral / stitch binding */
.nb-book::before {
  content: ""; position: absolute; top: 10px; bottom: 10px; left: 7px; width: 4px;
  background: repeating-linear-gradient(var(--line-2) 0 7px, transparent 7px 18px);
  border-radius: 4px; opacity: 0.8; z-index: 5; pointer-events: none;
}
@media (max-width: 820px) { .nb-book { border-radius: 4px; } .nb-book::before { display: none; } }

.book-pages {
  position: relative;
  height: clamp(540px, 74vh, 780px);
  perspective: 2200px;
}
@media (max-width: 820px) { .book-pages { height: auto; min-height: 70vh; } }

/* page: stacked when JS on, flippable */
.page { padding: clamp(1.4rem, 3vw, 2.6rem) clamp(1.3rem, 3vw, 2.4rem) 1.4rem clamp(1.6rem, 3.4vw, 3rem); }
.js .page {
  position: absolute; inset: 0; display: none;
  overflow-y: auto; overflow-x: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transform-origin: left center;
  transition: transform .6s var(--flip), box-shadow .6s var(--flip);
  /* ruled paper */
  background-image:
    linear-gradient(90deg, transparent 38px, var(--margin-red) 38px, var(--margin-red) 39px, transparent 39px),
    repeating-linear-gradient(var(--page) 0 31px, var(--rule) 31px 32px);
  background-attachment: local;
}
@media (max-width: 820px) { .js .page { background-image: repeating-linear-gradient(var(--page) 0 31px, var(--rule) 31px 32px); } }
.js .page.active, .js .page.show { display: block; }
.js .page.turning { box-shadow: 0 0 38px rgba(33,34,28,0.22); z-index: 6; }

/* page chrome (prev / counter / next) */
.nb-chrome {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem clamp(1.3rem, 3vw, 2.4rem); border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--page) 80%, var(--desk));
  border-radius: 0 0 12px 2px;
}
.nb-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.03em;
  color: var(--ink); padding: 0.4rem 0.7rem; border-radius: 7px;
  border: 1px solid var(--line-2); background: var(--page);
  transition: background .2s, transform .2s var(--ease), opacity .2s;
}
.nb-btn:hover { background: var(--desk); }
.nb-btn:disabled { opacity: 0.32; cursor: default; }
.nb-btn.next:hover { transform: translateX(2px); }
.nb-btn.prev:hover { transform: translateX(-2px); }
.nb-count { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.03em; color: var(--muted); }
.nb-count b { color: var(--ink); font-weight: 600; }

/* =====================================================================
   Page content
   ===================================================================== */
.page-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.4rem; }
.ico-sticker {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--page-2));
  border: 1.5px solid color-mix(in srgb, var(--accent) 42%, var(--line-2));
  color: var(--accent);
  transform: rotate(-3deg);
  transition: transform .3s var(--ease);
}
.ico-sticker svg { width: 23px; height: 23px; }
.page:hover .ico-sticker, .page.active .ico-sticker { transform: rotate(2deg); }
.page-kicker { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.page-kicker b { color: var(--ink); font-weight: 600; }
.page h2 { font-size: clamp(1.3rem, 2.6vw, 1.65rem); font-weight: 500; margin: 0.5rem 0 1rem; }
.page h2 em { font-style: normal; font-weight: 700; color: inherit; }
.page p { color: var(--ink-soft); margin: 0 0 1rem; max-width: 60ch; }
.page p.lead { color: var(--ink); font-size: 1.06rem; }
.page p.bio { max-width: 80ch; }
.prof-pic { float: right; width: clamp(96px, 20vw, 132px); height: clamp(96px, 20vw, 132px); border-radius: 50%; object-fit: cover; background: var(--page); border: 1px solid var(--line-2); margin: 0.2rem 0 0.7rem 1.3rem; opacity: 0.9; }
@media (max-width: 600px) { .prof-pic { width: 88px; height: 88px; margin-left: 0.9rem; } }
.quotes-intro { margin-top: 1.6rem; }
.quote { margin: 0.2rem 0 0.9rem; padding-left: 1rem; border-left: 2px solid var(--ink); }
.quote p { font-size: 1.1rem; font-style: italic; color: var(--ink); margin: 0 0 0.25rem; line-height: 1.4; max-width: 60ch; }
.quote[lang^="zh"] p { font-style: normal; font-size: 1.3rem; letter-spacing: 0.04em; }
.quote cite { display: block; font-family: var(--font-mono); font-size: 0.64rem; font-style: normal; color: var(--muted); letter-spacing: 0.02em; }

.callout {
  background: var(--page-2);
  border: 1px solid var(--line-2); border-left: 3px solid var(--ink);
  border-radius: var(--r); padding: 0.85rem 1.05rem; margin: 1.1rem 0;
  font-size: 0.95rem; color: var(--ink-soft); max-width: 60ch;
}
.callout b { color: var(--ink); }

.facts { list-style: none; margin: 1.1rem 0 0; padding: 0; display: grid; gap: 0.5rem; max-width: 60ch; }
.facts li { display: grid; grid-template-columns: 14px 1fr; gap: 0.7rem; align-items: baseline; font-size: 0.95rem; }
.facts li .fdot { width: 9px; height: 9px; border-radius: 50%; margin-top: 0.45rem; background: var(--ink); }
.facts li b { font-weight: 650; color: var(--ink); }
.facts li span { color: var(--muted); }
.qs-intro { margin-bottom: 0.5rem; }
.qs { list-style: none; margin: 0 0 1.3rem; padding: 0; display: grid; gap: 0.75rem; max-width: 62ch; }
.qs li { position: relative; padding-left: 1.4rem; color: var(--ink-soft); line-height: 1.5; }
.qs li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }

/* ---- cover page ---- */
.cover-page { display: flex; flex-direction: column; justify-content: center; }
.js .cover-page.active, .js .cover-page.show { display: flex; }
.cover-page .eyebrow { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.cover-page h1 { font-size: clamp(1.9rem, 5vw, 3rem); font-weight: 500; letter-spacing: -0.025em; margin: 0.8rem 0 0.4rem; line-height: 1.05; }
.cover-page h1 .pin { color: inherit; font-weight: 700; }
.cover-page .cover-byline { font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted); margin: 0 0 1.2rem; }
.cover-page .cover-lede { font-size: 1.15rem; color: var(--ink); max-width: 44ch; margin: 0 0 1.4rem; line-height: 1.45; }
.cover-page .cover-lede b { color: var(--primary-d); }
.cover-meta { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1.8rem; }
.tag { font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-soft); background: var(--page-2); border: 1px solid var(--line-2); border-radius: 100px; padding: 0.22rem 0.62rem; }
.tag.hand { font-family: var(--font-hand); font-size: 1.05rem; color: var(--primary-d); border-style: dashed; }
.cover-start {
  display: inline-flex; align-items: center; gap: 0.55rem; align-self: flex-start;
  font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--ink); color: var(--page); padding: 0.7rem 1.1rem; border-radius: 8px;
  transition: transform .25s var(--ease);
}
.cover-start:hover { transform: translateX(3px); text-decoration: none; }
.cover-doodle { font-family: var(--font-hand); font-size: 1.3rem; color: var(--muted); margin-top: 1.6rem; transform: rotate(-2deg); }
.cover-paw { position: absolute; right: clamp(0.7rem, 3vw, 1.8rem); bottom: clamp(0.7rem, 3vw, 1.4rem); width: clamp(44px, 8vw, 68px); height: auto; pointer-events: none; transform: rotate(8deg); }
@media (max-width: 600px) { .cover-paw { width: 40px; right: 0.55rem; bottom: 0.55rem; } }

/* =====================================================================
   Build-a-peptide app
   ===================================================================== */
.pep { margin-top: 0.6rem; }
.pep-stage {
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--page-2);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.pep-stage-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.7rem; }
.pep-stage-head .seq { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-soft); word-break: break-all; max-width: 70%; }
.pep-stage-head .seq em { color: var(--muted); font-style: normal; }
.pep-tools { display: flex; gap: 0.35rem; }
.pep-tools button {
  font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-soft);
  border: 1px solid var(--line-2); border-radius: 6px; padding: 0.28rem 0.5rem; background: var(--page);
  transition: background .2s, color .2s;
}
.pep-tools button:hover { background: var(--desk); color: var(--ink); }

/* one-screen layout: structure left, palette right */
.pep-grid { display: grid; grid-template-columns: 1.08fr 0.92fr; gap: 1rem; align-items: start; }
@media (max-width: 760px) { .pep-grid { grid-template-columns: 1fr; } }
.pep-left { min-width: 0; }
.pep-right { min-width: 0; display: flex; flex-direction: column; gap: 0.8rem; }

/* view toggle */
.pep-views { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; flex: none; }
.pep-views button { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.03em; padding: 0.3rem 0.62rem; color: var(--muted); background: var(--page); transition: background .2s, color .2s; }
.pep-views button.active { background: var(--ink); color: var(--page); }

/* 3D fold (3Dmol canvas) */
.pep-3d { position: relative; height: 218px; border-radius: 8px; overflow: hidden; background: var(--page-2); }
.pep-3d canvas { display: block; border-radius: 8px; }
.pep-3d .pep-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 1rem; }
.pep-fold { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.55rem; text-align: center; padding: 1rem; }
.pep-foldbtn { font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.03em; color: var(--page); background: var(--ink); padding: 0.62rem 1.05rem; border-radius: 8px; transition: transform .2s var(--ease), background .2s; }
.pep-foldbtn:hover { transform: translateY(-2px); background: var(--primary-d); }
.pep-fold small { font-family: var(--font-mono); font-size: 0.6rem; color: var(--muted); }

/* structure (RDKit svg) — whole molecule fits, centered; zoom + pan */
.pep-structure { position: relative; overflow: hidden; padding: 0.2rem 0; height: 218px; display: flex; align-items: center; justify-content: center; touch-action: none; }
.pep-structure.zoomed { cursor: grab; }
.pep-structure.grabbing { cursor: grabbing; }
.pep-svg-wrap { display: flex; max-width: 100%; }
.pep-svg-wrap svg { display: block; max-width: 100%; max-height: 202px; width: auto; height: auto; }
.pep-zoom { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; gap: 4px; }
.pep-zoom button { width: 26px; height: 26px; border: 1px solid var(--line-2); background: color-mix(in srgb, var(--page) 80%, transparent); border-radius: 6px; font-family: var(--font-mono); font-size: 0.9rem; line-height: 1; color: var(--ink); display: grid; place-items: center; backdrop-filter: blur(2px); transition: background .15s; }
.pep-zoom button:hover { background: var(--desk); }

.pep-cap { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.02em; color: var(--muted); margin: 0.4rem 0.2rem 0; min-height: 1em; line-height: 1.3; }
.pep-cap:empty { margin: 0; }
.pep-note { font-family: var(--font-body); font-size: 0.82rem; color: var(--ink-soft); margin: 0.55rem 0 0; padding: 0.5rem 0.65rem; min-height: 1.1em; line-height: 1.4; background: color-mix(in srgb, var(--c-bio) 7%, var(--page)); border-left: 2px solid var(--c-bio); border-radius: 0 6px 6px 0; }
.pep-tools { margin-top: 0.6rem; }

/* presets */
.pep-presets { border: 1px solid var(--line-2); border-radius: var(--r); background: var(--page-2); padding: 0.7rem 0.8rem; }
.pep-rlabel { font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 0.12rem; }
.pep-preset-hint { display: block; font-size: 0.74rem; color: var(--ink-soft); margin-bottom: 0.55rem; }
.pep-preset-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.preset { font-family: var(--font-body); font-size: 0.76rem; font-weight: 550; color: var(--ink); border: 1px solid var(--line-2); border-radius: 100px; padding: 0.28rem 0.66rem; background: var(--page); transition: background .2s, border-color .2s, transform .2s var(--ease); }
.preset:hover { background: color-mix(in srgb, var(--c-bio) 12%, var(--page)); border-color: color-mix(in srgb, var(--c-bio) 42%, var(--line)); transform: translateY(-1px); }
.preset.active { color: var(--page); background: var(--c-bio); border-color: var(--c-bio); }

.pep-chain {
  display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 0.7rem 0.2rem;
  min-height: 78px;
  -webkit-overflow-scrolling: touch;
}
.pep-empty { color: var(--muted); font-family: var(--font-hand); font-size: 1.3rem; padding: 0.6rem 0.2rem; }
.residue {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; position: relative;
  border: 2px solid var(--rc); background: color-mix(in srgb, var(--rc) 15%, var(--page-2));
  font-family: var(--font-mono); font-weight: 600; font-size: 1rem; color: var(--ink);
}
.residue small { position: absolute; bottom: -16px; font-size: 0.54rem; color: var(--muted); letter-spacing: 0.02em; }
.residue.pop { animation: pop .3s var(--ease); }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.14); } 100% { transform: scale(1); } }
.pep-bond { flex: none; width: 13px; height: 2.5px; background: var(--ink-soft); opacity: 0.55; }

/* readout */
.pep-readout { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; margin: 0.6rem 0 0.4rem; }
@media (max-width: 380px) { .pep-readout { grid-template-columns: repeat(2, 1fr); } }
.metric { border: 1px solid var(--line-2); border-radius: 9px; padding: 0.45rem 0.5rem; background: var(--page-2); }
.metric .m-label { font-family: var(--font-mono); font-size: 0.54rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.metric .m-val { font-size: 1.05rem; font-weight: 650; line-height: 1.1; margin-top: 0.12rem; }
.metric .m-val small { font-size: 0.62rem; color: var(--muted); font-weight: 500; }
.pep-reading { font-family: var(--font-hand); font-size: 1.15rem; color: var(--ink-soft); margin: 0; }
.pep-challenge { margin-top: 0.65rem; padding: 0.6rem 0.7rem; border: 1px dashed var(--line-2); border-radius: 8px; background: var(--page); transition: background .2s, border-color .2s; }
.pep-challenge.complete { border-style: solid; border-color: var(--c-bio); background: color-mix(in srgb, var(--c-bio) 9%, var(--page)); }
.pep-challenge-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.pep-challenge .pep-rlabel { margin: 0; }
.pep-challenge-head button { font-family: var(--font-mono); font-size: 0.58rem; color: var(--muted); padding: 0.1rem 0; }
.pep-challenge-head button:hover { color: var(--ink); }
.pep-challenge p { margin: 0.22rem 0 0; font-size: 0.76rem; line-height: 1.35; color: var(--ink-soft); }
.pep-challenge .pep-challenge-status { font-family: var(--font-mono); font-size: 0.59rem; color: var(--muted); }
.pep-challenge.complete .pep-challenge-status { color: var(--c-bio); font-weight: 600; }
.pep-challenge-wide { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.25rem 1rem; margin: 0.75rem 0; }
.pep-challenge-wide .pep-challenge-head { display: flex; flex-direction: column; align-items: flex-start; gap: 0.18rem; }
.pep-challenge-wide .pep-challenge-copy { min-width: 0; }
.pep-challenge-wide p { margin: 0; }
.pep-challenge-wide .pep-challenge-status { margin-top: 0.14rem; }
@media (max-width: 560px) { .pep-challenge-wide { grid-template-columns: 1fr; gap: 0.35rem; } .pep-challenge-wide .pep-challenge-head { flex-direction: row; align-items: center; justify-content: space-between; } }

/* amino-acid keyboard */
.pep-keyboard .pep-legend { margin: 0 0 0.6rem; gap: 0.38rem 0.52rem; }
.pep-legend { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-bottom: 0.6rem; }
.pep-legend span { font-family: var(--font-mono); font-size: 0.58rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.32rem; }
.pep-legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--lc); }
.pep-palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.38rem; }
@media (max-width: 380px) { .pep-palette { grid-template-columns: repeat(4, 1fr); } }
.aa {
  border: 1.5px solid var(--rc); border-radius: 9px; padding: 0.28rem 0.2rem;
  background: color-mix(in srgb, var(--rc) 9%, var(--page-2));
  display: grid; place-items: center; gap: 0.05rem;
  transition: transform .18s var(--ease), background .18s;
}
.aa:hover { transform: translateY(-3px); background: color-mix(in srgb, var(--rc) 20%, var(--page-2)); }
.aa .aa-c { font-family: var(--font-mono); font-weight: 600; font-size: 0.96rem; color: var(--ink); }
.aa .aa-t { font-family: var(--font-mono); font-size: 0.54rem; color: var(--muted); }

/* =====================================================================
   Pillars accordion (Notes page)
   ===================================================================== */
.pillars { border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--page-2); }
.pillar { border-top: 1px solid var(--line); }
.pillar:first-child { border-top: none; }
.pillar-btn { width: 100%; text-align: left; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 0.7rem; padding: 0.8rem 1rem; transition: background .2s; }
.pillar-btn:hover, .pillar.open .pillar-btn { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.pillar-btn .p-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--page-2); border: 1px solid var(--line-2); color: var(--ink-soft); }
.pillar-btn .p-ico svg { width: 17px; height: 17px; }
.pillar-btn .p-title { font-weight: 600; font-size: 0.98rem; }
.pillar-btn .p-title small { display: block; font-family: var(--font-mono); font-size: 0.6rem; color: var(--muted); font-weight: 400; margin-top: 0.1rem; }
.pillar-btn .p-toggle { font-family: var(--font-mono); color: var(--muted); transition: transform .3s var(--ease); }
.pillar.open .pillar-btn .p-toggle { transform: rotate(45deg); color: var(--ink); }
.pillar-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s var(--ease); }
.pillar.open .pillar-body { grid-template-rows: 1fr; }
.pillar-body > div { overflow: hidden; min-height: 0; }
.pillar-body .pb-pad { padding: 0 1rem 1rem 2.7rem; }
.pillar-body p { font-size: 0.93rem; margin: 0 0 0.7rem; }
.pillar-body ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.pillar-body ul li { font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-soft); border: 1px solid var(--line-2); border-radius: 100px; padding: 0.16rem 0.55rem; background: var(--page); }

/* =====================================================================
   Notes feed
   ===================================================================== */
.note-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.3rem 0 1rem; }
.nf { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.03em; color: var(--muted); border: 1px solid var(--line-2); border-radius: 100px; padding: 0.26rem 0.7rem; background: var(--page); transition: background .2s, color .2s, border-color .2s; }
.nf:hover { color: var(--ink); }
.nf.active { background: var(--ink); color: var(--page); border-color: var(--ink); }
.writing { list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; gap: 1.5rem; max-width: 72ch; }
.writing .w-title { font-size: 1.08rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
.writing .w-title:hover { text-decoration: underline; }
.writing .w-title .arrow { font-size: 0.8em; color: var(--muted); }
.writing .w-meta { display: block; font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); margin-top: 0.2rem; }
.writing .w-sum { color: var(--ink-soft); margin: 0.35rem 0 0; max-width: 70ch; }

/* native note pages (/writing/:slug/) */
.note-page { max-width: 68ch; margin: 0 auto; padding: clamp(2rem, 6vw, 4.5rem) 1.4rem; }
.note-back { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.note-back:hover { color: var(--ink); text-decoration: none; }
.note-back-foot { display: inline-block; margin-top: 2.5rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.note-h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin: 1.4rem 0 0.4rem; }
.note-byline { font-family: var(--font-mono); font-size: 0.66rem; color: var(--muted); margin: 0 0 2rem; }
.note-content { color: var(--ink); font-size: 1.05rem; line-height: 1.72; }
.note-content > :first-child { margin-top: 0; }
.note-content p { margin: 0 0 1.15rem; }
.note-content h2 { font-size: 1.3rem; font-weight: 600; margin: 2.1rem 0 0.7rem; }
.note-content h3 { font-size: 1.1rem; font-weight: 600; margin: 1.7rem 0 0.5rem; }
.note-content a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.note-content img { max-width: 100%; height: auto; border-radius: 8px; }
.note-content blockquote { border-left: 2px solid var(--ink); padding-left: 1rem; margin: 1.3rem 0; color: var(--ink-soft); font-style: italic; }
.note-content ul, .note-content ol { padding-left: 1.4rem; margin: 0 0 1.15rem; }
.note-content li { margin: 0 0 0.4rem; }
.note-content code { font-family: var(--font-mono); font-size: 0.88em; background: var(--page-2); padding: 0.1em 0.35em; border-radius: 4px; }

/* subscribe (Buttondown) */
.subscribe { margin: 2rem 0 0; max-width: 38ch; }
.subscribe-label { display: block; font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem; }
.subscribe-row { display: flex; gap: 0.5rem; }
.subscribe-input { flex: 1; min-width: 0; font-family: var(--font-body); font-size: 0.9rem; color: var(--ink); background: var(--page); border: 1px solid var(--line-2); border-radius: 8px; padding: 0.5rem 0.7rem; }
.subscribe-input:focus { outline: none; border-color: var(--ink); }
.subscribe-btn { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.03em; color: var(--page); background: var(--ink); border: none; border-radius: 8px; padding: 0.5rem 0.9rem; cursor: pointer; white-space: nowrap; transition: opacity .2s; }
.subscribe-btn:hover { opacity: 0.85; }

/* subscribe modal */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1.2rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(33, 34, 28, 0.45); backdrop-filter: blur(2px); }
.modal-panel { position: relative; z-index: 1; width: 100%; max-width: 30rem; background: var(--page); border: 1px solid var(--line-2); border-radius: 14px; padding: 1.7rem 1.5rem 1.5rem; box-shadow: 0 24px 60px -24px rgba(33, 34, 28, 0.5); }
.modal-x { position: absolute; top: 0.5rem; right: 0.7rem; background: none; border: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0.2rem 0.4rem; }
.modal-x:hover { color: var(--ink); }
.modal-title { font-size: 1.2rem; font-weight: 600; margin: 0 0 0.3rem; }
.modal-sub { font-size: 0.9rem; color: var(--ink-soft); margin: 0 0 1.1rem; }
.modal .subscribe { margin: 0; max-width: none; }

/* field notes */
.field-intro { max-width: 56ch; }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; margin-top: 1rem; }
.field-photo { min-width: 0; padding: 0; text-align: left; color: var(--ink); background: none; }
.field-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--line-2); border-radius: 8px; transition: transform .25s var(--ease), box-shadow .25s; }
.field-photo:hover img { transform: translateY(-2px); box-shadow: 0 12px 22px -18px rgba(33, 34, 28, 0.7); }
.field-photo span { display: block; margin: 0.25rem 0.15rem 0; font-family: var(--font-hand); font-size: 1rem; color: var(--ink-soft); }
@media (max-width: 480px) { .field-grid { grid-template-columns: repeat(2, 1fr); } }

/* field-note lightbox */
.lightbox[hidden] { display: none; }
.lightbox { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 1.2rem; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(33, 34, 28, 0.72); backdrop-filter: blur(3px); }
.lightbox-panel { position: relative; z-index: 1; margin: 0; max-width: min(92vw, 900px); max-height: 90vh; }
.lightbox-panel img { display: block; max-width: 100%; max-height: calc(90vh - 3rem); width: auto; margin: 0 auto; border-radius: 8px; box-shadow: 0 24px 70px -24px rgba(0, 0, 0, 0.72); }
.lightbox-panel figcaption { margin-top: 0.45rem; font-family: var(--font-hand); font-size: 1.2rem; color: #fff; text-align: center; }
.lightbox-x { position: absolute; top: 0.25rem; right: 0.25rem; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; color: #fff; background: rgba(33, 34, 28, 0.7); font-size: 1.4rem; line-height: 1; }
.lightbox-x:hover { background: var(--ink); }
.note-card { display: block; border: 1px solid var(--line-2); border-left: 3px solid var(--ink); border-radius: var(--r); background: var(--page-2); padding: 0.85rem 1.05rem; color: var(--ink); transition: transform .2s var(--ease), box-shadow .2s; }
.note-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 12px 26px -20px rgba(33, 34, 28, 0.55); }
.note-top { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.35rem; }
.note-tag { font-family: var(--font-mono); font-size: 0.58rem; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; background: var(--ink); border-radius: 4px; padding: 0.1rem 0.45rem; }
.note-date { font-family: var(--font-mono); font-size: 0.64rem; color: var(--muted); }
.note-title { font-size: 1.05rem; font-weight: 650; line-height: 1.22; margin: 0 0 0.3rem; letter-spacing: -0.01em; }
.note-short { font-size: 0.92rem; color: var(--ink-soft); margin: 0 0 0.5rem; max-width: 66ch; }
.note-link { font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink); display: inline-flex; align-items: center; gap: 0.3rem; }
.note-link .arrow { display: inline-block; transition: transform .2s var(--ease); }
.note-card:hover .note-link .arrow { transform: translate(2px, -2px); }
.note-empty { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 1.1rem 1.2rem; background: var(--page); color: var(--ink-soft); font-size: 0.95rem; }

/* =====================================================================
   Rows (work / publications) + connect links
   ===================================================================== */
.rows { margin-top: 0.4rem; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 1rem; align-items: baseline; padding: 0.85rem 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: none; }
.row .r-name { font-weight: 600; font-size: 1rem; }
.row .r-name a { color: var(--ink); }
.row .r-name a:hover { color: var(--primary-d); }
.row .r-name .r-meta { font-family: var(--font-mono); font-size: 0.62rem; color: var(--muted); margin-left: 0.5rem; }
.row .r-desc { grid-column: 1 / -1; color: var(--ink-soft); font-size: 0.92rem; max-width: 64ch; margin: 0; }
.row .r-link { font-family: var(--font-mono); font-size: 0.68rem; color: var(--primary-d); white-space: nowrap; }
.row .r-link .arrow { display: inline-block; transition: transform .25s var(--ease); }
.row:hover .r-link .arrow { transform: translate(2px,-2px); }
.pub-venue { font-family: var(--font-mono); font-size: 0.58rem; text-transform: uppercase; color: #fff; background: var(--primary-d); border-radius: 4px; padding: 0.12rem 0.4rem; white-space: nowrap; }
.pub-venue.el { background: var(--muted); }
.scholar-link { font-family: var(--font-mono); font-size: 0.7rem; display: inline-block; margin-top: 0.9rem; }

.links { margin-top: 0.4rem; border-top: 1px solid var(--line); }
.links a { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 0.2rem; border-bottom: 1px solid var(--line); color: var(--ink); transition: padding-left .25s var(--ease); }
.links a:hover { text-decoration: none; padding-left: 0.5rem; background: color-mix(in srgb, var(--primary) 5%, transparent); }
.links a .l-left { display: flex; align-items: center; gap: 0.7rem; }
.links a .l-ico { width: 18px; height: 18px; color: var(--muted); }
.links a:hover .l-ico { color: var(--primary-d); }
.links a .l-label { font-weight: 550; }
.links a .l-handle { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }

/* =====================================================================
   Footer
   ===================================================================== */
.foot {
  max-width: 1120px; margin: 0 auto; padding: 1rem clamp(0.9rem,3vw,1.6rem) 2rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.64rem; color: var(--muted);
}
.foot .dot { color: var(--muted); }

/* no-JS: pages just stack and scroll */
.no-js .nb-chrome, .no-js .nb-tabs .bm-no { opacity: 0.5; }
