/* =========================================================================
   Adarsh Vatsa. Set like a manuscript, with notes in the margin.
   ========================================================================= */

:root {
  --bg: #ffffff;
  --bg-2: #f5f4f1;
  --card: #ffffff;
  --line: #e6e0d4;
  --line-2: #d3cbbd;
  --ink: #1c1a17;
  --ink-2: #47433d;      /* 9.6:1 */
  --ink-3: #6b655c;      /* 5.6:1 */
  --red: #b33a17;        /* margin ink, 5.9:1 */
  --highlight: #ffe58a;
  --accent: #1c1a17; --accent-ink: #1c1a17; --on-accent: #fffefb;
  --accent-soft: rgba(28, 26, 23, 0.06); --accent-line: rgba(28, 26, 23, 0.3);
  --shadow: 0 1px 2px rgba(40, 30, 10, 0.05), 0 10px 30px -10px rgba(40, 30, 10, 0.18);
  --code-bg: #f6f3ec;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: var(--serif); --text: var(--serif); --ui: var(--serif);

  --col: 46rem;          /* longest comfortable line of running text */
  --cue: clamp(10.5rem, 15vw, 16rem);
  --gap: clamp(2rem, 3.5vw, 4rem);
  --margin-line: rgba(179, 58, 23, 0.32);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --bg-2: #1e1c19; --card: #1b1a17; --line: #2e2b27; --line-2: #403c36;
    --ink: #ece7dd; --ink-2: #c4beb2; --ink-3: #9a9387; --red: #ff9673; --highlight: rgba(255, 214, 90, 0.3);
    --accent: #ece7dd; --accent-ink: #ece7dd; --on-accent: #161513;
    --accent-soft: rgba(255, 255, 255, 0.07); --accent-line: rgba(255, 255, 255, 0.3);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.7); --code-bg: #1e1c19;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --bg-2: #1e1c19; --card: #1b1a17; --line: #2e2b27; --line-2: #403c36;
  --ink: #ece7dd; --ink-2: #c4beb2; --ink-3: #9a9387; --red: #ff9673; --highlight: rgba(255, 214, 90, 0.3);
  --accent: #ece7dd; --accent-ink: #ece7dd; --on-accent: #161513;
  --accent-soft: rgba(255, 255, 255, 0.07); --accent-line: rgba(255, 255, 255, 0.3);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -12px rgba(0,0,0,.7); --code-bg: #1e1c19;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 2rem; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--serif); font-size: 19px; line-height: 1.62; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  font-variant-numeric: oldstyle-nums proportional-nums;
}
@media (max-width: 600px) { body { font-size: 18px; } }
@media (min-width: 1300px) { body { font-size: clamp(20px, 0.5vw + 13px, 23px); } }
@media (min-width: 1500px) { :root { --col: 52rem; } }
::selection { background: var(--highlight); color: inherit; }
a { color: inherit; text-decoration: none; }
p { margin: 0 0 1em; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.25; text-wrap: balance; }
b, strong { font-weight: 600; }
img, svg { max-width: 100%; }
.sc { font-variant: small-caps; letter-spacing: 0.05em; }
kbd {
  font-family: var(--serif); font-size: 13px; color: var(--ink-3); font-variant-numeric: lining-nums;
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line-2); border-radius: 4px; background: var(--card); line-height: 1;
}
.icon { width: 15px; height: 15px; flex: none; }
:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--bg); padding: 6px 12px; border-radius: 4px; }
.skip:focus { left: 8px; }
time, .num { font-variant-numeric: lining-nums tabular-nums; }

.prose a, .link, .abstract a {
  text-decoration: underline; text-decoration-color: var(--line-2); text-decoration-thickness: 1px; text-underline-offset: 3px;
  transition: text-decoration-color 0.15s;
}
.prose a:hover, .link:hover, .abstract a:hover { text-decoration-color: var(--ink); }

