:root {
  --paper: #f7f5f2;
  --paper-2: #fffefc;
  --ink: #17141a;
  --ink-2: #453f4b;
  --muted: #5d5764;
  --faint: #6f6875;
  --rule: #e3ded7;
  --rule-2: #d5cec5;
  --accent: #9d1b4f;
  --accent-wash: #f6e9ef;
  --fuchsia: #d0177f;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", "Songti SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #100e12;
    --paper-2: #16131a;
    --ink: #ece9ee;
    --ink-2: #bdb7c2;
    --muted: #98919e;
    --faint: #8f8896;
    --rule: #272230;
    --rule-2: #363041;
    --accent: #ef7ba7;
    --accent-wash: #241722;
    --fuchsia: #f25aa8;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 6.5rem; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.85 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 320ms ease, color 320ms ease;
}
a, button, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 3px; }
.skip {
  position: fixed; left: 1rem; top: -4rem; z-index: 50; background: var(--paper-2);
  border: 1px solid var(--rule-2); border-radius: 8px; padding: .5rem .8rem; font-size: 14px;
  transition: top 140ms ease-out;
}
.skip:focus { top: 1rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.shell { max-width: 64rem; margin: 0 auto; padding: 0 1.5rem; }
@media (min-width: 62rem) {
  .shell { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 4.5rem; padding: 0 2.5rem; }
}

.rail { position: sticky; top: 0; align-self: start; padding: 4.5rem 0 2rem; }
@media (max-width: 61.99rem) { .rail { display: none; } }
.mark {
  font-family: var(--serif); font-size: 22px; font-weight: 400; letter-spacing: -.015em;
  display: inline-flex; align-items: baseline;
}
.mark i { font-style: normal; color: var(--accent); }
.rail-sub { font-size: 13.5px; color: var(--muted); margin: .4rem 0 2.4rem; line-height: 1.65; }
.rail nav { display: flex; flex-direction: column; gap: .1rem; position: relative; }
.rail nav a { font-size: 15px; color: var(--muted); padding: .35rem 0 .35rem .75rem; transition: color 130ms ease-out; }
.rail nav a:hover { color: var(--ink); }
.rail nav a[aria-current="page"] { color: var(--ink); font-weight: 500; }

@media (min-width: 62rem) { .mobbar { display: none; } }
@media (max-width: 61.99rem) {
  .mobbar {
    position: sticky; top: 0; z-index: 20; padding: .7rem 1.5rem;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  }
  .mobbar .mark { font-size: 18px; }
  .mobbar nav { display: flex; gap: 1.1rem; font-size: 14px; color: var(--muted); }
}

main { padding: 4.5rem 0 0; min-width: 0; }
@media (max-width: 61.99rem) { main { padding-top: 2.2rem; } }
h1 { font-size: clamp(28px, 4.2vw, 36px); line-height: 1.3; letter-spacing: -.018em; font-weight: 600; margin: 0 0 .5rem; }
.lede { font-size: 16.5px; line-height: 1.8; color: var(--muted); margin: 0 0 2.6rem; max-width: 34rem; }

/* ---------- the molecule panel ---------- */
.panel { border: 1px solid var(--rule); border-radius: 14px; background: var(--paper-2); overflow: hidden; }
.panel-top { display: flex; align-items: center; gap: .2rem; padding: .9rem 1rem 0; flex-wrap: wrap; }
.tabs { position: relative; display: flex; gap: .15rem; flex-wrap: wrap; }
#tab-pill {
  position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 999px;
  background: var(--accent-wash); border: 1px solid var(--rule-2); opacity: 0; pointer-events: none;
}
.tab {
  position: relative; z-index: 1; font: inherit; font-size: 14px; color: var(--muted);
  background: none; border: 0; border-radius: 999px; padding: .4rem .9rem; min-height: 38px; cursor: pointer;
  transition: color 130ms ease-out, transform 110ms ease-out;
}
.tab:hover { color: var(--ink); }
.tab:active { transform: scale(.95); }
.tab[aria-selected="true"] { color: var(--accent); font-weight: 500; }
.panel-formula { margin-left: auto; font-family: var(--mono); font-size: 13px; color: var(--faint); padding-right: .2rem; }

.stage { position: relative; padding: .4rem 1rem 1.1rem; }
svg.mol { display: block; width: 100%; height: 240px; }
svg.mol .b { stroke: var(--ink-2); stroke-width: 1.6; fill: none; stroke-linecap: round; }
svg.mol .b2 { stroke: var(--ink-2); stroke-width: 1.6; fill: none; opacity: .55; }
svg.mol .lab { font: 13px/1 var(--mono); fill: var(--ink-2); }
svg.mol .lab.hi { fill: var(--accent); font-weight: 600; }
svg.mol .dot { fill: var(--ink-2); stroke: none; }
svg.mol .frag { transform-box: fill-box; transform-origin: center; }

