/* Personality Pharmacology — web edition
   Design principles
   1. The text comes first: a serif tuned for long reading, a 66-character
      measure, generous leading, nothing moving while you read.
   2. One metaphor carries the visuals: the self as a landscape of states,
      drawn as contour lines. No stock brains, pills or glowing synapses.
   3. Colour is information. Each signalling system has one hue, used the same
      way in every chapter, figure and slider. Everything else is ink on paper.
   4. Detail is one tap away, never in the way: sources sit behind small
      numerals, figures can be explored but read fine at rest. */

@font-face { font-family: 'Source Serif'; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(../fonts/source-serif-4-latin-opsz-normal.woff2) format('woff2-variations');
  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'; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(../fonts/source-serif-4-latin-ext-opsz-normal.woff2) format('woff2-variations');
  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; }
@font-face { font-family: 'Source Serif'; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url(../fonts/source-serif-4-latin-opsz-italic.woff2) format('woff2-variations');
  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'; font-style: italic; font-weight: 200 900; font-display: swap;
  src: url(../fonts/source-serif-4-latin-ext-opsz-italic.woff2) format('woff2-variations');
  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; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/inter-latin-wght-normal.woff2) format('woff2-variations');
  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: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(../fonts/inter-latin-ext-wght-normal.woff2) format('woff2-variations');
  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; }

:root {
  --paper: #f7f4ee;
  --paper-2: #efebe2;
  --paper-3: #e6e0d4;
  --ink: #1e1c19;
  --ink-2: #4d4840;
  --ink-3: #807a6f;
  --rule: #dcd5c7;
  --accent: #a2462b;
  --good: #3d7a52;
  --bad: #b2412f;
  --neutral: #8a8579;
  --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 8px 30px rgb(40 30 10 / .08);
  --serif: 'Source Serif', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --measure: 34rem;
  --wide: 52rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161512; --paper-2: #1e1d19; --paper-3: #2a2823;
    --ink: #e8e3d8; --ink-2: #bdb6a8; --ink-3: #8a8478; --rule: #34322c;
    --accent: #e0896a; --good: #7cbf8f; --bad: #ec8a76; --neutral: #9a9488; --tb: .2; --tk: .62;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 30px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #161512; --paper-2: #1e1d19; --paper-3: #2a2823;
  --ink: #e8e3d8; --ink-2: #bdb6a8; --ink-3: #8a8478; --rule: #34322c;
  --accent: #e0896a; --good: #7cbf8f; --bad: #ec8a76; --neutral: #9a9488; --tb: .2; --tk: .62;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 30px rgb(0 0 0 / .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 4rem; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.6;
  font-optical-sizing: auto; font-kerning: normal;
  font-variant-ligatures: common-ligatures; text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
@media (min-width: 720px) { body { font-size: 1.1875rem; line-height: 1.62; } }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: .5rem; background: var(--ink); color: var(--paper); padding: .4rem .8rem; z-index: 99; }
.skip:focus { left: .5rem; }
.muted { color: var(--ink-3); }
button { font: inherit; color: inherit; }

/* ---------- top bar ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 30; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--hue, var(--accent)); }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .55rem var(--gutter); font-family: var(--sans); font-size: .82rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--rule); }
.brand { text-decoration: none; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; font-size: .72rem; color: var(--ink-2); }
.tools { display: flex; gap: .15rem; }
.tool { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 0; border-radius: 50%; background: none; cursor: pointer; color: var(--ink-2); }
.tool:hover { background: var(--paper-2); color: var(--ink); }
.tool svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.tool svg .fill { fill: currentColor; stroke: none; }

/* ---------- terrain ---------- */
.terrain { display: block; width: 100%; height: 100%; }
.terrain path { fill: none; stroke: var(--hue, var(--accent)); stroke-width: 1; vector-effect: non-scaling-stroke;
  stroke-opacity: calc(var(--tb, .14) + var(--lvl) * var(--tk, .5)); stroke-linejoin: round; stroke-linecap: round; }