/* ---------- frame ---------- */
.page { margin: 0; padding: 0 clamp(20px, 4.5vw, 96px); }
.top { display: flex; align-items: baseline; gap: 2px 22px; flex-wrap: wrap; padding: 30px 0 0; margin-bottom: 72px; font-size: 0.95em; }
.top__home { margin-right: auto; font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-2); cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.top__home:hover { color: var(--ink); }
.top__nav { display: flex; gap: 18px; align-items: baseline; font-variant: small-caps; letter-spacing: 0.06em; }
.top__nav a, .tool { color: var(--ink-3); transition: color 0.15s; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit; display: inline-flex; align-items: center; gap: 6px; }
.top__nav a:hover, .tool:hover, .top__nav a[aria-current="page"] { color: var(--ink); }
.tool { font-variant: normal; letter-spacing: 0; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; } :root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
@media (max-width: 560px) { .top { margin-bottom: 48px; } .tool kbd { display: none; } .top__nav { gap: 13px; flex-wrap: wrap; letter-spacing: 0.03em; } }

.progress { position: fixed; left: 0; top: 0; height: 2px; width: calc(var(--p, 0) * 100%); background: var(--red); z-index: 50; }
body:not(.is-post) .progress { display: none; }

/* ---------- title block (home + posts) ---------- */
.titleblock { text-align: center; padding-bottom: 28px; margin-bottom: 0; border-bottom: 3px double var(--line-2); }
.titleblock h1 { font-size: 1.6em; font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; margin-bottom: 12px; }
.titleblock .byline { color: var(--ink-2); margin: 0; }
.titleblock .affil { font-variant: small-caps; letter-spacing: 0.06em; color: var(--ink-3); margin: 2px 0 0; font-size: 16px; }
.titleblock .date { color: var(--ink-3); margin: 10px 0 0; font-size: 16px; }
@media (max-width: 600px) { .titleblock h1 { font-size: 1.4em; } }

