:root {
  --bg:        #faf9f5;     /* eggshell, Anthropic */
  --bg-tint:   #f3f1e8;     /* slightly deeper for figure backgrounds */
  --ink:       #141413;     /* near-black, warm */
  --ink-soft:  #5a5a55;
  --ink-faint: #8a8a82;
  --rule:      #e3e0d3;
  --accent:    #c84a1d;     /* quiet rust, used only on labels and links */

  --font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --font-serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(200, 74, 29, 0.18); }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
a:hover { color: var(--ink); }

/* ───── HEADER ───── */
header.site {
  border-bottom: 1px solid var(--rule);
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}
header.site .brand {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none;
  border: none;
}
header.site .brand .brand-mark {
  width: 34px;
  height: 12px;
  margin-right: 10px;
  vertical-align: -0.1em;
  display: inline-block;
}
header.site nav {
  display: flex;
  gap: 28px;
  text-transform: lowercase;
}
header.site nav a {
  color: var(--ink-soft);
  border: none;
}
header.site nav a:hover { color: var(--ink); }
header.site nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 500;
}

/* ───── ARTICLE ───── */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 32px 120px;
  position: relative;
}

/* HERO */
.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.kicker::before {
  content: "//";
  color: var(--ink-faint);
}

h1.title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(38px, 5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin: 0 0 20px;
  max-width: 18ch;
}

.deck {
  font-family: var(--font-serif);
  font-size: 21px;
  line-height: 1.45;
  color: var(--ink-soft);
  font-weight: 400;
  margin: 0 0 48px;
  max-width: 54ch;
}
.deck em {
  font-style: italic;
  color: var(--ink);
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  padding: 16px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-bottom: 56px;
}
.byline strong { color: var(--ink); font-weight: 500; }
.byline .sep { color: var(--rule); }

/* BODY */
article p {
  margin: 0 0 24px;
  font-size: 19px;
  line-height: 1.62;
  color: var(--ink);
}
article p strong { font-weight: 600; color: var(--ink); }
article p em { font-style: italic; }

article p.lede {
  font-size: 22px;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 28px;
}
article p.lede::first-line {
  font-weight: 500;
}

/* SECTIONS */
article section {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--rule);
}
article section h2 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.018em;
  color: var(--ink);
  margin: 0 0 6px;
}
article section h2 .num {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0;
  margin-bottom: 14px;
}
article section > p:first-of-type {
  margin-top: 24px;
}

h3 {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin: 36px 0 10px;
}

/* LISTS */
ul {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
}
ul li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 14px;
  line-height: 1.55;
}
ul li::before {
  content: "·";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--ink-faint);
}
ul li .term {
  font-weight: 600;
  color: var(--ink);
}

/* BLOCKQUOTE / PULL */
blockquote {
  margin: 40px 0;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.45;
  font-style: italic;
  color: var(--ink);
  font-weight: 400;
  max-width: 60ch;
}

