/* Kspectra Research — full-text paper pages (shared by every /papers/<slug>/ page).
   Same tokens, header and theme toggle as the blog posts; the paper body is set in serif to sit with the math font. */
:root{
  --page:#F4F6FB; --panel:#ffffff; --ink:#14161f; --ink-2:#454a5c; --ink-3:#61677b;
  --line:#d9deea; --line-2:#c3cadd; --accent:#2E37D4; --accent-soft:#e7e9fb; --code-bg:#eef1f8; --mark:#fff4c2;
  --edge:rgba(20,22,31,.30);
  --measure:44rem;
  --serif:"Iowan Old Style","Palatino Linotype","Book Antiqua",Palatino,Georgia,"Times New Roman",serif;
  --sans:system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --mono:"SF Mono","JetBrains Mono","Roboto Mono",ui-monospace,Menlo,Consolas,monospace;
  --math:"STIX Two Math","Cambria Math","Latin Modern Math","Libertinus Math",math;
}
@media (prefers-color-scheme:dark){
  :root{ --page:#08090f; --panel:#111420; --ink:#e8eaf2; --ink-2:#aeb4c9; --ink-3:#7d849c;
         --line:#232838; --line-2:#2f3548; --accent:#8f97ff; --accent-soft:#1b1f36; --code-bg:#141826; --mark:#3a3413;
         --edge:rgba(232,234,242,.34); }
}
:root[data-theme="light"]{ --page:#F4F6FB; --panel:#ffffff; --ink:#14161f; --ink-2:#454a5c; --ink-3:#61677b;
  --line:#d9deea; --line-2:#c3cadd; --accent:#2E37D4; --accent-soft:#e7e9fb; --code-bg:#eef1f8; --mark:#fff4c2;
  --edge:rgba(20,22,31,.30); }
:root[data-theme="dark"]{ --page:#08090f; --panel:#111420; --ink:#e8eaf2; --ink-2:#aeb4c9; --ink-3:#7d849c;
  --line:#232838; --line-2:#2f3548; --accent:#8f97ff; --accent-soft:#1b1f36; --code-bg:#141826; --mark:#3a3413; }

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%; scroll-behavior:smooth}
body{margin:0; background:var(--page); color:var(--ink); font-family:var(--serif); font-size:18px; line-height:1.62;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility}
::selection{background:var(--accent-soft); color:var(--ink)}
a{color:var(--accent); text-decoration:none}
a:hover{text-decoration:underline; text-underline-offset:2px}
:focus-visible{outline:2px solid var(--accent); outline-offset:3px; border-radius:3px}
[id]{scroll-margin-top:5.2rem}

/* ---- header (same as the blog posts) ---- */
.chrome{position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between;
  gap:1rem; padding:.85rem clamp(1rem,4vw,2.5rem); background:color-mix(in srgb,var(--page) 86%,transparent);
  backdrop-filter:saturate(1.3) blur(9px); border-bottom:1px solid var(--line)}
/* the company lockup, same as the homepage: candlestick drop-cap K (static SVG) + oblique "spectra",
   a broken rule through the p's descender band, and upright "Research" under the e (placed by paper.js) */
.brand{position:relative; display:flex; flex-direction:column; align-items:flex-start; width:max-content; line-height:1; text-decoration:none; color:var(--ink)}
.brand.laid{display:block}   /* paper.js measured the glyphs and switched to the exact lockup */
.brand:hover{text-decoration:none}
.brand .wm{display:inline-block; font-family:var(--serif); font-weight:600; font-size:1.42rem; letter-spacing:-.012em; line-height:1; white-space:nowrap}
.brand .kmark{display:inline-block; overflow:visible; height:1.17em; width:auto; margin-right:-.07em; vertical-align:-.2em; color:var(--ink)}   /* these are the no-JS defaults; paper.js refines them from the real glyph metrics */
.brand .spectra{font-style:oblique 10deg}
.brand .research{font-size:.62em; margin:.3em 0 0 34%; font-family:var(--serif); font-weight:500; letter-spacing:.005em; line-height:1; white-space:nowrap; opacity:.72}   /* stacked fallback before/without JS */
.brand.laid .research{position:absolute; margin:0}
.brand .rseg{position:absolute; height:1.2px; border-radius:1px; background:var(--line-2); pointer-events:none}
.nav-right{display:flex; align-items:center; gap:.4rem}
.nav-right a{font-family:var(--mono); font-size:.72rem; letter-spacing:.05em; color:var(--ink-2); padding:.4rem .5rem}
.tbtn{display:inline-grid; place-items:center; width:34px; height:34px; border-radius:8px;
  border:1px solid var(--line); background:var(--panel); color:var(--ink-2); cursor:pointer}