/* ---------- chapter head ---------- */
.chapter-head { position: relative; margin: 0 0 2.5rem; }
.hero { height: clamp(11rem, 30vw, 20rem); overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent); mask-image: linear-gradient(to bottom, #000 40%, transparent); }
.chapter-head-text { max-width: var(--measure); margin: -4.5rem auto 0; padding: 0 var(--gutter); position: relative; box-sizing: content-box; }
.chapter-head.simple .chapter-head-text { margin-top: 4rem; }
.eyebrow { font-family: var(--sans); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 1.2rem; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.eyebrow a { text-decoration: none; }
.draft-badge { font-family: var(--sans); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 99px; padding: .12rem .55rem; font-weight: 500; white-space: nowrap; }
.chapter-n { font-family: var(--sans); font-weight: 300; font-size: 1rem; color: var(--hue); margin: 0 0 .3rem; letter-spacing: .02em; font-variant-numeric: lining-nums; }
h1, h2, h3 { font-weight: 600; line-height: 1.15; letter-spacing: -.012em; text-wrap: balance; }
.chapter-head h1 { font-size: clamp(2.1rem, 6vw, 3.3rem); margin: 0; font-weight: 600; letter-spacing: -.02em; line-height: 1.05; }
.chapter-sub { font-size: clamp(1.1rem, 2.6vw, 1.35rem); color: var(--ink-2); margin: .8rem 0 0; font-style: italic; line-height: 1.4; text-wrap: balance; }

/* ---------- prose ---------- */
.prose { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); box-sizing: content-box; hyphens: auto; -webkit-hyphens: auto; hanging-punctuation: first; }
.prose p { margin: 0 0 1.1em; text-wrap: pretty; }
.page-chapter .prose > p:first-child::first-line { font-variant-caps: all-small-caps; letter-spacing: .05em; font-weight: 500; }
.prose h2 { font-size: 1.45rem; margin: 2.4em 0 .7em; }
.prose strong { font-weight: 650; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1.2em; }
.prose li { margin-bottom: .35em; }
.prose blockquote { margin: 1.6em 0; padding: 0 0 0 1.2em; border-left: 2px solid var(--hue, var(--accent)); color: var(--ink-2); font-style: italic; }
.term { }
.math { font-family: var(--serif); font-style: normal; font-variant-numeric: lining-nums; letter-spacing: .01em; }
.math i { font-style: italic; }
.display-math { text-align: center; font-size: 1.12em; margin: 1.6em 0 !important; color: var(--ink); overflow-x: auto; hyphens: none; }

/* citations */
.cites { line-height: 0; font-size: .62em; vertical-align: super; margin-left: .08em; }
.cite { font-family: var(--sans); font-weight: 600; text-decoration: none; color: var(--hue, var(--accent)); padding: 0 .12em; border-radius: 3px; cursor: pointer; }
.cite + .cite::before { content: ','; color: var(--ink-3); margin-right: .05em; }
.cite:hover, .cite[aria-expanded="true"] { background: color-mix(in srgb, var(--hue, var(--accent)) 14%, transparent); }
.ref-pop { position: absolute; z-index: 40; max-width: min(24rem, calc(100vw - 2rem)); background: var(--paper); color: var(--ink); border: 1px solid var(--rule);
  box-shadow: var(--shadow); border-radius: 10px; padding: .8rem 1rem; font-family: var(--sans); font-size: .82rem; line-height: 1.45; }
.ref-pop .ref-title { display: block; margin: .15rem 0; font-family: var(--serif); font-size: .98rem; line-height: 1.35; }
.ref-link { color: var(--accent); word-break: break-all; }
.ref-note { display: block; margin-top: .3rem; color: var(--ink-3); }
.endnotes { max-width: var(--measure); margin: 3.5rem auto 0; padding: 1.5rem var(--gutter) 0; box-sizing: content-box; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: .82rem; line-height: 1.5; color: var(--ink-2); }
.endnotes h2 { font-family: var(--sans); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin: 0 0 1rem; }
.endnotes ol { padding-left: 1.5em; margin: 0; }
.endnotes li { margin-bottom: .6rem; padding-left: .3rem; }
.endnotes li:target { background: color-mix(in srgb, var(--hue, var(--accent)) 10%, transparent); border-radius: 4px; }
.endnotes .ref-title { color: var(--ink); }

/* ---------- figures ---------- */
.fig { margin: 2.6rem 0; }
.fig-wide { margin-left: calc(50% - min(50vw, var(--wide) / 2) + var(--gutter) * 0); margin-right: calc(50% - min(50vw, var(--wide) / 2)); }
@media (max-width: 860px) { .fig-wide { margin-left: 0; margin-right: 0; } }
.fig figcaption { font-family: var(--sans); font-size: .8rem; line-height: 1.5; color: var(--ink-2); margin-top: .85rem; max-width: var(--measure); hyphens: manual; }
.fig-no { font-weight: 600; color: var(--hue, var(--accent)); margin-right: .45em; letter-spacing: .02em; }
.fig-title { font-weight: 600; color: var(--ink); }
.fig-toy { color: var(--ink-3); font-style: italic; }
.fig svg.diagram { width: 100%; height: auto; display: block; overflow: visible; }
.widget { background: var(--paper-2); border-radius: 14px; padding: clamp(.9rem, 3vw, 1.4rem); font-family: var(--sans); font-size: .82rem; line-height: 1.4; color: var(--ink-2); hyphens: manual; }
.widget-loading { margin: 0; padding: 2rem 0; text-align: center; color: var(--ink-3); }
.widget svg { display: block; width: 100%; height: auto; overflow: visible; }

/* diagrams share a vocabulary */
.dg-ink { stroke: var(--ink-2); fill: none; stroke-width: 1.3; }
.dg-faint { stroke: var(--rule); fill: none; stroke-width: 1.2; }
.dg-box { fill: var(--paper); stroke: color-mix(in srgb, var(--ink-3) 45%, var(--rule)); stroke-width: 1; }
.dg-boxh { fill: color-mix(in srgb, var(--hue) 13%, var(--paper)); stroke: color-mix(in srgb, var(--hue) 60%, var(--rule)); stroke-width: 1.1; }
.dg-pill { fill: var(--paper); fill-opacity: .92; stroke: color-mix(in srgb, var(--ink-3) 40%, var(--rule)); stroke-width: 1; }
.dg-hue { stroke: var(--hue); fill: none; stroke-width: 1.8; }
.dg-ring { fill: var(--paper); stroke-width: 2.4; }
.dg-huefill { fill: var(--hue); }
.dg-text { fill: var(--ink); font-family: var(--sans); font-size: 15px; }
.dg-small { fill: var(--ink-2); font-family: var(--sans); font-size: 13.5px; }
.dg-label { fill: var(--ink-2); font-family: var(--sans); font-size: 11.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }
.dg-serif { fill: var(--ink); font-family: var(--serif); font-size: 17px; font-style: italic; }
.dg-big { fill: var(--ink); font-family: var(--serif); font-size: 21px; font-style: italic; }
.dg-arrow { stroke: var(--ink-2); fill: none; stroke-width: 1.3; }
.dg-strong { stroke-width: 1.8; }
.dg-ah { fill: var(--ink-2); }
.fig-diagram text.hue { fill: color-mix(in srgb, var(--hue) 75%, var(--ink)); }
/* a halo in the paper colour keeps labels legible where they cross lines */
.fig-diagram svg text { paint-order: stroke; stroke: var(--paper); stroke-width: 4px; stroke-linejoin: round; }
.fig-diagram svg text.nh { stroke: color-mix(in srgb, var(--hue) 13%, var(--paper)); }
.widget .dg-small, .widget .dg-text { font-size: 15px; }
.widget .dg-label { font-size: 12.5px; }
.widget .w-tick { fill: var(--ink-2); font-family: var(--sans); font-size: 12.5px; }
.widget svg text { paint-order: stroke; stroke: var(--paper-2); stroke-width: 3.5px; stroke-linejoin: round; }
.fig-diagram .tc-a { stop-color: var(--hue); stop-opacity: .45; }
.fig-diagram .tc-b { stop-color: var(--hue); stop-opacity: .08; }

/* widget controls */
.w-row { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; align-items: center; margin: .8rem 0 0; }
.w-ctl { display: grid; grid-template-columns: minmax(7rem, auto) 1fr auto; align-items: center; gap: .3rem .8rem; flex: 1 1 15rem; }
.w-ctl label { color: var(--ink-2); font-weight: 500; }
.w-ctl output { font-variant-numeric: tabular-nums; color: var(--ink-3); min-width: 3.2em; text-align: right; font-size: .78rem; }
.w-note { color: var(--ink-3); font-size: .78rem; margin: .7rem 0 0; }
.w-readout { font-family: var(--serif); font-size: 1rem; color: var(--ink); margin: 1.1rem 0 0; line-height: 1.45; min-height: 2.9em; }
.w-readout b { font-weight: 600; }
.w-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .6rem; color: var(--ink-2); font-size: .76rem; }
.w-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .35rem; vertical-align: -.05rem; }
.w-btn { border: 1px solid var(--rule); background: var(--paper); border-radius: 99px; padding: .38rem .9rem; cursor: pointer; font-family: var(--sans); font-size: .78rem; color: var(--ink-2); }
.w-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.w-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.w-seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 99px; padding: 2px; background: var(--paper); }
.w-seg button { border: 0; background: none; border-radius: 99px; padding: .32rem .8rem; cursor: pointer; font-size: .78rem; color: var(--ink-2); font-family: var(--sans); }
.w-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 1.6rem; background: none; cursor: pointer; --c: var(--ink-2); margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, var(--c) var(--p, 50%), var(--rule) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--rule); }
input[type=range]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--c); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: var(--paper); border: 2px solid var(--c); margin-top: -.42rem; box-shadow: 0 1px 3px rgb(0 0 0 / .15); }
input[type=range]::-moz-range-thumb { width: .9rem; height: .9rem; border-radius: 50%; background: var(--paper); border: 2px solid var(--c); }
input[type=range].centered::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--rule) min(50%, var(--p)), var(--c) min(50%, var(--p)), var(--c) max(50%, var(--p)), var(--rule) max(50%, var(--p))); }