.abstract { margin: 0 auto 48px; max-width: 33rem; font-size: 16.5px; line-height: 1.6; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.abstract p { margin: 0 0 0.7em; }
.abstract p:first-child::before { content: "Abstract. "; font-weight: 600; font-variant: small-caps; letter-spacing: 0.04em; }
.abstract p:last-child { margin: 0; }
@media (max-width: 600px) { .abstract { text-align: left; hyphens: manual; } }

/* margin notes, in red ink */
.marg { position: relative; }
.note {
  font-family: var(--hand); font-size: 1.3em; line-height: 1.12; color: var(--red); font-weight: 500;
  font-variant-numeric: normal;
}
.marg > .note { position: absolute; left: calc(100% + 34px); top: 2px; width: 170px; transform: rotate(-2.5deg); transform-origin: left top; }
.marg > .note::before {
  content: ""; position: absolute; left: -30px; top: 10px; width: 24px; height: 14px;
  border-top: 1.6px solid var(--red); border-left: 1.6px solid var(--red); border-radius: 14px 0 0 0; transform: rotate(-12deg);
}
@media (max-width: 1080px) { .marg > .note { display: none; } }

/* ---------- numbered sections ---------- */
.doc { counter-reset: sec; }
.sec { margin-bottom: 52px; }
.sec > h2 { counter-increment: sec; font-size: 20px; font-weight: 600; margin-bottom: 18px; display: flex; align-items: baseline; gap: 14px; }
.sec > h2::before { content: counter(sec); font-weight: 600; min-width: 1em; }
.sec > h2 .more { margin-left: auto; font-size: 15px; font-weight: 400; color: var(--ink-3); font-style: italic; transition: color 0.15s; }
.sec > h2 .more:hover { color: var(--ink); }
.sec > p { color: var(--ink); }

/* table of contents style lists, with dotted leaders */
.toclist { list-style: none; margin: 0; padding: 0; }
.toclist li { margin: 0 0 10px; }
.toclist a, .toclist .line { display: flex; align-items: baseline; gap: 10px; }
.toclist .t { flex: 0 1 auto; transition: color 0.15s; }
.toclist a:hover .t { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.toclist .lead { flex: 1 1 2rem; min-width: 2rem; border-bottom: 1.5px dotted var(--line-2); transform: translateY(-5px); }
.toclist .r { flex: none; color: var(--ink-3); font-size: 0.9em; white-space: nowrap; }
.toclist .s { display: block; color: var(--ink-3); font-size: 16px; font-style: italic; margin-top: 1px; padding-right: 5rem; }
.toclist .st { font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); font-size: 15px; margin-left: 4px; }

/* references */
.refs { list-style: none; margin: 0; padding: 0; counter-reset: ref; }
.refs li { counter-increment: ref; position: relative; padding-left: 2.6rem; margin-bottom: 14px; line-height: 1.5; scroll-margin-top: 40px; }
.refs li::before { content: "[" counter(ref) "]"; position: absolute; left: 0; color: var(--ink-3); font-variant-numeric: lining-nums; }
.refs li:target { background: linear-gradient(transparent 60%, var(--highlight) 60%); }
.refs .au { color: var(--ink-2); }
.refs .au b { font-weight: 600; color: var(--ink); }
.refs .ti { font-style: italic; }
.refs a.ti:hover { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.refs .ve { color: var(--ink-3); }
.refs .acts { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 3px; font-size: 0.85em; }
.refs .acts a, .refs .acts button, .refs .acts summary { color: var(--ink-3); font: inherit; font-variant: small-caps; letter-spacing: 0.05em; background: none; border: 0; padding: 0; cursor: pointer; list-style: none; transition: color 0.15s; }
.refs .acts summary::-webkit-details-marker { display: none; }
.refs .acts a:hover, .refs .acts button:hover, .refs .acts summary:hover, .refs details[open] summary { color: var(--ink); }
.refs details[open] { flex-basis: 100%; order: 9; }
.refs details p { margin: 6px 0 4px; color: var(--ink-2); font-size: 16px; text-align: justify; hyphens: auto; }
.interests { color: var(--ink-2); font-style: italic; }

.corr { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 22px; }
.corr dt { font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); }
.corr dd { margin: 0; }
.corr a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.corr a:hover { text-decoration-color: var(--ink); }

/* ---------- index page ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin: -12px 0 40px; font-size: 16px; }
.filter-search { flex: 1 1 12rem; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line-2); padding: 2px 0; color: var(--ink-3); }
.filter-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; color: var(--ink); font-style: italic; }
.filter-group { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.chip { font: inherit; font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); background: none; border: 0; padding: 0; cursor: pointer; transition: color 0.15s; }
.chip:hover { color: var(--ink); }
.chip.is-on { color: var(--ink); text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 1.5px; text-underline-offset: 4px; }
.chip small { font-size: 13px; }
.year { margin-bottom: 28px; }
.year__label { font-size: 16px; font-weight: 600; color: var(--ink-3); margin-bottom: 10px; font-variant-numeric: lining-nums; }
.empty { color: var(--ink-3); font-style: italic; }

/* ---------- post ---------- */
.post-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 16px; color: var(--ink-3); font-size: 0.9em; margin-top: 10px; }
.post-meta .st { font-variant: small-caps; letter-spacing: 0.05em; }
.post-meta a:hover { color: var(--ink); }