.tbtn:hover{border-color:var(--line-2); color:var(--ink)}
.tbtn svg{width:16px; height:16px}
.tbtn .sun{display:none} .tbtn .moon{display:block}
@media(prefers-color-scheme:dark){.tbtn .moon{display:none} .tbtn .sun{display:block}}
:root[data-theme="light"] .tbtn .moon{display:block} :root[data-theme="light"] .tbtn .sun{display:none}
:root[data-theme="dark"] .tbtn .moon{display:none} :root[data-theme="dark"] .tbtn .sun{display:block}

/* ---- layout: sidebar contents on wide screens, inline contents otherwise ---- */
.pwrap{display:grid; grid-template-columns:minmax(0,var(--measure)); justify-content:center; gap:0 3.2rem;
  padding:0 clamp(1rem,4vw,2.5rem)}
.toc-side{display:none}
@media (min-width:1180px){
  .pwrap{grid-template-columns:14.5rem minmax(0,var(--measure))}
  .toc-side{display:block; position:sticky; top:4.6rem; align-self:start; max-height:calc(100vh - 5.6rem); overflow:auto;
    padding:2.6rem .2rem 2rem 0; scrollbar-width:thin}
  .toc-inline{display:none}
  .pwrap::after{content:""}
}
main.paper{padding:2.6rem 0 4rem; min-width:0}

/* ---- paper header ---- */
.phead .eyebrow{font-family:var(--mono); font-size:.68rem; letter-spacing:.16em; text-transform:uppercase; color:var(--accent); margin:0 0 .9rem}
.phead h1{font-family:var(--serif); font-weight:600; font-size:clamp(1.75rem,4.2vw,2.5rem); line-height:1.14; letter-spacing:-.015em;
  margin:0 0 .9rem; text-wrap:balance}
.phead .authors{font-family:var(--sans); font-size:1rem; color:var(--ink-2); margin:0 0 1.1rem}
.phead .author-note{font-family:var(--sans); font-size:.8rem; color:var(--ink-3); margin:-.7rem 0 1.1rem}
.phead sup.aff{font-size:.7em; line-height:0; margin-left:.06em}
.phead .author-note a[href^="mailto:"]{color:inherit; text-decoration:underline dotted; text-underline-offset:3px}
.phead .author-note a[href^="mailto:"]:hover{color:var(--accent)}
.plinks{display:flex; flex-wrap:wrap; gap:.3rem 1.2rem; font-family:var(--mono); font-size:.8rem}
.plinks a{padding:.2rem 0}

.abstract{margin:2rem 0 1.4rem; padding:1.15rem 1.3rem; background:var(--panel); border:1px solid var(--line); border-radius:12px}
.abstract .label, .toc .label{font-family:var(--mono); font-size:.64rem; letter-spacing:.2em; text-transform:uppercase; color:var(--ink-3); margin:0 0 .55rem}
.abstract p{margin:0 0 .6em; font-size:1rem}
.abstract p:last-child{margin-bottom:0}
.keywords{font-family:var(--sans); font-size:.84rem; color:var(--ink-2); margin:.8rem 0 0}

/* ---- contents ---- */
.toc ol{list-style:none; margin:0; padding:0}
.toc li{margin:.18rem 0}
.toc ol ol{padding-left:1rem; margin:.1rem 0 .3rem}
.toc a{display:flex; gap:.5rem; color:var(--ink-2); font-family:var(--sans); font-size:.86rem; line-height:1.35; padding:.12rem 0}
.toc a .n{font-family:var(--mono); font-size:.72rem; color:var(--ink-3); min-width:1.6rem; padding-top:.1rem}
.toc a:hover{color:var(--accent); text-decoration:none}
.toc a.on{color:var(--accent)}
.toc a.on .n{color:var(--accent)}
.toc-inline{margin:0 0 2rem; border-top:1px solid var(--line); border-bottom:1px solid var(--line)}
.toc-inline summary{cursor:pointer; list-style:none; padding:.8rem 0; font-family:var(--mono); font-size:.68rem; letter-spacing:.2em; text-transform:uppercase; color:var(--ink-3)}
.toc-inline summary::-webkit-details-marker{display:none}
.toc-inline summary::after{content:" +"; color:var(--accent)}
.toc-inline[open] summary::after{content:" −"}
.toc-inline ol{padding-bottom:.9rem}

