\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{monograph}[2026/10/22 K-COS book typography]
\RequirePackage[paperwidth=8.25in,paperheight=11in,left=.94in,right=.94in,top=.92in,bottom=.87in,headheight=15pt,headsep=23pt,footskip=27pt]{geometry}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{newpxtext}
\RequirePackage{amsmath,amsthm}
\RequirePackage{newpxmath}
\RequirePackage[scaled=.91]{inconsolata}
\renewcommand{\sfdefault}{qhv}
\DeclareTextFontCommand{\texttt}{\normalfont\ttfamily}
\RequirePackage{microtype}
\RequirePackage{mathtools}
\RequirePackage{booktabs,longtable,array,tabularx}
\RequirePackage{enumitem,xcolor,graphicx,float,caption}
\RequirePackage{titlesec,fancyhdr,listings,xurl}
\RequirePackage[most]{tcolorbox}
\RequirePackage{tikz}
\RequirePackage{placeins,needspace,etoolbox}
\RequirePackage{hyperref,bookmark}
\definecolor{ink}{HTML}{352C3B}
\definecolor{bodyink}{HTML}{252A2C}
\definecolor{accent}{HTML}{70566D}
\definecolor{gold}{HTML}{A98D5E}
\definecolor{muted}{HTML}{68656B}
\definecolor{pale}{HTML}{F7F5F7}
\definecolor{rulecolor}{HTML}{DCD7DD}
\definecolor{coverink}{HTML}{282331}
\colorlet{navy}{ink}
\colorlet{teal}{accent}
\definecolor{red}{HTML}{95544F}
\newcommand{\displayface}{\fontfamily{EBGaramond-LF}\fontseries{m}\fontshape{n}\selectfont}
\newcommand{\booklabel}[1]{{\sffamily\fontsize{8}{11}\selectfont\textls[125]{\MakeUppercase{#1}}}}
\hypersetup{colorlinks=true,linkcolor=ink,citecolor=accent,urlcolor=accent,
 pdftitle={The K-COS Method: Structured Gaussian Quadratic Forms, Spectral Compression, and Certified Extreme-Tail Evaluation},
 pdfauthor={Komorebi P.},pdfsubject={Realization Calculus: Mathematical Monographs},bookmarksopen=true,bookmarksopenlevel=0,bookmarksdepth=2,pdfdisplaydoctitle=true,pdfstartview=FitH}
\graphicspath{{figures_final/}{figures_packets/}{figures_visual/}{figures_edition/}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 1pt minus .5pt}
\makeatletter
\renewcommand\normalsize{\@setfontsize\normalsize{11.3pt}{14.9pt}\abovedisplayskip 10pt plus 2pt minus 2pt\belowdisplayskip 10pt plus 2pt minus 2pt\abovedisplayshortskip 5pt plus 2pt\belowdisplayshortskip 6pt plus 2pt minus 1pt\let\@listi\@listI}
\renewcommand\small{\@setfontsize\small{10.2pt}{13.3pt}\abovedisplayskip 8pt plus 2pt minus 2pt\belowdisplayskip 8pt plus 2pt minus 2pt\abovedisplayshortskip 4pt plus 1pt\belowdisplayshortskip 5pt plus 1pt}
\renewcommand\footnotesize{\@setfontsize\footnotesize{9.2pt}{12pt}}
\makeatother
\AtBeginDocument{\normalsize\color{bodyink}}
\setlength{\emergencystretch}{2.8em}
\usepackage{ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}
\hyphenpenalty=500
\clubpenalty=10000
\widowpenalty=10000
\displaywidowpenalty=10000
\raggedbottom
\setcounter{tocdepth}{0}
\setcounter{secnumdepth}{2}
\setlist{itemsep=3pt,topsep=5pt,parsep=0pt,leftmargin=1.6em}
\captionsetup{font={small,color=muted},labelfont={bf,color=ink},labelsep=period,skip=9pt,justification=raggedright,singlelinecheck=false}
\setlength{\textfloatsep}{22pt plus 3pt minus 2pt}
\setlength{\intextsep}{19pt plus 2pt minus 2pt}
\renewcommand{\topfraction}{.90}
\renewcommand{\bottomfraction}{.80}
\renewcommand{\textfraction}{.08}
\renewcommand{\floatpagefraction}{.68}
\setcounter{topnumber}{3}
\setcounter{totalnumber}{5}
\renewcommand{\arraystretch}{1.12}
\setlength{\tabcolsep}{5pt}
\setlength{\LTpre}{12pt}
\setlength{\LTpost}{12pt}
\titleformat{\chapter}[display]{\normalfont\color{ink}}{\booklabel{\chaptertitlename\enspace\thechapter}}{16pt}{\displayface\fontsize{38}{41}\selectfont\raggedright}[\vspace{-12pt}{\color{gold}\rule{36pt}{.7pt}}]
\titleformat{name=\chapter,numberless}[display]{\normalfont\color{ink}}{\booklabel{The K-COS Method}}{16pt}{\displayface\fontsize{36}{40}\selectfont\raggedright}[\vspace{-12pt}{\color{gold}\rule{36pt}{.7pt}}]
\titlespacing*{\chapter}{0pt}{17pt}{22pt}
\titleformat{\section}{\displayface\fontsize{20}{23}\selectfont\color{ink}}{\sffamily\fontsize{10}{13}\selectfont\color{accent}\thesection}{.75em}{}
\titlespacing*{\section}{0pt}{23pt plus 3pt minus 2pt}{9pt}
\titleformat{\subsection}{\normalfont\fontsize{12}{15}\selectfont\bfseries\color{ink}}{\thesubsection}{.65em}{}
\titlespacing*{\subsection}{0pt}{17pt plus 2pt minus 1pt}{6pt}
\titleformat{\subsubsection}{\normalsize\normalfont\bfseries\color{ink}}{\thesubsubsection}{.65em}{}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\sffamily\fontsize{7.2}{9}\selectfont\color{muted}\textls[65]{THE K-COS METHOD}}
\fancyhead[R]{\sffamily\fontsize{7.2}{9}\selectfont\color{muted}\nouppercase{\leftmark}}
\fancyfoot[R]{\fontsize{10}{12}\selectfont\color{muted}\thepage}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancypagestyle{plain}{\fancyhf{}\fancyfoot[R]{\fontsize{10}{12}\selectfont\color{muted}\thepage}\renewcommand{\headrulewidth}{0pt}}
\newtheoremstyle{monotheorem}{11pt}{11pt}{\itshape}{}{\bfseries\color{ink}}{.}{.5em}{}
\theoremstyle{monotheorem}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{example}{Example}[chapter]
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\DeclareMathOperator{\E}{\mathbb E}
\DeclareMathOperator{\Var}{Var}
\newcommand{\R}{\mathbb R}
\newcommand{\C}{\mathbb C}
\newcommand{\Pp}{\mathbb P}
\newcommand{\eps}{\varepsilon}
\newcommand{\ii}{\mathrm{i}}
\newcommand{\phit}{\phi_{\theta}}
\newcommand{\decl}[1]{\nolinkurl{#1}}
\newtcolorbox{atlasnote}{enhanced,breakable,colback=white,colframe=rulecolor,boxrule=0pt,borderline west={1pt}{0pt}{gold},arc=0pt,left=10pt,right=0pt,top=3pt,bottom=3pt,before skip=9pt,after skip=5pt}
\newtcolorbox{scopebox}{enhanced,breakable,colback=pale,colframe=rulecolor,boxrule=0pt,borderline west={1pt}{0pt}{gold},arc=0pt,left=12pt,right=11pt,top=9pt,bottom=9pt,before skip=13pt,after skip=15pt}
\lstset{basicstyle=\ttfamily\fontsize{10.2}{13.2}\selectfont,columns=fullflexible,keepspaces=true,breaklines=true,breakatwhitespace=false,showstringspaces=false,frame=none,backgroundcolor=\color{pale},xleftmargin=9pt,xrightmargin=9pt,framesep=9pt,aboveskip=15pt,belowskip=15pt,commentstyle=\color{muted},keywordstyle=\color{accent}\bfseries}
\makeatletter
\renewcommand*\l@part[2]{\ifnum\c@tocdepth>-2\relax\addpenalty{-\@highpenalty}\addvspace{22pt}\Needspace{5\baselineskip}\begingroup\parindent\z@\rightskip\@pnumwidth\parfillskip-\@pnumwidth{\sffamily\fontsize{10}{13}\selectfont\color{accent}#1\hfill#2\par}\nobreak\vspace{6pt}\endgroup\fi}
\renewcommand*\l@chapter[2]{\ifnum\c@tocdepth>\m@ne\addpenalty{-\@highpenalty}\vskip 6pt\setlength\@tempdima{2.2em}\begingroup\parindent\z@\rightskip\@pnumwidth\parfillskip-\@pnumwidth\leavevmode\normalfont\fontsize{11.3}{15}\selectfont\advance\leftskip\@tempdima\hskip-\leftskip#1\nobreak\hfil\nobreak\hb@xt@\@pnumwidth{\hss\color{muted}#2}\par\endgroup\fi}
\makeatother
\newcommand{\partchapter}[2]{\noindent\hyperref[#1]{{\color{muted}\ref*{#1}}\hspace{1em}#2}\hfill{\color{muted}\pageref{#1}}\par\vspace{4pt}}
\newcommand{\partoverview}{\begin{minipage}{\linewidth}\small\color{bodyink}
\ifcase\value{part}\or
\partchapter{ch:gaussian}{Gaussian quadratic forms}
\or
\partchapter{ch:streaming}{Exact streamed representations}
\partchapter{ch:phases}{Polyphase propagation and scheduling}
\partchapter{ch:range}{Range cores and low-rank interfaces}
\partchapter{ch:spectrum}{Spectral uncertainty and exact completion}
\or
\partchapter{ch:packets}{Exponential tilting and spectral packets}
\partchapter{ch:inversion}{COS inversion and the analytic error budget}
\partchapter{ch:adaptive}{Adaptive evaluation and numerical interfaces}
\or
\partchapter{ch:intervals}{Directed probability enclosures}
\partchapter{ch:accuracy}{Accuracy-driven certification}
\partchapter{ch:evidence}{Numerical evidence and applications}
\partchapter{ch:synthesis}{Composition, scope, and contribution}
\fi\end{minipage}}
\newcommand{\monopart}[3]{\clearpage\refstepcounter{part}\label{#1}\addcontentsline{toc}{part}{\thepart\space #2}\markboth{#2}{}\thispagestyle{plain}\vspace*{.5in}{\color{accent}\booklabel{Part \thepart}\par}\vspace{27pt}{\displayface\fontsize{43}{47}\selectfont\color{ink}\raggedright#2\par}\vspace{23pt}{\color{gold}\rule{40pt}{.8pt}}\par\vspace{19pt}\begin{minipage}{.91\linewidth}\fontsize{12.4}{17}\selectfont #3\end{minipage}\vfill{\color{rulecolor}\rule{\linewidth}{.4pt}}\par\vspace{15pt}\partoverview\vspace*{.3in}\clearpage}
\newcommand{\monocover}{\begin{titlepage}\thispagestyle{empty}
\begin{tikzpicture}[remember picture,overlay]
\fill[coverink] (current page.south west) rectangle (current page.north east);
\node[anchor=north west,text=rulecolor,inner sep=0pt] at ([xshift=.94in,yshift=-.93in]current page.north west) {\booklabel{Realization Calculus / Mathematical Monographs}};
\draw[gold,line width=.8pt] ([xshift=.94in,yshift=-1.46in]current page.north west)--++(.55in,0);
\node[anchor=north west,align=left,text=white,inner sep=0pt] at ([xshift=.88in,yshift=-1.80in]current page.north west) {\displayface\fontsize{67}{70}\selectfont\begin{tabular}{@{}l@{}}The K-COS\\Method\end{tabular}};
\node[anchor=north west,align=left,text=white,inner sep=0pt,text width=6.0in] at ([xshift=.94in,yshift=-4.20in]current page.north west) {\displayface\fontsize{23}{29}\selectfont Structured Gaussian Quadratic Forms,\\Spectral Compression, and\\Certified Extreme-Tail Evaluation};
\draw[rulecolor!35!coverink,line width=.4pt] ([xshift=.94in,yshift=1.57in]current page.south west)--([xshift=-.94in,yshift=1.57in]current page.south east);
\node[anchor=south west,text=white,inner sep=0pt] at ([xshift=.94in,yshift=.99in]current page.south west) {\displayface\fontsize{17}{21}\selectfont Komorebi P.};
\end{tikzpicture}\null\end{titlepage}\setcounter{page}{2}}
\newcommand{\monotitle}{\clearpage\thispagestyle{empty}\vspace*{.2in}{\color{accent}\booklabel{Realization Calculus}\par}\vspace{.62in}{\displayface\fontsize{52}{55}\selectfont\color{ink}The K-COS\\Method\par}\vspace{.38in}{\displayface\fontsize{23}{28}\selectfont\color{ink}Structured Gaussian Quadratic Forms,\\Spectral Compression, and\\Certified Extreme-Tail Evaluation\par}\vspace{.32in}{\color{gold}\rule{38pt}{.8pt}}\vfill{\displayface\fontsize{18}{22}\selectfont Komorebi P.\par}\vspace{.22in}{\small\color{muted}A mathematical monograph in four parts.\par}\vspace*{.35in}\clearpage\setcounter{page}{1}}
\renewcommand{\bibname}{References}

\newcommand{\chapterlead}[1]{\begingroup\fontsize{11.6}{15.7}\selectfont\color{ink}#1\par\endgroup\vspace{3pt}}
\newcommand{\atlasheading}[3]{\noindent{\booklabel{Study #1 / #2}\par}\vspace{10pt}{\displayface\fontsize{27}{30}\selectfont\color{ink}\raggedright #3\par}\vspace{8pt}}
\newcommand{\studyresult}[1]{\begin{atlasnote}\small #1\end{atlasnote}}
\AtBeginEnvironment{theorem}{\Needspace{5\baselineskip}}
\AtBeginEnvironment{proposition}{\Needspace{5\baselineskip}}
\AtBeginEnvironment{corollary}{\Needspace{4\baselineskip}}
\AtBeginEnvironment{lemma}{\Needspace{4\baselineskip}}
\AtBeginEnvironment{proof}{\Needspace{3\baselineskip}}
\renewcommand{\bibname}{References}