@media (max-width: 560px) {
  .widget .dg-small, .widget .dg-text { font-size: 22px; }
  .widget .dg-label { font-size: 18px; }
  .widget .w-tick { font-size: 17px; }
  .fig-diagram .dg-small { font-size: 16px; } .fig-diagram .dg-text { font-size: 17.5px; }
  .fig-diagram .dg-label { font-size: 13px; } .fig-diagram .dg-serif { font-size: 19px; } .fig-diagram .dg-big { font-size: 24px; }
}
/* console */
.console { display: grid; gap: 1.4rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .console { grid-template-columns: minmax(15rem, 1fr) minmax(16rem, 1.15fr); } }
.console-sys { display: grid; gap: .1rem; }
.sys-row { display: grid; grid-template-columns: 9rem 1fr; align-items: center; gap: .6rem; }
.sys-row label { font-weight: 500; color: var(--ink); font-size: .8rem; display: flex; align-items: center; gap: .45rem; line-height: 1.15; }
.sys-row label i { width: .55rem; height: .55rem; border-radius: 50%; flex: none; }
.console-presets { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .9rem; }
.trait-bars { display: grid; gap: .45rem; }
.trait { display: grid; grid-template-columns: 1fr; gap: .15rem; }
.trait-name { display: flex; justify-content: space-between; font-size: .76rem; color: var(--ink-2); }
.trait-name b { color: var(--ink); font-weight: 500; }
.trait-track { position: relative; height: 8px; background: var(--paper-3); border-radius: 8px; }
.trait-track::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink-3); opacity: .5; }
.trait-fill { position: absolute; top: 0; bottom: 0; border-radius: 8px; transition: left .25s, width .25s; }
.console-land { height: 9.5rem; margin: -.4rem 0 .6rem; border-radius: 10px; overflow: hidden; }
.widget .console-land svg.terrain { height: 100%; }
.console-land .terrain path { stroke: var(--land, var(--accent)); }