.prose { font-size: 1em; line-height: 1.68; counter-reset: h2 thm; }
.prose p { margin: 0 0 1.15em; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
@media (max-width: 600px) { .prose p { text-align: left; hyphens: manual; } }
.prose h2, .prose h3, .prose h4 { position: relative; scroll-margin-top: 32px; }
.prose h2 { counter-increment: h2; counter-reset: h3; font-size: 1.15em; font-weight: 600; margin: 2.2em 0 0.7em; }
.prose h2::before { content: counter(h2); margin-right: 14px; }
.prose h3 { counter-increment: h3; font-size: 18px; font-weight: 600; margin: 1.8em 0 0.5em; }
.prose h3::before { content: counter(h2) "." counter(h3); margin-right: 12px; }
.prose h4 { font-size: 18px; font-weight: 600; font-style: italic; margin: 1.4em 0 0.4em; }
.anchor { position: absolute; left: -24px; color: var(--ink-3); opacity: 0; transition: opacity 0.15s; text-decoration: none !important; font-weight: 400; }
.prose h2:hover .anchor, .prose h3:hover .anchor, .anchor:focus { opacity: 1; }
@media (max-width: 700px) { .anchor { display: none; } }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1.15em; }
.prose li { margin-bottom: 0.3em; padding-left: 0.2em; }
.prose li::marker { color: var(--ink-3); }
.prose ol li::marker { font-variant-numeric: lining-nums; }
.prose blockquote { margin: 1.4em 2em; color: var(--ink-2); font-size: 17px; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose mark { background: linear-gradient(transparent 52%, var(--highlight) 52%, var(--highlight) 92%, transparent 92%); color: inherit; padding: 0 2px; }
.prose hr { border: 0; text-align: center; margin: 2em 0; }
.prose hr::after { content: "*   *   *"; white-space: pre; color: var(--ink-3); }
.prose img { display: block; max-width: 100%; height: auto; margin: 1.8em auto; }
.figure { margin: 2em 0; }
.figure figcaption { color: var(--ink-2); font-size: 16px; text-align: center; margin-top: 10px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 1.6em 0; display: block; overflow-x: auto; border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); }
.prose th { text-align: left; font-weight: 600; border-bottom: 1px solid var(--ink); padding: 6px 18px 6px 0; }
.prose td { padding: 6px 18px 6px 0; }
.prose code { font-family: var(--mono); font-size: 0.8em; background: var(--bg-2); border-radius: 3px; padding: 0.1em 0.3em; }
.prose a.ext::after { content: "↗"; font-size: 0.7em; margin-left: 1px; color: var(--ink-3); display: inline-block; text-decoration: none; }
.code { position: relative; margin: 1.5em 0; border-left: 2px solid var(--line-2); background: var(--code-bg); }
.code figcaption { position: absolute; top: 6px; right: 8px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.code figcaption > span { font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); }
.copy { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 14px; color: var(--ink-3); background: none; border: 0; padding: 0; cursor: pointer; opacity: 0; transition: opacity 0.15s, color 0.15s; }
.code:hover .copy, .copy:focus { opacity: 1; }
.copy:hover { color: var(--ink); }
.copy .icon { width: 13px; height: 13px; }
.code pre { margin: 0; padding: 14px 18px; overflow-x: auto; }
.code code { background: none; padding: 0; font-size: 13.5px; line-height: 1.65; }
.math-display { display: block; overflow-x: auto; overflow-y: hidden; margin: 1.3em 0; text-align: center; }

/* theorem-style environments */
.thm { margin: 1.5em 0; }
.thm p { margin-bottom: 0.6em; }
.thm p:last-child { margin-bottom: 0; }
.thm__h { font-weight: 600; font-style: normal; }
.thm--claim, .thm--conjecture, .thm--theorem, .thm--lemma, .thm--question { font-style: italic; }
.thm--claim .thm__h, .thm--conjecture .thm__h, .thm--theorem .thm__h, .thm--lemma .thm__h { font-style: normal; }
.thm--conjecture, .thm--question { border-left: 2px solid var(--red); padding-left: 16px; }
.thm--definition, .thm--theorem, .thm--claim, .thm--lemma { border-left: 2px solid var(--ink); padding-left: 16px; }
.thm--note, .thm--example, .thm--idea, .thm--warning { padding: 12px 16px; background: var(--bg-2); }
.thm--proof .thm__h { font-style: italic; font-weight: 400; }
.thm--proof > :last-child::after { content: "∎"; float: right; margin-left: 12px; }

/* margin notes inside writing (^[...]) */
.sn-ref { cursor: pointer; }
.sn-ref::after { content: attr(data-n); font-size: 0.68em; vertical-align: super; line-height: 0; margin-left: 1px; color: var(--red); font-variant-numeric: lining-nums; font-weight: 600; }
.sn-toggle { display: none; }
.sidenote { display: none; font-family: var(--hand); font-size: 1.3em; line-height: 1.15; color: var(--red); text-align: left; hyphens: none; }
.sidenote::before { content: attr(data-n) ". "; font-family: var(--serif); font-size: 14px; font-weight: 600; }
.sn-toggle:checked + .sidenote { display: block; margin: 4px 0 12px 1.5em; }
@media (min-width: 99999px) {
  .sn-ref { cursor: default; }
  .sidenote, .sn-toggle:checked + .sidenote {
    display: block; float: right; clear: right; width: 190px; margin: -4px -228px 10px 0;
    transform: rotate(-1.5deg); transform-origin: left top; transition: transform 0.2s;
  }
  .sidenote.is-lit { transform: rotate(0) scale(1.03); }
}