/* Blockquote citation line */
blockquote cite {
  display: block;
  margin-top: 12px;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
blockquote cite::before {
  content: "·  ";
  color: var(--ink-faint);
}

/* FIGURES */
figure {
  margin: 56px 0;
  padding: 0;
}
figure .frame {
  border: 1px solid var(--rule);
  background: #ffffff;
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  padding: 28px 24px;
}
figure svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;

  /* Shared diagram tokens, every diagram inherits these */
  font-family: var(--font-mono);
  --d-ink:    #141413;
  --d-soft:   #5a5a55;
  --d-faint:  #8a8a82;
  --d-hair:   #d0cdc0;
  --d-rust:   #c84a1d;
  --d-tint:   #f5f4ee;
}
/* Shared SVG element classes (used inside diagram SVGs) */
figure svg .stroke      { stroke: var(--d-ink);   stroke-width: 1.5; fill: none; }
figure svg .stroke-2    { stroke: var(--d-soft);  stroke-width: 1;   fill: none; }
figure svg .hair        { stroke: var(--d-hair);  stroke-width: 0.8; fill: none; }
figure svg .dashed      { stroke: var(--d-faint); stroke-width: 1;   stroke-dasharray: 3 3; fill: none; }
figure svg .accent      { stroke: var(--d-rust);  stroke-width: 1.5; fill: none; }
figure svg .fill-ink    { fill: var(--d-ink); }
figure svg .fill-soft   { fill: var(--d-soft); }
figure svg .fill-faint  { fill: var(--d-faint); }
figure svg .fill-tint   { fill: var(--d-tint); }
figure svg .fill-rust   { fill: var(--d-rust); }
figure svg .fill-white  { fill: #ffffff; }
figure svg text         { font-family: var(--font-mono); }
figure svg .t-title     { font-size: 22px; fill: var(--d-soft); letter-spacing: 0.18em; text-transform: uppercase; font-weight: 500; }
figure svg .t-body      { font-size: 22px; fill: var(--d-ink); font-weight: 500; }
figure svg .t-label     { font-size: 18px; fill: var(--d-soft); letter-spacing: 0.02em; }
figure svg .t-faint     { font-size: 18px; fill: var(--d-faint); letter-spacing: 0.02em; }
figure svg .t-num       { font-size: 18px; fill: var(--d-rust); font-weight: 600; letter-spacing: 0.1em; }
figure svg .t-axis      { font-size: 16px; fill: var(--d-faint); }
figure svg .t-big       { font-size: 32px; fill: var(--d-ink); font-weight: 600; }
figure figcaption {
  margin-top: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}
figure figcaption .fignum {
  color: var(--accent);
  white-space: nowrap;
}
figure figcaption .credit {
  display: block;
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 10.5px;
}
figure figcaption .credit a {
  color: var(--ink-faint);
  border-bottom: none;
}
figure figcaption .credit a:hover { color: var(--ink-soft); }

/* FOOTNOTE-LIKE / DISCLAIMER BOX */
.fineprint {
  margin-top: 56px;
  padding: 18px 22px;
  background: var(--bg-tint);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-faint);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.55;
}
.fineprint p {
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  font-family: var(--font-mono);
  color: var(--ink-faint);
}
.fineprint::before {
  content: "disclaimer";
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

/* Ex.N prefix label on h3 */
h3 .ex-num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 12px;
  vertical-align: middle;
}

/* Inline reference superscript */
sup.ref {
  font-size: 0.7em;
  line-height: 0;
  margin-left: 1px;
}
sup.ref a {
  color: var(--accent);
  border-bottom: none;
  font-family: var(--font-mono);
}
sup.ref a:hover { color: var(--ink); }

/* Sources list */
.sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: src;
}
.sources-list li {
  margin-bottom: 14px;
  padding-left: 0;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.sources-list li::before { content: none; }
.sources-list li strong {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  margin-right: 6px;
}

/* SECTION BREAK */
hr.brk {
  border: none;
  height: 1px;
  background: var(--rule);
  margin: 56px 0;
}

/* FOOTER */
footer.site {
  border-top: 1px solid var(--rule);
  padding: 32px;
  max-width: 1200px;
  margin: 80px auto 0;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

/* RESPONSIVE */
@media (max-width: 720px) {
  main { padding: 48px 22px 80px; }
  header.site { padding: 16px 22px; }
  header.site nav { gap: 18px; }
  h1.title { font-size: 36px; }
  .deck { font-size: 18px; }
  article p { font-size: 18px; }
  article p.lede { font-size: 20px; }
  blockquote { font-size: 19px; padding-left: 16px; }
  article section h2 { font-size: 24px; }
  figure { margin: 36px -22px; }
  figure .frame { border-left: none; border-right: none; border-radius: 0; }
  figure figcaption { padding: 0 22px; }
  footer.site { padding: 22px; flex-direction: column; gap: 8px; }
}

/* ───── SELECT-TO-COMMENT SYSTEM (UI-driven, localStorage-backed) ─────
   Highlight any text in the article to reveal a "+ comment" tooltip
   just above your selection. Click it to open a composer above the
   passage. Save → the passage gets a rust highlight, and a sticky
   note appears in the right margin anchored to that highlight.
   Hover an existing card to reveal edit/delete. Banner top-right
   shows the count; click it to toggle visibility. Inline pattern
   (<aside class="cmt"> in source HTML) also still works.
*/

/* Floating toolbar shown above a text selection */
.cmt-toolbar {
  position: absolute;
  z-index: 200;
  padding: 4px;
  background: var(--ink);
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  display: none;
}
.cmt-toolbar::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
}
.cmt-toolbar button {
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 2px;
}
.cmt-toolbar button:hover {
  background: rgba(200, 74, 29, 0.7);
}

/* Inline composer pinned above a passage */
.cmt-composer-popup {
  position: absolute;
  z-index: 201;
  width: 320px;
  max-width: calc(100vw - 32px);
}
.cmt-composer-popup::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 24px;
  border: 5px solid transparent;
  border-top-color: var(--accent);
  border-bottom: 0;
}