/* ---------- home ---------- */
.cover { position: relative; min-height: min(88vh, 52rem); display: grid; align-items: end; overflow: hidden; }
.cover-terrain { position: absolute; inset: 0; }
.cover-terrain .terrain path { stroke: var(--accent); }
.cover-text { position: relative; padding: 0 var(--gutter) clamp(3rem, 10vh, 6rem); max-width: 60rem; margin: 0 auto; width: 100%; }
.cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, var(--paper) 15%, color-mix(in srgb, var(--paper) 40%, transparent) 55%, transparent); pointer-events: none; }
.cover-text { z-index: 1; }
.book-title { font-size: clamp(3rem, 11vw, 7rem); line-height: .95; letter-spacing: -.035em; margin: 0; font-weight: 600; }
.book-sub { font-size: clamp(1.15rem, 3vw, 1.6rem); font-style: italic; color: var(--ink-2); margin: 1rem 0 2rem; }
.start { display: inline-block; font-family: var(--sans); font-size: .85rem; font-weight: 600; letter-spacing: .02em; text-decoration: none; background: var(--ink); color: var(--paper); padding: .8rem 1.4rem; border-radius: 99px; }
.start:hover { background: var(--accent); color: var(--paper); }
.intro { margin-top: 3rem; margin-bottom: 4rem; }
.lede { font-size: 1.3em; line-height: 1.45; color: var(--ink); }
.console-home { max-width: var(--wide); margin: 0 auto 5rem; padding: 0 var(--gutter); }
.console-home .fig-wide { margin-left: 0; margin-right: 0; }
.console-intro { max-width: var(--measure); }
.console-intro h2, .contents h2, .thesis h2 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 0 0 .6rem; }
.console-intro p { color: var(--ink-2); }
.contents { max-width: var(--wide); margin: 0 auto 5rem; padding: 0 var(--gutter); }
.contents-part { border-top: 1px solid var(--rule); padding: 1.4rem 0 1.2rem; display: grid; gap: .4rem 2rem; }
@media (min-width: 760px) { .contents-part { grid-template-columns: 15rem 1fr; } }
.contents-part-head { text-decoration: none; display: flex; flex-direction: column; gap: .2rem; }
.cp-roman { font-family: var(--sans); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--hue); font-weight: 600; }
.cp-title { font-size: 1.15rem; font-weight: 600; line-height: 1.25; }
.contents ol { list-style: none; padding: 0; margin: 0; columns: 1; }
.contents li a, .toc li li a { display: grid; grid-template-columns: 2rem 1fr; text-decoration: none; padding: .22rem 0; line-height: 1.35; }
.toc-n { font-family: var(--sans); font-size: .78rem; color: var(--ink-3); padding-top: .2em; font-variant-numeric: tabular-nums; }
.thesis { margin-bottom: 5rem; }
.thesis blockquote { font-size: 1.02em; }