/* contents */
.toc { margin: 24px 0 0; font-size: 16.5px; }
.toc summary { cursor: pointer; list-style: none; font-weight: 600; font-variant: small-caps; letter-spacing: 0.05em; width: max-content; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 8px 0 0; padding: 0; counter-reset: t2; }
.toc li { display: flex; gap: 10px; }
.toc .toc__d2 { counter-increment: t2; counter-reset: t3; }
.toc .toc__d2::before { content: counter(t2); min-width: 1.6em; color: var(--ink-3); }
.toc .toc__d3 { counter-increment: t3; padding-left: 1.6em; }
.toc .toc__d3::before { content: counter(t2) "." counter(t3); min-width: 2.2em; color: var(--ink-3); }
.toc a { color: var(--ink-2); transition: color 0.15s; }
.toc a:hover, .toc a.is-active { color: var(--ink); }
.toc a.is-active { text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; }
@media (min-width: 99999px) {
  .toc { position: fixed; top: 150px; left: max(16px, calc(50% - 19rem - 250px)); width: 200px; margin: 0; font-size: 15px; }
  .toc summary { pointer-events: none; }
}

.qed { display: none; }
.post-foot { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 16px; font-size: 16px; }
.post-foot a { display: flex; flex-direction: column; }
.post-foot a span { font-style: italic; transition: color 0.15s; }
.post-foot a:hover span { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.post-foot small { color: var(--ink-3); font-variant: small-caps; letter-spacing: 0.05em; font-size: 15px; }
.post-foot .next { text-align: right; grid-column: 2; }
.backlinks { margin-top: 40px; color: var(--ink-3); font-size: 16px; }

/* ---------- about + 404 ---------- */
.page-prose .prose h2::before, .page-prose .prose h3::before { content: none; }
.status-legend p { text-align: left !important; }
.lost { text-align: center; }
.lost p { color: var(--ink-2); }

/* ---------- footer ---------- */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; margin: 96px 0 0; padding: 20px 0 44px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 0.85em; }
.foot a { transition: color 0.15s; } .foot a:hover { color: var(--ink); }

/* ---------- palette, shortcuts, previews, toast ---------- */
.sheet {
  width: min(560px, calc(100vw - 24px)); max-height: min(460px, 76vh); margin: 14vh auto auto; padding: 0;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); color: var(--ink);
  box-shadow: 0 24px 64px -16px rgba(30, 20, 0, 0.35); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: pop 0.16s ease-out; }
.sheet::backdrop { background: rgba(20, 15, 5, 0.18); }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }
.palette__field { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--ink-3); }
.palette__field input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 18px; color: var(--ink); }
.palette__results { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.palette__group { font-variant: small-caps; letter-spacing: 0.05em; font-size: 15px; color: var(--ink-3); padding: 10px 10px 2px; }
.palette__item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.palette__item.is-active { background: var(--bg-2); }
.palette__ico { display: none; }
.palette__title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__snip { font-size: 15px; color: var(--ink-3); font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette__snip mark, .palette__title mark { background: var(--highlight); color: inherit; }
.palette__hint { font-size: 14px; color: var(--ink-3); }
.palette__empty { padding: 28px 12px; text-align: center; color: var(--ink-3); font-style: italic; }
.palette__foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }
.palette__foot span { display: inline-flex; align-items: center; gap: 4px; }
.keys { padding: 18px 22px 22px; overflow-y: auto; }
.keys h2 { font-size: 19px; margin-bottom: 14px; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 16px; align-items: center; }
.keys dt { display: flex; gap: 3px; justify-content: flex-end; }
.keys dd { margin: 0; color: var(--ink-2); }

.preview { position: absolute; z-index: 60; width: min(340px, calc(100vw - 32px)); padding: 12px 16px; background: var(--card); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: var(--shadow); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity 0.15s, transform 0.15s; }
.preview.is-on { opacity: 1; transform: none; }
.preview__meta { font-size: 14px; color: var(--ink-3); margin-bottom: 2px; }
.preview__meta .status { display: none; }
.preview__title { font-weight: 600; font-size: 17px; margin-bottom: 4px; }
.preview__summary { font-size: 15px; color: var(--ink-2); margin: 0; line-height: 1.5; font-style: italic; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 8px); opacity: 0; font-size: 15px; padding: 8px 14px; border-radius: 6px; background: var(--ink); color: var(--bg); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.to-top { display: none; }

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}
@media print {
  .top, .foot, .toc, .post-foot, .progress { display: none !important; }
  .sidenote { display: inline !important; float: none !important; margin: 0 !important; transform: none !important; }
}