.panel-note { padding: 0 1.15rem 1.1rem; font-size: 14.5px; line-height: 1.75; color: var(--muted); max-width: 44rem; }
.panel-note b { color: var(--ink); font-weight: 500; }

.ph { display: flex; align-items: center; gap: .9rem; padding: .9rem 1.15rem; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.ph label { font-family: var(--mono); font-size: 13px; color: var(--faint); }
.ph input[type=range] { flex: 1 1 12rem; min-width: 10rem; accent-color: var(--fuchsia); height: 32px; }
.ph output { font-family: var(--mono); font-size: 13px; color: var(--ink); min-width: 12rem; }
.ph .swatch {
  width: 15px; height: 15px; border-radius: 4px; background: var(--fuchsia);
  border: 1px solid var(--rule-2); opacity: 0;
}
.ph[hidden] { display: none; }

/* ---------- lists ---------- */
section { padding: 3.2rem 0 0; }
.sec-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: .01em; margin: 0; }
.sec-note { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--faint); }
.filters { position: relative; display: flex; flex-wrap: wrap; gap: .15rem; margin-bottom: .5rem; }
#chip-thumb {
  position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 999px;
  background: var(--accent-wash); border: 1px solid var(--rule-2); opacity: 0; pointer-events: none;
}
.chip {
  position: relative; z-index: 1; font: inherit; font-size: 13.5px; color: var(--muted);
  background: none; border: 0; border-radius: 999px; padding: .4rem .9rem; min-height: 38px; cursor: pointer;
  transition: color 130ms ease-out, transform 110ms ease-out;
}
.chip:hover { color: var(--ink); }
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] { color: var(--accent); font-weight: 500; }
.list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.item { border-bottom: 1px solid var(--rule); }
.item[hidden] { display: none; }
.item a {
  display: grid; grid-template-columns: 5.2rem 4.2rem minmax(0, 1fr); gap: 1rem;
  align-items: baseline; padding: .8rem .35rem .8rem 0; min-height: 44px;
  transition: background-color 130ms ease-out;
}
.item.work-row a { grid-template-columns: 5.2rem minmax(0, 1fr) auto; }
.item a:hover { background: var(--paper-2); }
.item a:active { background: var(--accent-wash); }
.meta { font-family: var(--mono); font-size: 12.5px; color: var(--faint); letter-spacing: -.01em; }
.tag { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--accent); text-transform: uppercase; }
.tag.cs { color: #2c6a8f; } .tag.phy { color: #8a6212; }
@media (prefers-color-scheme: dark) { .tag.cs { color: #7cc0e0; } .tag.phy { color: #d9ab5a; } }
.title { font-size: 16.5px; font-weight: 500; letter-spacing: -.008em; line-height: 1.5; }
.title > span {
  background-image: linear-gradient(var(--accent), var(--accent));
  background-repeat: no-repeat; background-position: 0 100%; background-size: 0 1px;
  transition: background-size 240ms cubic-bezier(.22,.61,.36,1);
}
.item a:hover .title > span { background-size: 100% 1px; }
.contact { font-size: 16.5px; color: var(--muted); }
.contact a { color: var(--ink); border-bottom: 1px solid var(--rule-2); padding-bottom: 1px; transition: color 140ms ease-out, border-color 140ms ease-out; }
.contact a:hover { color: var(--accent); border-bottom-color: var(--accent); }
footer { margin-top: 3.6rem; padding: 1.4rem 0 3.5rem; border-top: 1px solid var(--rule); font-size: 13px; color: var(--faint); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .item a, .chip, .tab, .contact a, .title > span, .skip { transition-property: opacity, background-color, border-color, color; transition-duration: 160ms; transform: none !important; }
}
@media (prefers-reduced-transparency: reduce) { .mobbar { background: var(--paper); } }
@media (prefers-contrast: more) {
  :root { --rule: #8b8492; --rule-2: #6f6875; --muted: #453f4b; --faint: #565060; --paper: #ffffff; }
}
@media (max-width: 40rem) {
  body { font-size: 16px; }
  .item a, .item.work-row a { grid-template-columns: 4.4rem minmax(0, 1fr); }
  .item .tag, .item .meta:last-child { grid-column: 2; }
}