/* ---------- part pages ---------- */
.part-open { position: relative; }
.part-hero { height: clamp(14rem, 40vw, 26rem); }
.part-text { max-width: var(--measure); margin: -6rem auto 0; padding: 0 var(--gutter); box-sizing: content-box; position: relative; }
.part-text h1 { font-size: clamp(2.4rem, 7vw, 3.8rem); margin: 0; letter-spacing: -.025em; line-height: 1.02; }
.part-text .eyebrow { color: var(--hue); font-weight: 600; }
.part-blurb { font-size: 1.12em; color: var(--ink-2); margin: 1.5rem 0 0; }
.chapter-list { list-style: none; max-width: var(--measure); margin: 3rem auto; padding: 0 var(--gutter); box-sizing: content-box; }
.chapter-list li { border-top: 1px solid var(--rule); }
.chapter-list a { display: grid; grid-template-columns: 2.6rem 1fr; gap: .5rem; padding: 1.3rem 0; text-decoration: none; }
.chapter-list a:hover .cl-title { color: var(--hue); }
.cl-n { font-family: var(--sans); font-weight: 300; font-size: 1.5rem; color: var(--hue); line-height: 1.1; }
.cl-text { display: flex; flex-direction: column; gap: .25rem; }
.cl-title { font-size: 1.2rem; font-weight: 600; line-height: 1.25; transition: color .15s; }
.cl-sub { font-style: italic; color: var(--ink-2); font-size: .95rem; }
.cl-teaser { color: var(--ink-3); font-size: .92rem; line-height: 1.5; margin-top: .25rem; }