/* =========================================================================
   Cornell layout. Cue column on the left, notes on the right, a summary at the foot.
   ========================================================================= */
.cornell { position: relative; }
.cornell::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--cue) + var(--gap) / 2);
  border-left: 1.5px solid var(--margin-line); pointer-events: none;
}
.cn-row { display: grid; grid-template-columns: var(--cue) minmax(0, 1fr); column-gap: var(--gap); padding: 26px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.cn-cue { position: relative; }
.cue { font-size: 1em; font-weight: 600; line-height: 1.35; margin: 0; }
.cue .n { color: var(--ink-3); font-weight: 400; margin-right: 8px; font-variant-numeric: lining-nums; }
.cn-cue .note { display: block; margin-top: 8px; transform: rotate(-2deg); transform-origin: left top; }
.cue-more { display: inline-block; margin-top: 6px; font-size: 0.9em; font-style: italic; color: var(--ink-3); transition: color 0.15s; }
.cue-more:hover { color: var(--ink); }
.cn-body > :last-child { margin-bottom: 0; }
.cn-body .toclist li:last-child { margin-bottom: 0; }
.cn-body .refs li:last-child { margin-bottom: 0; }
.cn-abstract p { text-align: justify; hyphens: auto; -webkit-hyphens: auto; margin: 0 0 0.7em; }
.cn-abstract p:last-child { margin: 0; }
.cn-summary { border-top: 3px double var(--line-2); border-bottom: 0; margin-top: -1px; }
.cn-summary .cn-body p { font-style: italic; color: var(--ink-2); margin: 0; }
.cn-filters .filters { margin: 0; }

/* inside writing, headings and margin notes live in the cue column */
.cn-prose { padding: 30px 0 30px calc(var(--cue) + var(--gap)); }
.cn-prose .prose h2 {
  float: left; clear: left; width: var(--cue); margin: 0.15em 0 0.6em calc(-1 * (var(--cue) + var(--gap)));
  font-size: 1em; line-height: 1.35;
}
.cn-prose .prose h2::before { display: block; margin: 0 0 2px; font-weight: 400; color: var(--ink-3); }
.cn-prose .prose h2 + * { margin-top: 0; }
.cn-prose .prose h2 .anchor { display: none; }
.cn-break { display: none; }
.cn-prose .cn-break { display: block; clear: left; border-top: 1px solid var(--line); margin: 2.2em 0 1.6em calc(-1 * (var(--cue) + var(--gap))); }
.cn-prose .prose > .cn-break:first-child { display: none; }
.cn-prose .prose .sidenote, .cn-prose .prose .sn-toggle:checked + .sidenote {
  display: block; float: left; clear: left; width: var(--cue); margin: 0.1em 0 1em calc(-1 * (var(--cue) + var(--gap)));
  transform: rotate(-1.5deg); transform-origin: right top; text-align: left;
}
.cn-prose .prose .sidenote.is-lit { transform: rotate(0) scale(1.03); }
.cn-prose .prose .sn-ref { cursor: default; }
.cn-prose + .cornell .cn-summary, .cn-prose ~ .cn-summary { margin-top: 0; }
.cn-prose-wrap .toc { display: none; }

@media (max-width: 900px) {
  .cornell::before { display: none; }
  .cn-row { grid-template-columns: 1fr; row-gap: 12px; padding: 22px 0; }
  .cn-cue { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
  .cn-cue .note { margin: 0; font-size: 19px; }
  .cue-more { margin: 0; }
  .cn-prose { padding: 24px 0; }
  .cn-prose .prose h2 { float: none; width: auto; margin: 0 0 0.6em; font-size: 20px; }
  .cn-prose .cn-break { margin: 2em 0 1.4em; }
  .cn-prose .prose h2::before { display: inline; margin-right: 12px; }
  .cn-prose .prose .sidenote { display: none; float: none; width: auto; margin: 0; transform: none; }
  .cn-prose .prose .sn-toggle:checked + .sidenote { display: block; float: none; width: auto; margin: 6px 0 12px 1.2em; transform: none; }
  .cn-prose .prose .sn-ref { cursor: pointer; }
  .cn-prose-wrap .toc { display: block; }
}

/* ---------- full-width layout: text keeps a readable measure, everything else spreads out ---------- */
.cn-abstract, .cn-body > p, .interests, .refs, .corr { max-width: var(--col); }
.prose > p, .prose > ul, .prose > ol, .prose > blockquote, .prose > .thm, .prose > h3, .prose > h4 { max-width: var(--col); }
.toclist { max-width: 80rem; }
.titleblock h1 { max-width: 60rem; margin-left: auto; margin-right: auto; }

/* paper cards */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: 18px; }
.pcard {
  display: flex; flex-direction: column; border: 1px solid var(--line); background: var(--card);
  transition: border-color 0.15s, transform 0.2s, box-shadow 0.2s; overflow: hidden;
}
.pcard:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow); }
.pcard__fig { display: block; height: 12rem; padding: 14px; background: #fff; border-bottom: 1px solid var(--line); overflow: hidden; }
.pcard__fig img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pcard__body { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 16px; }
.pcard__venue { font-variant: small-caps; letter-spacing: 0.05em; color: var(--red); font-size: 0.85em; }
.pcard__title { font-weight: 600; line-height: 1.3; }
.pcard__take { color: var(--ink-2); font-size: 0.9em; line-height: 1.45; font-style: italic; }

/* paper pages */
.plinks { display: inline-flex; gap: 14px; }
.plinks a, .plinks button { font: inherit; font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); background: none; border: 0; padding: 0; cursor: pointer; transition: color 0.15s; }
.plinks a:hover, .plinks button:hover { color: var(--ink); }
.titleblock .byline b { font-weight: 600; }
.paper-page .prose { counter-reset: h2 fig; }
.prose .figure { counter-increment: fig; }
.prose .figure { margin: 1.6em 0 2.2em; max-width: 100%; }
.prose .figure img { display: block; width: 100%; height: auto; max-height: 34rem; object-fit: contain; background: #fff; padding: 18px; border: 1px solid var(--line); margin: 0; }
.prose .figure figcaption { text-align: left; font-size: 0.88em; color: var(--ink-2); margin-top: 8px; max-width: var(--col); }
.prose .figure figcaption::before { content: "Figure " counter(fig) ". "; font-weight: 600; font-variant: small-caps; letter-spacing: 0.04em; }

/* ---------- handwritten annotations with arrows ---------- */
:root { --arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 40'%3E%3Cg fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8 C 20 2, 40 8, 55 28'/%3E%3Cpath d='M43 27 L56 30 L57 17'/%3E%3C/g%3E%3C/svg%3E"); }
@media (min-width: 901px) {
  .cn-prose .prose .sidenote { position: relative; padding-right: 10px; }
  .cn-prose .prose .sidenote::before { content: none; }
  .cn-prose .prose .sidenote::after {
    content: ""; position: absolute; right: -40px; top: 0.55em; width: 44px; height: 28px;
    background: var(--red); -webkit-mask: var(--arrow) center / contain no-repeat; mask: var(--arrow) center / contain no-repeat;
    transform: rotate(-8deg);
  }
  .cn-prose .prose .sn-ref::after { content: none; }
}
.pcard { position: relative; }
.pcard__note {
  position: absolute; right: 14px; top: calc(12rem - 22px); padding: 0 6px; background: var(--card);
  font-family: var(--hand); font-size: 1.15em; line-height: 1.1; color: var(--red); transform: rotate(-3deg); transform-origin: right center;
}

/* home opens like a paper: a modest title, the author as a byline, no duplicate label in the corner */
.titleblock--home h1 { font-size: 1.6em; cursor: default; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.titleblock--home .byline { font-size: 1em; }
.is-home .top__home { visibility: hidden; }

/* wide screens: annotations move into the open right margin, arrow pointing back at the text */
@media (min-width: 1440px) {
  .cn-prose .prose > p, .cn-prose .prose > ul, .cn-prose .prose > ol { max-width: min(var(--col), calc(100% - 20rem)); }
  .cn-prose .prose .sidenote, .cn-prose .prose .sn-toggle:checked + .sidenote {
    float: right; clear: right; width: 15rem; margin: -0.1em -19rem 1.2em 0;
    padding: 0 0 0 14px; border-left: 1.5px dashed var(--line-2);
    transform: rotate(-1.5deg); transform-origin: left top;
  }
  .cn-prose .prose .sidenote::after {
    right: auto; left: -50px; top: 0.35em; transform: scaleX(-1) rotate(-6deg);
  }
  .cn-prose .prose .figure, .cn-prose .prose .code, .cn-prose .prose table, .cn-prose .math-display, .cn-prose .cn-break { clear: both; }
}

/* ---------- conferences: a calendar ---------- */
.cn-month .cue .yr { color: var(--ink-3); font-weight: 400; }
.cal { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 0 var(--gap); align-items: start; }
.mini { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; font-size: 13px; line-height: 1; font-variant-numeric: lining-nums tabular-nums; text-align: center; }
.mini .w { color: var(--ink-3); font-variant: small-caps; padding-bottom: 6px; }
.mini .d { position: relative; padding: 6px 0 9px; color: var(--ink-2); border-radius: 3px; transition: background 0.15s, color 0.15s; }
.mini .d.is-past { color: var(--line-2); }
.mini .d.is-today { box-shadow: inset 0 0 0 1px var(--ink-3); }
.mini .d.has-ev { background: var(--accent-soft); color: var(--ink); }
.mini .d.has-dl { color: var(--ink); font-weight: 600; }
.mini .d.has-dl::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--red); }
.mini .d.has-nt::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--ink-3); }
.mini .d.has-dl.has-nt::after { background: var(--red); box-shadow: none; }
.mini .d.is-hl { background: var(--highlight); color: var(--ink); }
.agenda { list-style: none; margin: 0; padding: 0; }
.ag { display: grid; grid-template-columns: 5.4rem minmax(0, 1fr); gap: 0 12px; padding: 3px 0 5px; line-height: 1.4; }
.ag__day { color: var(--ink-3); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.ag--dl .ag__day { color: var(--red); }
.ag--nt .ag__name, .ag--nt .ag__what { color: var(--ink-3); }
.ag__name { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; transition: text-decoration-color 0.15s; }
.ag a:hover .ag__name { text-decoration-color: var(--ink); }
.ag__what { color: var(--ink-3); font-style: italic; }
.ag.is-est .ag__name { font-style: italic; color: var(--ink-2); }
.ag .kd, .venues .kd { font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); font-size: 0.9em; margin-left: 7px; }
.confs .est { font-variant: small-caps; letter-spacing: 0.05em; color: var(--ink-3); margin-left: 6px; text-decoration: none; border-bottom: 1px dotted var(--line-2); cursor: help; }
.ag .cd { font-family: var(--hand); font-size: 1.2em; line-height: 1; color: var(--red); margin-left: 10px; white-space: nowrap; display: inline-block; transform: rotate(-2deg); }
.ag.is-closed { opacity: 0.45; }
.agenda--next .ag { grid-template-columns: 5.4rem minmax(0, 1fr); }
.cn-month.is-empty .cn-body::after { content: "Nothing yet."; color: var(--line-2); font-style: italic; }
.cn-month.is-empty .cal { display: none; }
.venues { list-style: none; margin: 0; padding: 0; max-width: var(--col); }
.venues li { margin: 0 0 10px; line-height: 1.5; }
.venues .ti { font-style: italic; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.venues .ve { color: var(--ink-3); }
.venues .why { display: block; color: var(--ink-2); font-size: 0.95em; }
.conf-foot { color: var(--ink-3); font-size: 15px; font-style: italic; margin: 28px 0 0; max-width: var(--col); }
@media (max-width: 760px) {
  .cal { grid-template-columns: minmax(0, 1fr); row-gap: 14px; }
  .mini { max-width: 15rem; }
}
@media (max-width: 900px) {
  .confs .cn-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .ag, .agenda--next .ag { grid-template-columns: 3.9rem minmax(0, 1fr); gap: 0 8px; }
}
.ag__body { min-width: 0; overflow-wrap: break-word; }