/* ---- body text ---- */
.body h2, .appendix h2, .refs h2, .notes h2{font-family:var(--serif); font-weight:600; font-size:clamp(1.35rem,2.8vw,1.7rem); line-height:1.2;
  letter-spacing:-.01em; margin:2.6rem 0 .9rem; text-wrap:balance}
.body h3{font-family:var(--serif); font-weight:600; font-size:1.22rem; line-height:1.25; margin:2rem 0 .7rem}
.body h4{font-family:var(--serif); font-weight:600; font-size:1.05rem; margin:1.6rem 0 .5rem}
.body h2 .secno, .body h3 .secno, .body h4 .secno{font-family:var(--mono); font-weight:500; font-size:.62em; color:var(--accent); margin-right:.6rem; vertical-align:.14em}
.body p{margin:0 0 1em}
.body ul, .body ol{padding-left:1.4rem; margin:0 0 1em}
.body li{margin:.2rem 0}
.body a.ref, .body a.cite{color:inherit; text-decoration:underline dotted var(--ink-3); text-underline-offset:3px}
.body a.ref:hover, .body a.cite:hover{color:var(--accent); text-decoration-color:var(--accent)}
code, .tt{font-family:var(--mono); font-size:.88em}

/* math: MathJax SVG rendered at build time (papers-build/render_math.mjs); numbers sit at the right margin */
math{font-family:var(--math); font-size:1.05em}   /* fallback only, if a formula could not be rendered */
.eq{margin:1.1rem 0; padding:.15rem 0; overflow-x:auto; overflow-y:hidden}
/* a display or table wider than the column scrolls; the inset edge says so, and goes when you reach the end */
.eq.scrollx, .tablewrap.scrollx, mjx-container.scrollx{box-shadow:inset -20px 0 14px -14px var(--edge)}
.eq.scrollx.at-end, .tablewrap.scrollx.at-end, mjx-container.scrollx.at-end{box-shadow:none}
/* displays outside the body (the abstract, footnotes) have no .eq box: the formula scrolls by itself */
.abstract mjx-container[display="true"], .notes mjx-container[display="true"]{max-width:100%; overflow-x:auto; overflow-y:hidden}
/* an inline formula longer than the whole line (rare, and only on the narrowest phones) scrolls in place;
   paper.js adds .wide only when it is needed, because an inline-block with overflow sits on its bottom edge */
mjx-container.wide{display:inline-block; max-width:100%; overflow-x:auto; overflow-y:hidden; vertical-align:middle}
.eq mjx-container[display="true"]{margin:0 !important}
mjx-container[jax="SVG"]{color:inherit}
.eq:target, .thm:target, figure:target, .tablefig:target{background:var(--mark); border-radius:8px; transition:background 1.2s}

/* theorem-like blocks and proofs */
.thm{margin:1.4rem 0; padding:.85rem 1.1rem; border-left:3px solid var(--accent); background:var(--panel); border-radius:0 10px 10px 0}
.thm p:last-child{margin-bottom:0}
.thm .thm-head{font-weight:700; font-style:normal; margin-right:.35rem}
.proof{margin:.6rem 0 1.4rem}
.proof .proof-head{font-style:italic; margin-right:.35rem}
.proof p:last-child{margin-bottom:0}
.qed{float:right; color:var(--ink-3); margin-left:.6rem}