/* ---------- chapter end ---------- */
.chapter-nav { max-width: var(--measure); margin: 4rem auto 3rem; padding: 0 var(--gutter); box-sizing: content-box; display: flex; flex-direction: column; gap: 1.2rem; }
.next-card { display: flex; flex-direction: column; gap: .45rem; text-decoration: none; padding: 1.5rem 1.6rem; border-radius: 16px; background: var(--paper-2); border: 1px solid transparent; transition: border-color .2s, transform .2s; }
.next-card:hover { border-color: var(--rule); color: inherit; transform: translateY(-1px); }
.next-label { font-family: var(--sans); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.next-title { font-size: 1.45rem; font-weight: 600; line-height: 1.2; }
.next-n { color: var(--hue); font-family: var(--sans); font-weight: 300; margin-right: .2rem; }
.next-teaser { color: var(--ink-2); font-size: .98rem; line-height: 1.5; }
.next-go { font-family: var(--sans); font-size: .82rem; font-weight: 600; color: var(--accent); margin-top: .3rem; }
.prev-link { font-family: var(--sans); font-size: .82rem; color: var(--ink-3); text-decoration: none; }
.site-foot { border-top: 1px solid var(--rule); margin-top: 4rem; padding: 2rem var(--gutter) 3rem; font-family: var(--sans); font-size: .78rem; color: var(--ink-2); text-align: center; }
.site-foot p { margin: .3rem 0; }
.site-foot a { text-decoration: none; }

/* ---------- drawers ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; background: rgb(20 18 14 / .35); display: flex; justify-content: flex-end; animation: fade .18s ease-out; }
.drawer[hidden] { display: none; }
.drawer-panel { position: relative; width: min(26rem, 100%); height: 100%; overflow-y: auto; background: var(--paper); box-shadow: var(--shadow); padding: 3.2rem 1.6rem 2rem; animation: slide .22s ease-out; font-size: 1rem; }
.search-drawer { justify-content: center; align-items: flex-start; }
.search-drawer .drawer-panel { width: min(42rem, 100%); height: auto; max-height: 85vh; margin-top: 6vh; border-radius: 16px; animation: fade .18s ease-out; }
@media (max-width: 640px) { .search-drawer .drawer-panel { margin-top: 0; border-radius: 0; max-height: 100vh; height: 100%; } }
.drawer-close { position: absolute; top: .7rem; right: .8rem; width: 2.2rem; height: 2.2rem; border: 0; background: none; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--ink-3); border-radius: 50%; }
.drawer-close:hover { background: var(--paper-2); color: var(--ink); }
.drawer-title { font-family: var(--sans); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 1rem; }
.drawer-title a { text-decoration: none; }
.toc { list-style: none; padding: 0; margin: 0; }
.toc-part > a { display: block; font-weight: 600; text-decoration: none; margin: 1.2rem 0 .4rem; line-height: 1.3; }
.toc-roman { display: block; font-family: var(--sans); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.toc ol { list-style: none; padding: 0; margin: 0; font-size: .95rem; }
.toc a[aria-current="page"] { color: var(--accent); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(2rem); opacity: .4; } }

/* pagefind */
#search { --pagefind-ui-scale: .9; --pagefind-ui-primary: var(--accent); --pagefind-ui-text: var(--ink); --pagefind-ui-background: var(--paper);
  --pagefind-ui-border: var(--rule); --pagefind-ui-tag: var(--paper-2); --pagefind-ui-border-width: 1px; --pagefind-ui-border-radius: 10px; --pagefind-ui-font: var(--sans); }
#search .pagefind-ui__result-excerpt { font-family: var(--serif); }
#search mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  .topbar, .progress, .chapter-nav, .site-foot, .hero, .widget { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
}