/* Highlighted passage */
article mark.cmt-anchor {
  background: rgba(200, 74, 29, 0.16);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
  box-shadow: inset 0 -1px 0 rgba(200, 74, 29, 0.4);
  cursor: pointer;
}
article mark.cmt-anchor.active {
  background: rgba(200, 74, 29, 0.32);
}

/* Comment card / composer (positioned absolutely vs. main) */
aside.cmt,
.cmt-composer-floating {
  position: absolute;
  left: calc(100% + 16px);
  width: 240px;
}
aside.cmt {
  padding: 10px 12px 8px;
  background: #fff8f0;
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
aside.cmt::before {
  content: "comment";
  display: block;
  font-size: 9.5px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
aside.cmt .cmt-actions {
  margin-top: 8px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity .15s;
}
aside.cmt:hover .cmt-actions { opacity: 1; }
aside.cmt .cmt-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
aside.cmt .cmt-actions button:hover { color: var(--accent); }

/* Composer */
.cmt-composer-floating {
  z-index: 6;
}
.cmt-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: #fff8f0;
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.cmt-composer textarea {
  width: 100%;
  min-height: 64px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: 2px;
  padding: 6px 8px;
  resize: vertical;
  color: var(--ink);
  box-sizing: border-box;
}
.cmt-composer textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.cmt-composer .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.cmt-composer .hint {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
}
.cmt-composer button {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink-soft);
}
.cmt-composer button.save {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Top banner */
#cmt-banner {
  display: none;
  position: fixed;
  top: 12px;
  right: 16px;
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 2px;
  z-index: 100;
  cursor: pointer;
  user-select: none;
}
#cmt-banner.has-cmts { display: block; }
body.hide-cmts aside.cmt,
body.hide-cmts .cmt-add-btn { display: none !important; }
body.hide-cmts #cmt-banner { opacity: 0.55; }

/* Narrow viewport: stack inline rather than margin-pinned */
@media (max-width: 1180px) {
  aside.cmt,
  .cmt-composer-floating {
    position: static;
    width: auto;
    margin: 12px 0;
  }
}

/* ───── HOME PAGE (essay timeline) ───── */
main.home {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 32px 120px;
}
.essay-entry {
  padding: 56px 0;
  border-bottom: 1px solid var(--rule);
}
.essay-entry:first-child { padding-top: 0; }
.essay-entry:last-child { border-bottom: none; }

.entry-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.entry-kicker::before {
  content: "//";
  color: var(--ink-faint);
}

.entry-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: clamp(30px, 3.6vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.022em;
  margin: 0 0 28px;
}
.entry-title a {
  color: var(--ink);
  border: none;
  transition: color 0.15s;
}
.entry-title a:hover { color: var(--accent); }

.entry-preview {
  position: relative;
  max-height: 11.5em;
  overflow: hidden;
  margin-bottom: 28px;
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}
.entry-preview p {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 16px;
}
.entry-preview p:last-child { margin-bottom: 0; }

.entry-readmore {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.02em;
  border: none;
  display: inline-block;
}
.entry-readmore:hover { color: var(--ink); }