/* figures and tables */
figure{margin:1.8rem 0}
.figbox{background:#fff; border:1px solid var(--line); border-radius:12px; padding:clamp(.6rem,2vw,1rem); overflow:hidden}
.figbox img, .figbox svg{display:block; max-width:100%; height:auto; margin:0 auto}
figcaption{font-family:var(--sans); font-size:.86rem; line-height:1.5; color:var(--ink-2); margin-top:.7rem}
figcaption .cap-id{font-weight:600; color:var(--ink)}
.tablewrap{overflow-x:auto; margin:.2rem 0}
.tablefig table{border-collapse:collapse; margin:0 auto; font-family:var(--sans); font-size:.9rem; border-top:1.5px solid var(--ink); border-bottom:1.5px solid var(--ink)}
.tablefig td, .tablefig th{padding:.4rem .75rem; white-space:nowrap}
.tablefig tr:first-child td, .tablefig tr:first-child th{border-bottom:1px solid var(--ink-2); font-weight:600}
.tablefig figcaption{margin:0 0 .6rem}
.figbox{cursor:zoom-in}

/* footnotes and references */
sup.fn a{font-family:var(--sans); font-size:.72em; padding:0 .1em}
.notes, .refs{margin-top:2.6rem; padding-top:.4rem; border-top:1px solid var(--line)}
.notes ol{padding-left:1.3rem; font-size:.92rem; color:var(--ink-2)}
.notes li{margin:.5rem 0}
.notes .back{font-family:var(--sans); margin-left:.3rem}
.refs .bib{font-size:.95rem; margin:0 0 .7rem; padding-left:1.6em; text-indent:-1.6em}
/* a URL or DOI is one unbroken word: let it wrap anywhere, or on a phone it widens the whole page */
.refs a, .refs code, .notes a, .notes code, .body a.url, .body code{overflow-wrap:anywhere}
/* last resort for any other run too long for the line (break-word, not anywhere: table cells keep their widths) */
.body p, .body li, .abstract p{overflow-wrap:break-word}
.refs .bib:target{background:var(--mark); border-radius:6px}

/* how to cite: a readable reference, the BibTeX, and the pointer to the Markdown copy */
.cite{margin-top:2.6rem; padding-top:.4rem; border-top:1px solid var(--line)}
.cite h2{font-family:var(--serif); font-weight:600; font-size:clamp(1.35rem,2.8vw,1.7rem); line-height:1.2}
.cite .cite-line{font-size:.95rem}
.cite .cite-line a, .cite .cite-alt a{overflow-wrap:anywhere}
.bibwrap{position:relative}
.cite pre.bibtex{margin:.8rem 0; padding:.9rem 1rem; background:var(--code-bg); border:1px solid var(--line); border-radius:10px;
  font-family:var(--mono); font-size:.74rem; line-height:1.6; overflow-x:auto; white-space:pre}
.cite button.copy{position:absolute; top:.45rem; right:.45rem; font:500 .68rem/1 var(--mono); letter-spacing:.04em; color:var(--ink-2);
  background:var(--panel); border:1px solid var(--line-2); border-radius:7px; padding:.4rem .55rem; cursor:pointer}
.cite button.copy:hover{color:var(--accent); border-color:var(--accent)}
.cite .cite-alt{font-family:var(--sans); font-size:.8rem; color:var(--ink-3)}

/* closing notes (AI-use disclosure, code availability, acknowledgements) read as a run-in lead */
.body p.backmatter{margin-top:1.6rem}

.pfoot{margin-top:3rem; padding-top:1.4rem; border-top:1px solid var(--line); font-family:var(--mono); font-size:.72rem; line-height:1.9; color:var(--ink-3)}
.pfoot p{margin:0}
.pfoot .pmotto{font-family:var(--serif); font-style:italic; font-size:1.25rem; line-height:1.3; color:var(--ink); margin-bottom:.9rem}
.pfoot a{color:var(--ink-2)}
.pfoot strong{color:var(--ink-2); font-weight:600}

/* full-screen figure view (tap/click a figure) */
.figzoom{position:fixed; inset:0; z-index:200; background:#fff; display:flex; flex-direction:column;
  padding:max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
.figzoom .zbar{display:flex; align-items:center; justify-content:space-between; gap:1rem; min-height:44px}
.figzoom .ztitle{font-family:var(--mono); font-size:.72rem; color:#454a5c; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.figzoom .zclose{flex:0 0 auto; width:40px; height:40px; border-radius:10px; border:1px solid #d9deea; background:#F4F6FB; color:#14161f; font-size:1.4rem; line-height:1; cursor:pointer}
.figzoom .zbody{position:relative; flex:1; min-height:0; display:flex; align-items:center; justify-content:center}
.figzoom .zbody img{display:block; max-width:100%; max-height:100%; width:auto; height:auto}
@media (orientation:portrait) and (max-width:560px){
  .figzoom[data-wide] .zbody img{position:absolute; top:50%; left:50%; max-width:none; max-height:none; width:var(--zh); height:auto; transform:translate(-50%,-50%) rotate(90deg)}
}
html.zoom-open, html.zoom-open body{overflow:hidden}

@media (max-width:640px){ body{font-size:17px} main.paper{padding-top:1.8rem} .abstract{padding:1rem} .eq{font-size:.9em} }
@media (prefers-reduced-motion:reduce){ html{scroll-behavior:auto} *{transition:none!important} }
@media print{
  .chrome, .toc, .toc-inline, .plinks{display:none!important}
  body{background:#fff; color:#000; font-size:11pt}
  .pwrap{display:block; padding:0} main.paper{padding:0}
  .abstract, .thm, .figbox{border-color:#999; background:#fff}
  a{color:#000}
}
