% beamerthemeCelestia.sty
%
% copyright (C) 2025 Razik Ikhlef
% razik.ikhlef@csilyon.fr
%
% The newest version of this beamer theme should always be available
% from the following web page: https://apps.edulatex.xyz/celestia/

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthemeCelestia}[2026/03/21 v1.2.2]

\RequirePackage{iftex}
\RequirePackage{etoolbox}
\RequirePackage{kvoptions}
\RequirePackage{xstring}
\RequirePackage{scalefnt}

\newcommand{\hugeHuge}{\scalefont{2.28}\selectfont}
\newcommand{\LARGEhuge}{\scalefont{1.9}\selectfont}
\newcommand{\LargeLARGE}{\scalefont{1.58}\selectfont}
\newcommand{\largeLarge}{\scalefont{1.32}\selectfont}
\newcommand{\normalsizelarge}{\scalefont{1.1}\selectfont}
\newcommand{\smallnormalsize}{\scalefont{0.95}\selectfont}
\newcommand{\footnotesizesmall}{\scalefont{0.85}\selectfont}
\newcommand{\scriptsizefootnotesize}{\scalefont{0.75}\selectfont}
\newcommand{\tinyscriptsize}{\scalefont{0.6}\selectfont}

\RequirePackage{silence}
\WarningFilter{latexfont}{Font shape}
\renewcommand{\@font@warning}[1]{}

\def\celestia@palette{nordic}

\SetupKeyvalOptions{
  family=celestia,
  prefix=celestia@
}

\DeclareBoolOption{allserif}
\DeclareBoolOption[true]{semibold}
\DeclareBoolOption[true]{light}
\DeclareBoolOption{unicolor}
\DeclareBoolOption{standout}
\DeclareBoolOption{compacttoc}
\DeclareBoolOption{twocoltoc}
\DeclareBoolOption[true]{codebox}
\DeclareBoolOption{nocodeframe}
\DeclareBoolOption{shownavigation}
\DeclareBoolOption{boldurl}
\DeclareBoolOption[true]{sectionpage}
\DeclareBoolOption[false]{sectionnumber}
\DeclareBoolOption[false]{progressbar}

\DeclareStringOption[sober]{block}
\DeclareStringOption[info]{footerstyle}
\DeclareStringOption[bar]{codestyle}
\DeclareStringOption[left]{titlealign}
\DeclareStringOption{titlebackground}
\DeclareStringOption[0.30]{shadedblockopacity}
\DeclareStringOption[0.18]{soberblockopacity}
\DeclareStringOption[0.18]{softblockopacity}
\DeclareStringOption[0.05]{barblockopacity}
\DeclareStringOption[listings]{codehandler}

\DeclareStringOption[sffamily]{headstyle}
\DeclareStringOption[normal]{headshape}
\DeclareStringOption[bfseries]{headweight}
\DeclareStringOption[bfseries]{blocktitleweight}
\DeclareStringOption[LargeLARGE]{titlesize}
\DeclareStringOption[normalsize]{frametitlesize}
\DeclareStringOption[LARGE]{sectiontitlesize}
\DeclareStringOption[Large]{subtitlesize}
\DeclareStringOption[tiny]{footertextsize}

\DeclareStringOption{maincolor}
\DeclareStringOption{accentcolor}
\DeclareStringOption{backgroundcolor}
\DeclareStringOption{codebackgroundcolor}
\DeclareStringOption{blockcolor}
\DeclareStringOption{examplecolor}
\DeclareStringOption{alertcolor}
\DeclareStringOption{custompalette}

\DeclareStringOption[2em]{margin}
\DeclareStringOption[subtle]{frametitle}

\DeclareStringOption[literata]{serifface}
\DeclareStringOption[]{seriffaceoptions}
\DeclareStringOption[inter]{sansface}
\DeclareStringOption[]{sansfaceoptions}
\DeclareStringOption[plex-mono]{monoface}
\DeclareStringOption[]{monofaceoptions}
\DeclareStringOption[iwona]{mathface}
\DeclareStringOption[]{mathfaceoptions}

\DeclareStringOption[english]{language}
\DeclareStringOption[main]{emphasis}
\DeclareStringOption[\celestia@emphasis]{decoration}

\newcommand{\celestia@set@palette}[6]{%
  \def\celestia@maincolor{#1}%
  \def\celestia@accentcolor{#2}%
  \def\celestia@blockcolor{#3}%
  \def\celestia@examplecolor{#4}%
  \def\celestia@alertcolor{#5}%
  \def\celestia@backgroundcolor{#6}%
}

\newcommand{\celestia@scheme@minimal}{%
  \def\celestia@palette{sapphire}%
  \def\celestia@frametitle{plain}%
  \def\celestia@footerstyle{minimalist}%
  \def\celestia@block{soft}%
}

\newcommand{\celestia@scheme@signature}{%
  \def\celestia@palette{petrol}%
  \def\celestia@frametitle{cosmic}%
  \def\celestia@footerstyle{cosmic}%
  \def\celestia@block{fullbar}%
}

\newcommand{\celestia@scheme@studio}{%
  \def\celestia@palette{oxford}%
  \def\celestia@frametitle{elegant}%
  \def\celestia@footerstyle{info}%
  \def\celestia@block{sober}%
  \def\celestia@emphasis{accent}%
}

\newcommand{\celestia@scheme@academic}{%
  \def\celestia@palette{horizon}%
  \def\celestia@frametitle{elegant}%
  \def\celestia@footerstyle{classic}%
  \def\celestia@block{native}%
  \def\celestia@titlealign{center}%
}

\newcommand{\celestia@scheme@modern}{%
  \def\celestia@palette{nordic}%
  \def\celestia@frametitle{subtle}%
  \def\celestia@footerstyle{info}%
  \def\celestia@block{sober}%
}

\newcommand{\celestia@scheme@design}{%
  \def\celestia@palette{imperial}%
  \def\celestia@frametitle{clean}%
  \def\celestia@footerstyle{badge}%
  \def\celestia@block{bar}%
}

\newcommand{\celestia@scheme@executive}{%
  \def\celestia@palette{palatial}%
  \def\celestia@frametitle{leftbar}%
  \def\celestia@footerstyle{fullbar}%
  \def\celestia@block{fullbar}%
}

\newcommand{\celestia@scheme@sober}{%
  \def\celestia@palette{terracotta}%
  \def\celestia@frametitle{gradient}%
  \def\celestia@footerstyle{info}%
  \def\celestia@block{sober}%
}

\newcommand{\celestia@scheme@simple}{%
  \def\celestia@palette{steel}%
  \def\celestia@frametitle{plain}%
  \def\celestia@footerstyle{minimalist}%
  \def\celestia@block{noback}%
}

\newcommand{\celestia@scheme@editorial}{%
  \def\celestia@palette{manuscript}%
  \def\celestia@frametitle{line}%
  \def\celestia@footerstyle{ruled}%
  \def\celestia@block{sober}%
}

\newcommand{\celestia@scheme@lumiere}{%
  \def\celestia@palette{lumiere}%
  \def\celestia@frametitle{plainrule}%
  \def\celestia@footerstyle{framed}%
  \def\celestia@block{soft}%
}

\newcommand{\celestia@scheme@chalk}{%
  \def\celestia@palette{chalk}%
  \def\celestia@frametitle{subtle}%
  \def\celestia@footerstyle{boxedruled}%
  \def\celestia@block{bar}%
  \def\celestia@barblockopacity{0.15}%
}

\define@key{celestia}{style}{%
  \csname celestia@scheme@#1\endcsname
}

%% Palettes
\newcommand{\celestia@palette@chalk}{\celestia@set@palette{2B303A}{D9963A}{5A8A70}{82B87A}{C04040}{E8E4D9}}
\newcommand{\celestia@palette@copper}{\celestia@set@palette{2A3040}{B35D33}{2E5055}{3D6D5D}{A63D40}{F8F9FA}}
\newcommand{\celestia@palette@dusk}{\celestia@set@palette{D8EEE8}{CCA030}{3A9080}{78AA48}{D86050}{131C20}}
\newcommand{\celestia@palette@horizon}{\celestia@set@palette{183D54}{00788C}{1F4E5F}{2E8B57}{B91C1C}{F8FAFA}}
\newcommand{\celestia@palette@imperial}{\celestia@set@palette{1A2535}{B22222}{2A4060}{2E5940}{B71C1C}{FAFAFA}}
\newcommand{\celestia@palette@lumiere}{\celestia@set@palette{2C3D55}{A05070}{3A4F6A}{1E6B5E}{8B3050}{F7F6F4}}
\newcommand{\celestia@palette@manuscript}{\celestia@set@palette{2E2E58}{8A62B8}{2D4A7A}{3A7D5A}{B03030}{FFFDF5}}
\newcommand{\celestia@palette@midnight}{\celestia@set@palette{E0E2F4}{A87AE0}{5A7EC8}{5AAA7A}{E06060}{161828}}
\newcommand{\celestia@palette@mineral}{\celestia@set@palette{243350}{B85A20}{1E293B}{1E3A8A}{B45309}{FAFAF8}}
\newcommand{\celestia@palette@nordic}{\celestia@set@palette{1C3A4E}{3D8AAA}{2D5A6A}{6A9A70}{BF4E4E}{F5F8F8}}
\newcommand{\celestia@palette@obsidian}{\celestia@set@palette{E8EAF6}{3FA8D8}{4A6A8A}{81C784}{F06060}{22242E}}
\newcommand{\celestia@palette@oxford}{\celestia@set@palette{212F42}{4A7AA8}{2C3E50}{43766C}{922B21}{F9FAFB}}
\newcommand{\celestia@palette@palatial}{\celestia@set@palette{243868}{B08A20}{1F3A5F}{2D5A27}{A33B20}{F8FAFC}}
\newcommand{\celestia@palette@petrol}{\celestia@set@palette{14404E}{B58900}{1F4A44}{7A9342}{A04030}{F9FBF9}}
\newcommand{\celestia@palette@prestige}{\celestia@set@palette{283D62}{A83858}{2D3F5E}{1E6B5E}{A03050}{F8F7F5}}
\newcommand{\celestia@palette@royal}{\celestia@set@palette{233348}{1A7A9A}{1A4A5A}{2D5A4C}{B03A2E}{FCFCFD}}
\newcommand{\celestia@palette@sakura}{\celestia@set@palette{4A4A4A}{C4607A}{8E7DBE}{99B898}{FE6B8B}{FFF9FB}}
\newcommand{\celestia@palette@sapphire}{\celestia@set@palette{1E2E50}{2C5FD6}{334155}{0F766E}{BE123C}{FDFDFD}}
\newcommand{\celestia@palette@steel}{\celestia@set@palette{1E2E48}{3D6BAA}{1E293B}{5A8A72}{941111}{F8FAFC}}
\newcommand{\celestia@palette@terracotta}{\celestia@set@palette{4A2C20}{B05E27}{6A5A4A}{5C7A5C}{C04A20}{FFF9F5}}
\newcommand{\celestia@palette@velours}{\celestia@set@palette{EAE0EC}{C8A030}{7A5AA8}{3A9888}{D05060}{1C1420}}
\newcommand{\celestia@palette@velvet}{\celestia@set@palette{3D2838}{8A7430}{3D2A3A}{17626E}{8B3A2A}{FBF9F8}}

\def\celestia@parse@custompalette#1{%
  \celestia@parse@palette@aux#1,,,,,\relax
}

\def\celestia@parse@palette@aux#1,#2,#3,#4,#5,#6,#7\relax{%
  \def\celestia@maincolor{#1}%
  \def\celestia@accentcolor{#2}%
  \def\celestia@blockcolor{#3}%
  \def\celestia@examplecolor{#4}%
  \def\celestia@alertcolor{#5}%
  \def\celestia@backgroundcolor{#6}%
}

\define@key{celestia}{palette}[lumiere]{%
  \def\celestia@palette{#1}
  \expandafter\ifx\csname celestia@palette@#1\endcsname\relax
    \PackageError{celestia}{Unknown palette: #1.}{See documentation.}%
  \else
    \csname celestia@palette@#1\endcsname
  \fi
}

\define@key{celestia}{custompalette}{%
  \celestia@parse@custompalette{#1}%
}

\newif\ifcelestia@user@sansfaceoptions@set
\newif\ifcelestia@user@frametitle@set
\newif\ifcelestia@user@footerstyle@set
\newif\ifcelestia@user@decoration@set
\newif\ifcelestia@user@headstyle@set

\define@key{celestia}{headstyle}{%
  \celestia@user@headstyle@settrue
  \def\celestia@headstyle{#1}%
}

\define@key{celestia}{sansfaceoptions}{%
  \celestia@user@sansfaceoptions@settrue
  \def\celestia@sansfaceoptions{#1}%
}

\define@key{celestia}{frametitle}{%
  \celestia@user@frametitle@settrue
  \def\celestia@frametitle{#1}%
}

\define@key{celestia}{footerstyle}{%
  \celestia@user@footerstyle@settrue
  \def\celestia@footerstyle{#1}%
}

\define@key{celestia}{decoration}{%
  \celestia@user@decoration@settrue
  \def\celestia@decoration{#1}%
}

\ProcessKeyvalOptions*

\csname celestia@palette@\celestia@palette\endcsname

\@ifpackageloaded{babel}{}{
  \RequirePackage[\celestia@language]{babel}
}

\def\celestia@name@theorem{Theorem}
\def\celestia@name@definition{Definition}
\def\celestia@name@definitions{Definitions}
\def\celestia@name@example{Example}
\def\celestia@name@examples{Examples}
\def\celestia@name@remark{Remark}
\def\celestia@name@remarks{Remarks}
\def\celestia@name@proposition{Proposition}
\def\celestia@name@corollary{Corollary}
\def\celestia@name@lemma{Lemma}
\def\celestia@name@property{Property}
\def\celestia@name@properties{Properties}
\def\celestia@name@activity{Activity}
\def\celestia@name@activities{Activities}
\def\celestia@name@application{Application}
\def\celestia@name@applications{Applications}
\def\celestia@name@method{Method}

\ifdefstring{\celestia@language}{french}{
  \def\celestia@name@theorem{Théorème}
  \def\celestia@name@definition{Définition}
  \def\celestia@name@definitions{Définitions}
  \def\celestia@name@example{Exemple}
  \def\celestia@name@examples{Exemples}
  \def\celestia@name@remark{Remarque}
  \def\celestia@name@remarks{Remarques}
  \def\celestia@name@proposition{Proposition}
  \def\celestia@name@corollary{Corollaire}
  \def\celestia@name@lemma{Lemme}
  \def\celestia@name@property{Propriété}
  \def\celestia@name@properties{Propriétés}
  \def\celestia@name@activity{Activité}
  \def\celestia@name@activities{Activités}
  \def\celestia@name@application{Application}
  \def\celestia@name@applications{Applications}
  \def\celestia@name@method{Méthode}
}{}

\def\celestia@fs@info{info}
\def\celestia@fs@fullbar{fullbar}
\def\celestia@fs@badge{badge}
\def\celestia@fs@classic{classic}
\def\celestia@fs@prestige{prestige}
\def\celestia@fs@cosmic{cosmic}
\def\celestia@fs@minimalist{minimalist}
\def\celestia@fs@ruled{ruled}
\def\celestia@fs@framed{framed}
\def\celestia@fs@boxed{boxed}
\def\celestia@fs@boxedruled{boxedruled}

\expandafter\ifx\csname celestia@fs@\celestia@footerstyle\endcsname\relax
  \PackageWarning{celestia}{Unknown footerstyle: \celestia@footerstyle}%
\fi

\pgfmathparse{int(\celestia@soberblockopacity*100)}
\let\celestia@soberopacity\pgfmathresult

\pgfmathparse{int(\celestia@softblockopacity*100)}
\let\celestia@softopacity\pgfmathresult

\pgfmathparse{int(\celestia@shadedblockopacity*100)}
\let\celestia@shadedopacity\pgfmathresult

\pgfmathparse{int(\celestia@barblockopacity*100)}
\let\celestia@baropacity\pgfmathresult


\RequirePackage{tikz}
\usetikzlibrary{backgrounds,calc,shapes,decorations.fractals,fadings}

\RequirePackage[most]{tcolorbox}
\tcbuselibrary{skins}
\RequirePackage{multicol}
\RequirePackage{xparse}
\RequirePackage{hyperref}

\usefonttheme{professionalfonts}

\ifcelestia@semibold
  \iftutex
    \ifx\celestia@sansfaceoptions\@empty
      \def\celestia@sansfaceoptions{BoldFeatures={Weight=600}}
    \else
      \appto\celestia@sansfaceoptions{,BoldFeatures={Weight=600}}
    \fi
    \ifx\celestia@seriffaceoptions\@empty
      \def\celestia@seriffaceoptions{BoldFeatures={Weight=600}}
    \else
      \appto\celestia@seriffaceoptions{,BoldFeatures={Weight=600}}
    \fi
  \fi
\fi
\ifcelestia@light
  \iftutex
    \ifx\celestia@sansfaceoptions\@empty
      \def\celestia@sansfaceoptions{UprightFeatures={Weight=300}}
    \else
      \appto\celestia@sansfaceoptions{,UprightFeatures={Weight=300}}
    \fi
    \ifx\celestia@monofaceoptions\@empty
      \def\celestia@monofaceoptions{UprightFeatures={Weight=300}}
    \else
      \appto\celestia@monofaceoptions{,UprightFeatures={Weight=300}}
    \fi
  \fi
\fi

\iftutex
  \RequirePackage{fontspec}
  \defaultfontfeatures{Scale=MatchLowercase}

  \IfStrEq{\celestia@sansface}{inter}{%
    \IfFontExistsTF{Inter}{%
      \ifcelestia@user@sansfaceoptions@set
        \setsansfont{Inter}[Scale=0.88, \celestia@sansfaceoptions]
      \else
        \ifcelestia@light
          \IfFontExistsTF{Inter Light}{%
            \ifcelestia@semibold
              \IfFontExistsTF{Inter SemiBold}{%
                \setsansfont{Inter}[Scale=0.88, UprightFont={Inter Light}, BoldFont={Inter SemiBold}]
              }{%
                \setsansfont{Inter}[Scale=0.88, UprightFont={Inter Light}, \celestia@sansfaceoptions]
              }
            \else
              \setsansfont{Inter}[Scale=0.88, UprightFont={Inter Light}]
            \fi
          }{%
            \setsansfont{Inter}[Scale=0.88, \celestia@sansfaceoptions]
          }
        \else
          \ifcelestia@semibold
            \IfFontExistsTF{Inter SemiBold}{%
              \setsansfont{Inter}[Scale=0.88, BoldFont={Inter SemiBold}]
            }{%
              \setsansfont{Inter}[Scale=0.88, \celestia@sansfaceoptions]
            }
          \else
            \setsansfont{Inter}[Scale=0.88]
          \fi
        \fi
      \fi
    }{%
      \setsansfont{texgyreheros-regular.otf}[
      Scale=0.95,
      BoldFont=texgyreheros-bold.otf,
      ItalicFont=texgyreheros-italic.otf,
      BoldItalicFont=texgyreheros-bolditalic.otf,
      ]
    }
  }{%
    \IfFontExistsTF{\celestia@sansface}{%
      \setsansfont{\celestia@sansface}[\celestia@sansfaceoptions]
    }{%
      \PackageWarning{celestia}{Sans font '\celestia@sansface' not found.
        On XeLaTeX, try the exact file name (e.g. SourceSans3-Regular.otf)
        or check fc-list. Falling back to TeX Gyre Heros}%
      \setsansfont{texgyreheros-regular.otf}[
        Scale=0.95,
        BoldFont=texgyreheros-bold.otf,
        ItalicFont=texgyreheros-italic.otf,
        BoldItalicFont=texgyreheros-bolditalic.otf,
      ]
    }
  }

  \IfStrEq{\celestia@serifface}{literata}{%
    \IfFontExistsTF{Literata}{%
      \setmainfont{Literata}[\celestia@seriffaceoptions]
    }{%
      \setmainfont{texgyrepagella-regular.otf}[
      BoldFont=texgyrepagella-bold.otf,
      ItalicFont=texgyrepagella-italic.otf,
      BoldItalicFont=texgyrepagella-bolditalic.otf,
      ]
    }
  }{%
    \IfStrEq{\celestia@serifface}{none}{}{%
      \IfFontExistsTF{\celestia@serifface}{%
        \setmainfont{\celestia@serifface}[\celestia@seriffaceoptions]
      }{%
        \PackageWarning{celestia}{Serif font '\celestia@serifface' not found.
          On XeLaTeX, try the exact file name. Falling back to TeX Gyre Pagella}%
        \setmainfont{texgyrepagella-regular.otf}[
          BoldFont=texgyrepagella-bold.otf,
          ItalicFont=texgyrepagella-italic.otf,
          BoldItalicFont=texgyrepagella-bolditalic.otf,
        ]
      }
    }
  }

  \IfStrEq{\celestia@monoface}{plex-mono}{%
    \IfFontExistsTF{IBM Plex Mono}{%
      \setmonofont{IBM Plex Mono}[\celestia@monofaceoptions]
    }{%
      \IfFontExistsTF{IBMPlexMono-Regular.otf}{%
        \setmonofont{IBMPlexMono-Regular.otf}[
        BoldFont=IBMPlexMono-Bold.otf,
        ItalicFont=IBMPlexMono-Italic.otf,
        BoldItalicFont=IBMPlexMono-BoldItalic.otf,
        ]
      }{%
        \setmonofont{texgyrecursor-regular.otf}[
        BoldFont=texgyrecursor-bold.otf,
        ItalicFont=texgyrecursor-italic.otf,
        BoldItalicFont=texgyrecursor-bolditalic.otf,
        ]
      }
    }
  }{%
    \IfFontExistsTF{\celestia@monoface}{%
      \setmonofont{\celestia@monoface}[\celestia@monofaceoptions]
    }{%
      \PackageWarning{celestia}{Mono font '\celestia@monoface' not found.
        On XeLaTeX, try the exact file name. Falling back to TeX Gyre Cursor}%
      \setmonofont{texgyrecursor-regular.otf}[
        BoldFont=texgyrecursor-bold.otf,
        ItalicFont=texgyrecursor-italic.otf,
        BoldItalicFont=texgyrecursor-bolditalic.otf,
      ]
    }
  }
  \defaultfontfeatures{Ligatures=TeX}
  \ifcelestia@allserif
    \renewcommand{\familydefault}{\rmdefault}
    \ifcelestia@user@headstyle@set\else
      \def\celestia@headstyle{rmfamily}%
    \fi
  \fi
  \ifx\celestia@mathface\@empty\else
    \IfStrEq{\celestia@mathface}{iwona}{%
      \SetSymbolFont{operators}{normal}{OT1}{iwona}{m}{n}%
      \SetSymbolFont{operators}{bold}{OT1}{iwona}{b}{n}%
      \SetSymbolFont{letters}{normal}{OML}{iwona}{m}{it}%
      \SetSymbolFont{letters}{bold}{OML}{iwona}{b}{it}%
      \SetSymbolFont{symbols}{normal}{OMS}{iwona}{m}{n}%
      \SetSymbolFont{symbols}{bold}{OMS}{iwona}{b}{n}%
      \SetSymbolFont{largesymbols}{normal}{OMX}{iwona}{m}{n}%
      \SetMathAlphabet{\mathrm}{normal}{OT1}{iwona}{m}{n}
      \SetMathAlphabet{\mathrm}{bold}{OT1}{iwona}{b}{n}
      \SetMathAlphabet{\mathbf}{normal}{OT1}{iwona}{b}{n}
      \SetMathAlphabet{\mathbf}{bold}{OT1}{iwona}{eb}{n}
      \SetMathAlphabet{\mathit}{normal}{OT1}{iwona}{m}{it}
      \SetMathAlphabet{\mathit}{bold}{OT1}{iwona}{b}{it}
      \SetMathAlphabet{\mathsf}{normal}{OT1}{iwona}{m}{n}
      \SetMathAlphabet{\mathsf}{bold}{OT1}{iwona}{b}{n}
    }{%
    \IfStrEq{\celestia@mathface}{kurier}{%
      \SetSymbolFont{operators}{normal}{OT1}{kurier}{m}{n}%
      \SetSymbolFont{operators}{bold}{OT1}{kurier}{b}{n}%
      \SetSymbolFont{letters}{normal}{OML}{kurier}{m}{it}%
      \SetSymbolFont{letters}{bold}{OML}{kurier}{b}{it}%
      \SetSymbolFont{symbols}{normal}{OMS}{kurier}{m}{n}%
      \SetSymbolFont{symbols}{bold}{OMS}{kurier}{b}{n}%
      \SetSymbolFont{largesymbols}{normal}{OMX}{kurier}{m}{n}%
      \SetMathAlphabet{\mathrm}{normal}{OT1}{kurier}{m}{n}
      \SetMathAlphabet{\mathrm}{bold}{OT1}{kurier}{b}{n}
      \SetMathAlphabet{\mathbf}{normal}{OT1}{kurier}{b}{n}
      \SetMathAlphabet{\mathbf}{bold}{OT1}{kurier}{eb}{n}
      \SetMathAlphabet{\mathit}{normal}{OT1}{kurier}{m}{it}
      \SetMathAlphabet{\mathit}{bold}{OT1}{kurier}{b}{it}
      \SetMathAlphabet{\mathsf}{normal}{OT1}{kurier}{m}{n}
      \SetMathAlphabet{\mathsf}{bold}{OT1}{kurier}{b}{n}
    }{%
    \IfStrEq{\celestia@mathface}{mtpro2}{%
      \let\digamma\undefined
      \let\hbar\undefined
      \let\notsimeq\undefined
      \RequirePackage[lite,subscriptcorrection,slantedGreek,nofontinfo]{mtpro2}
      \begingroup\lccode`~=`\{ \lowercase{\endgroup\let~}\textbraceleft
      \begingroup\lccode`~=`\} \lowercase{\endgroup\let~}\textbraceright
      \AtBeginDocument{%
        \let\{\textbraceleft
        \let\}\textbraceright
      }
    }{%
    \IfStrEq{\celestia@mathface}{noto}{%
      \let\celestia@saved@sfdefault\sfdefault
      \let\celestia@saved@rmdefault\rmdefault
      \RequirePackage{notomath}
      \AddToHook{begindocument/end}{%
        \let\sfdefault\celestia@saved@sfdefault
        \let\rmdefault\celestia@saved@rmdefault
      }
    }{%
      \RequirePackage{unicode-math}
      \IfStrEq{\celestia@mathface}{pagella}{%
        \setmathfont{TeX Gyre Pagella Math}[\celestia@mathfaceoptions]
      }{%
        \IfStrEq{\celestia@mathface}{termes}{%
          \setmathfont{TeX Gyre Termes Math}[\celestia@mathfaceoptions]
        }{%
          \IfStrEq{\celestia@mathface}{stix}{%
            \setmathfont{STIX Two Math}[\celestia@mathfaceoptions]
          }{%
            \IfStrEq{\celestia@mathface}{libertinus}{%
              \setmathfont{Libertinus Math}[\celestia@mathfaceoptions]
            }{%
              \IfStrEq{\celestia@mathface}{fira}{%
                \setmathfont{Fira Math}[\celestia@mathfaceoptions]
              }{%
                \setmathfont{\celestia@mathface}[\celestia@mathfaceoptions]
              }
            }
          }
        }
      }
    }}}}
  \fi
\else
  \RequirePackage[T1]{fontenc}
  \RequirePackage[utf8]{inputenc}

  \IfStrEq{\celestia@sansface}{inter}{%
    \IfFileExists{inter.sty}{%
      \ifcelestia@user@sansfaceoptions@set
        \ifx\celestia@sansfaceoptions\@empty
          \PassOptionsToPackage{scaled=0.88}{inter}
        \else
          \PassOptionsToPackage{\celestia@sansfaceoptions}{inter}
        \fi
      \else
        \ifcelestia@light
          \PassOptionsToPackage{light,scaled=0.88}{inter}
        \else
          \PassOptionsToPackage{scaled=0.88}{inter}
        \fi
      \fi
      \RequirePackage{inter}
    }{%
      \RequirePackage{helvet}
      \renewcommand{\familydefault}{\sfdefault}
    }
  }{%
    \PassOptionsToPackage{\celestia@sansfaceoptions}{\celestia@sansface}
    \RequirePackage{\celestia@sansface}
  }

  \IfStrEq{\celestia@serifface}{literata}{%
    \IfFileExists{XCharter.sty}{%
      \let\celestia@saved@familydefault\familydefault
      \RequirePackage{XCharter}
      \let\familydefault\celestia@saved@familydefault
    }{%
      \RequirePackage{mathpazo}
    }
  }{%
    \IfStrEq{\celestia@serifface}{none}{}{%
      \IfFileExists{\celestia@serifface.sty}{%
        \PassOptionsToPackage{\celestia@seriffaceoptions}{\celestia@serifface}
        \RequirePackage{\celestia@serifface}
      }{%
      }
    }
  }

  \IfStrEq{\celestia@monoface}{plex-mono}{%
    \IfFileExists{plex-mono.sty}{%
      \PassOptionsToPackage{scale=0.9}{plex-mono}
      \RequirePackage{plex-mono}
    }{%
      \RequirePackage{courier}
    }
  }{%
    \PassOptionsToPackage{\celestia@monofaceoptions}{\celestia@monoface}
    \RequirePackage{\celestia@monoface}
  }

  \ifcelestia@allserif
    \renewcommand{\familydefault}{\rmdefault}
    \ifcelestia@user@headstyle@set\else
      \def\celestia@headstyle{rmfamily}%
      \celestia@lightfalse
    \fi
  \fi
  \ifx\celestia@mathface\@empty\else
    \IfStrEq{\celestia@mathface}{pagella}{%
      \RequirePackage{mathpazo}
    }{%
      \IfStrEq{\celestia@mathface}{termes}{%
        \RequirePackage{newtxmath}
      }{%
        \IfStrEq{\celestia@mathface}{stix}{%
          \RequirePackage{stix2}
        }{%
          \IfStrEq{\celestia@mathface}{libertinus}{%
            \RequirePackage{libertinust1math}
          }{%
            \IfStrEq{\celestia@mathface}{iwona}{%
              \SetSymbolFont{operators}{normal}{OT1}{iwona}{m}{n}%
              \SetSymbolFont{operators}{bold}{OT1}{iwona}{b}{n}%
              \SetSymbolFont{letters}{normal}{OML}{iwona}{m}{it}%
              \SetSymbolFont{letters}{bold}{OML}{iwona}{b}{it}%
              \SetSymbolFont{symbols}{normal}{OMS}{iwona}{m}{n}%
              \SetSymbolFont{symbols}{bold}{OMS}{iwona}{b}{n}%
              \SetSymbolFont{largesymbols}{normal}{OMX}{iwona}{m}{n}%
              \SetMathAlphabet{\mathrm}{normal}{OT1}{iwona}{m}{n}
              \SetMathAlphabet{\mathrm}{bold}{OT1}{iwona}{b}{n}
              \SetMathAlphabet{\mathbf}{normal}{OT1}{iwona}{b}{n}
              \SetMathAlphabet{\mathbf}{bold}{OT1}{iwona}{eb}{n}
              \SetMathAlphabet{\mathit}{normal}{OT1}{iwona}{m}{it}
              \SetMathAlphabet{\mathit}{bold}{OT1}{iwona}{b}{it}
              \SetMathAlphabet{\mathsf}{normal}{OT1}{iwona}{m}{n}
              \SetMathAlphabet{\mathsf}{bold}{OT1}{iwona}{b}{n}
            }{%
              \IfStrEq{\celestia@mathface}{kurier}{%
                \SetSymbolFont{operators}{normal}{OT1}{kurier}{m}{n}%
                \SetSymbolFont{operators}{bold}{OT1}{kurier}{b}{n}%
                \SetSymbolFont{letters}{normal}{OML}{kurier}{m}{it}%
                \SetSymbolFont{letters}{bold}{OML}{kurier}{b}{it}%
                \SetSymbolFont{symbols}{normal}{OMS}{kurier}{m}{n}%
                \SetSymbolFont{symbols}{bold}{OMS}{kurier}{b}{n}%
                \SetSymbolFont{largesymbols}{normal}{OMX}{kurier}{m}{n}%
                \SetMathAlphabet{\mathrm}{normal}{OT1}{kurier}{m}{n}
                \SetMathAlphabet{\mathrm}{bold}{OT1}{kurier}{b}{n}
                \SetMathAlphabet{\mathbf}{normal}{OT1}{kurier}{b}{n}
                \SetMathAlphabet{\mathbf}{bold}{OT1}{kurier}{eb}{n}
                \SetMathAlphabet{\mathit}{normal}{OT1}{kurier}{m}{it}
                \SetMathAlphabet{\mathit}{bold}{OT1}{kurier}{b}{it}
                \SetMathAlphabet{\mathsf}{normal}{OT1}{kurier}{m}{n}
                \SetMathAlphabet{\mathsf}{bold}{OT1}{kurier}{b}{n}
              }{%
                \IfStrEq{\celestia@mathface}{mtpro2}{%
                  \RequirePackage[lite,subscriptcorrection,slantedGreek,nofontinfo]{mtpro2}
                  \begingroup\lccode`~=`\{ \lowercase{\endgroup\let~}\textbraceleft
                  \begingroup\lccode`~=`\} \lowercase{\endgroup\let~}\textbraceright
                  \AtBeginDocument{%
                    \let\{\textbraceleft
                    \let\}\textbraceright
                  }
                }{%
                  \RequirePackage{\celestia@mathface}
                }
              }
            }
          }
        }
      }
    }
  \fi
\fi

\ifcelestia@semibold
  \iftutex\else
    \AtBeginDocument{\DeclareFontSeriesDefault[sf]{bf}{sb}}
    \AtBeginDocument{\DeclareFontSeriesDefault[rm]{bf}{sb}}
  \fi
\fi

\ifcelestia@light
  \iftutex\else
    \AtBeginDocument{\DeclareFontSeriesDefault[tt]{md}{l}}
  \fi
\fi

\setbeamersize{text margin left=\celestia@margin, text margin right=\celestia@margin}

\setbeamertemplate{navigation symbols}{}
\useinnertheme[rounded=false,shaded=false,shadow=false,showtitle=false]{tcolorbox}

\newlength{\tcbSkip}
\setlength{\tcbSkip}{\baselineskip}
\addtolength{\tcbSkip}{2pt}

\tcbthemeset{
  arc=1mm,
  toptitle=1pt,
  bottomtitle=1pt,
  top=2pt,
  bottom=2pt,
  before skip=\tcbSkip,
  after skip=\tcbSkip,
}

\setbeamerfont{title}{size=\csname\celestia@titlesize\endcsname, family=\csname\celestia@headstyle\endcsname, series=\csname\celestia@headweight\endcsname, parent=structure}
\setbeamerfont{subject}{size=\normalsize, shape=\scshape}
\setbeamerfont{subtitle}{series=\mdseries, size=\large}
\setbeamerfont{author}{}
\setbeamerfont{institute}{size=\small}
\setbeamerfont{date}{size=\small}

\setbeamerfont{frametitle}{size=\normalsize\csname\celestia@frametitlesize\endcsname, family=\csname\celestia@headstyle\endcsname, series=\csname\celestia@headweight\endcsname, parent=structure}
\setbeamerfont{framesubtitle}{size=\small, series=\mdseries, parent=structure}

\setbeamerfont{section title}{size=\LARGE, family=\csname\celestia@headstyle\endcsname, series=\csname\celestia@headweight\endcsname, parent=structure}
\setbeamerfont{subsection title}{size=\large, series=\mdseries, parent=structure}

\setbeamerfont{section in toc}{size=\normalsize, family=\csname\celestia@headstyle\endcsname, series=\mdseries, parent=structure}
\setbeamerfont{subsection in toc}{size=\small, series=\mdseries, parent=structure}

\setbeamerfont{footline text}{size=\normalsize\csname\celestia@footertextsize\endcsname, parent=structure}
\setbeamercolor{footline text}{fg=black!40}
\colorlet{footlinecolor}{black!25}
\setbeamerfont{block title}{size=\normalsize, series=\csname\celestia@blocktitleweight\endcsname, parent=structure}
\setbeamerfont{caption}{size=\footnotesize}
\setbeamerfont{footnote}{size=\scriptsize}

\setbeamerfont{description item}{series=\bfseries}

\newcommand{\celestiaCircle}{%
  \raisebox{0.1ex}{\scalebox{1.2}{$\bullet$}}%
}
\newcommand{\celestiaSmallCircle}{%
  \raisebox{0.2ex}{\scalebox{1}{$\circ$}}%
}
\newcommand{\celestiaDiamond}{%
  \raisebox{0.2ex}{\scalebox{0.8}{$\diamond$}}%
}

\ifx\celestia@maincolor\@empty\else
  \definecolor{main}{HTML}{\celestia@maincolor}
\fi
\ifx\celestia@accentcolor\@empty\else
  \definecolor{accent}{HTML}{\celestia@accentcolor}
\fi
\ifx\celestia@backgroundcolor\@empty\else
  \definecolor{background}{HTML}{\celestia@backgroundcolor}
\fi
\ifx\celestia@blockcolor\@empty\else
  \definecolor{blockcolor}{HTML}{\celestia@blockcolor}
\fi
\ifx\celestia@examplecolor\@empty\else
  \definecolor{examplecolor}{HTML}{\celestia@examplecolor}
\fi
\ifx\celestia@alertcolor\@empty\else
  \definecolor{alertcolor}{HTML}{\celestia@alertcolor}
\fi

\setbeamercolor{alerted text}{fg=alertcolor}
\setbeamercolor{example text}{fg=examplecolor}
\setbeamercolor{structure}{fg=main}

\setbeamercolor{background canvas}{bg=background}
\setbeamercolor{normal text}{fg=main}
\usebeamercolor[fg]{normal text}

\setbeamercolor{titlelike}{parent=structure}
\setbeamercolor{section title}{fg=emphasis}

\setbeamercolor{subtitle}{fg=main}
\setbeamercolor{subject}{fg=\celestia@decoration}
\setbeamercolor{author}{fg=main}
\setbeamercolor{institute}{fg=main!75!background}
\setbeamercolor{date}{fg=main!60!background}

\setbeamercolor{item}{fg=emphasis}
\setbeamercolor{description}{fg=emphasis}
\setbeamercolor{section in toc}{fg=main}

\ifdefstring{\celestia@emphasis}{main}{%
  \colorlet{emphasis}{main}%
  \colorlet{decoration}{accent!80!main}%
}{%
  \colorlet{emphasis}{accent}%
  \colorlet{decoration}{main!60!background}%
}

\ifcelestia@user@decoration@set
  \ifdefstring{\celestia@decoration}{main}{%
    \colorlet{decoration}{main}%
  }{%
    \colorlet{decoration}{accent}%
  }
\fi

\ifcelestia@unicolor
  \colorlet{accent}{emphasis}
  \colorlet{blockcolor}{emphasis}
  \colorlet{examplecolor}{emphasis}
  \colorlet{decoration}{emphasis}
  \setbeamercolor{normal text}{fg=emphasis}
\fi

\setbeamercolor{title}{fg=emphasis}
\setbeamercolor{subsection title}{fg=main!80!background}

\AtEndPreamble{%
  \AtBeginDocument{%
    \ifx\celestia@codebackgroundcolor\@empty
      \colorlet{codebackground}{main!8!background}
    \else
      \definecolor{codebackground}{HTML}{\celestia@codebackgroundcolor}
    \fi

    \colorlet{codeKeyword}{blockcolor}
    \colorlet{codeComment}{blockcolor!60!background}
    \colorlet{codeString}{examplecolor}
    \colorlet{codeIdentifier}{main}

    \ifcelestia@nocodeframe
      \def\celestia@lst@colframe{none}
    \else
      \def\celestia@lst@colframe{accent}
    \fi
  }%
}

\setbeamercolor{footnote}{fg=main}
\setbeamercolor{footnote mark}{fg=main}

\setbeamercolor{button}{bg=main,fg=background}
\setbeamercolor{button border}{fg=main}

\setbeamertemplate{itemize item}{\celestiaCircle}
\setbeamertemplate{itemize subitem}{\celestiaSmallCircle}
\setbeamertemplate{itemize subsubitem}{\celestiaDiamond}

\setbeamercolor{itemize item}{fg=\celestia@decoration}
\setbeamercolor{itemize subitem}{fg=\celestia@decoration}
\setbeamercolor{itemize subsubitem}{fg=\celestia@decoration}

\setbeamertemplate{enumerate item}{%
    \begin{tikzpicture}[baseline=(char.base)]
        \node[circle, fill=\celestia@decoration, inner sep=1pt, minimum size=1em] (char)
        {\usebeamerfont*{enumerate item}\fontsize{8pt}{8pt}\selectfont\textcolor{background}{\bfseries\insertenumlabel}};
    \end{tikzpicture}%
}

\setbeamertemplate{enumerate subitem}{%
    \begin{tikzpicture}[baseline=(char.base)]
        \node[rectangle, draw=\celestia@decoration, fill=background, line width=0.7pt, rounded corners=1pt, inner sep=1pt, minimum size=0.9em] (char)
        {\usebeamerfont*{enumerate subitem}\fontsize{7pt}{7pt}\selectfont\textcolor{decoration}{\bfseries\alph{enumii}}};
    \end{tikzpicture}%
}

\setbeamertemplate{enumerate subsubitem}{%
    \begin{tikzpicture}[baseline=(char.base)]
        \node[circle, fill=\celestia@decoration!60, inner sep=0.5pt, minimum size=0.8em] (char)
        {\usebeamerfont*{enumerate subsubitem}\fontsize{6pt}{6pt}\selectfont\textcolor{background}{\bfseries \insertsubsubenumlabel}};
    \end{tikzpicture}%
}

\newcounter{quizchoice}
\newenvironment{quiz}{%
  \setcounter{quizchoice}{0}%
  \begin{list}{%
      \stepcounter{quizchoice}%
      {\color{\celestia@decoration}\bfseries\Alph{quizchoice}.}%
    }{%
      \setlength{\leftmargin}{2.5em}%
      \setlength{\itemsep}{2pt}%
      \setlength{\parsep}{0pt}%
      \setlength{\topsep}{0pt}%
    }%
    \newcommand{\correct}[1]{%
      \stepcounter{quizchoice}%
      \item[\alt<2>{\alert<2>{\bfseries\Alph{quizchoice}.}}{\color{\celestia@decoration}\bfseries\Alph{quizchoice}.}] \alert<2>{##1}%
    }%
  }{%
  \end{list}%
}

\newcommand{\celestia@verb}[1]{%
  \lstinline[style=latex,basicstyle=\ttfamily\footnotesize\color{main},keywordstyle=\color{main}\bfseries]|#1|%
}
\newcommand{\cverb}{\celestia@verb}

\hypersetup{colorlinks=true, urlcolor=blockcolor}

\ifcelestia@boldurl
  \def\UrlFont{\bfseries}
\fi

\setbeamertemplate{section in toc}{%
  \leavevmode%
  {\color{\celestia@decoration!80!background}\bfseries\inserttocsectionnumber.}%
  \hspace{0.5em}%
  \hypersetup{linkcolor=main!75!background}%
  {\usebeamerfont{section in toc}\usebeamercolor[fg]{section in toc}\inserttocsection}\par%
}

\setbeamertemplate{subsection in toc}{%
  \leavevmode\leftskip=2.5em%
  {\color{main!40!background}\inserttocsectionnumber.\inserttocsubsectionnumber}%
  \hspace{0.5em}%
  \hypersetup{linkcolor=main!65!background}%
  {\usebeamerfont{subsection in toc}\usebeamercolor[fg]{subsection in toc}\inserttocsubsection}\par%
}

\ifcelestia@compacttoc
  \patchcmd{\beamer@sectionintoc}
  {\vfill}
  {\vskip\itemsep}
  {}
  {}
\fi

\NewDocumentCommand{\twocolumntoc}{ O{} O{} O{} }{%
  \ifcelestia@twocoltoc
    \ifx\relax#1\relax
      \tableofcontents
    \else
      \setlength{\columnsep}{2em}
      \begin{multicols}{2}
        \tableofcontents[sections={#1-\the\numexpr#2-1}]
        \columnbreak
        \tableofcontents[sections={#2-#3}]
      \end{multicols}
    \fi
  \else
    \tableofcontents
  \fi
}

% Frametitles

\newlength{\celestia@ft@left@margin}
\setlength{\celestia@ft@left@margin}{2em}

\defbeamertemplate{frametitle}{clean}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\celestia@ft@left@margin-0.5em,
    sep=1.5em]{frametitle}
    {\usebeamerfont{frametitle}\color{emphasis}\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
    \ifx\insertframesubtitle\@empty\else%
      \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
    \fi%
    \tikz[remember picture, overlay] \coordinate (clean@bottom);
  \end{beamercolorbox}%
  \begin{tikzpicture}[remember picture, overlay]
    \fill[emphasis]
      ([xshift=\celestia@ft@left@margin-0.5em, yshift=-1.075em]current page.north west)
      rectangle
      ([xshift=\celestia@ft@left@margin-0.5em+0.3em, yshift=-0.5em]current page.north west |- clean@bottom);
  \end{tikzpicture}%
  \vskip-1em%
}

\setbeamercolor{elegant frametitle}{bg=emphasis,fg=background}

\defbeamertemplate{frametitle}{elegant}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth, sep=0.75em]{elegant frametitle}
    \usebeamerfont{frametitle}\mdseries\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup%
    \ifx\insertframesubtitle\@empty\else%
      \par{\usebeamerfont{framesubtitle}\insertframesubtitle}%
    \fi%
  \end{beamercolorbox}%
}

\defbeamertemplate{frametitle}{plain}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    sep=1.35em]{frametitle}
    \parbox[t]{0.85\textwidth}{
        {\usebeamerfont{frametitle}\color{emphasis}\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
        \ifx\insertframesubtitle\@empty\else%
            \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
        \fi%
    }
  \end{beamercolorbox}%
  \vskip-1em%
}

\defbeamertemplate{frametitle}{cosmic}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth, sep=1.35em]{frametitle}
    \parbox[t]{0.85\textwidth}{%
      {\usebeamerfont{frametitle}\color{emphasis}%
        \begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
      \fi%

      \tikz[remember picture, overlay] \coordinate (anchorY);
    }
    \begin{tikzpicture}[remember picture, overlay]
      \coordinate (L) at (current page.north west |- anchorY);
      \coordinate (R) at ([xshift=-1em]current page.north east |- anchorY);
      \fill[\celestia@decoration!70!background, rotate=45] ([yshift=1.5pt]R) +(-2pt,-2pt) rectangle +(2pt,2pt);
      \draw[\celestia@decoration!70!background] ([yshift=1pt]L) -- ([yshift=1pt]R);
    \end{tikzpicture}
  \end{beamercolorbox}%
  \vskip-1em%
}

\defbeamertemplate{frametitle}{line}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth, sep=1.35em]{frametitle}
    \parbox[t]{0.85\textwidth}{%
      {\usebeamerfont{frametitle}\color{emphasis}%
        \begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
      \fi%

      \tikz[remember picture, overlay] \coordinate (anchorY);
    }
    \begin{tikzpicture}[remember picture, overlay]
      \coordinate (L) at (current page.north west |- anchorY);
      \coordinate (R) at (current page.north east |- anchorY);
      \draw[\celestia@decoration!70!background] ([yshift=1pt]L) -- ([yshift=1pt]R);
    \end{tikzpicture}
  \end{beamercolorbox}%
  \vskip-1em%
}

\defbeamertemplate{frametitle}{subtle}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    sep=1.35em]{frametitle}
    {\usebeamerfont{frametitle}\color{emphasis}\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}\par%
    \ifx\insertframesubtitle\@empty\else%
      {\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle\par}%
    \fi%
    \vspace{0.15em}
    \tikz{\draw[\celestia@decoration!60!background, line width=0.8pt, line cap=round] (0,0) -- (2cm,0);}
  \end{beamercolorbox}%
  \vskip-1em%
}

\defbeamertemplate{frametitle}{plainrule}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,sep=1.35em]{frametitle}
    {\usebeamerfont{frametitle}\color{emphasis}\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
    \ifx\insertframesubtitle\@empty\else%
      \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
    \fi%
    \par
    \begin{tikzpicture}[remember picture, overlay]
      \fill[\celestia@decoration!60, path fading=east]
        ([xshift=1.35em]current page.west |- 0, 0) rectangle
        (current page.east |- 0, 0.6pt);
    \end{tikzpicture}
  \end{beamercolorbox}%
  \vskip-1em%
}

\defbeamertemplate{frametitle}{leftbar}{%
  \nointerlineskip
  \sbox{\@tempboxa}{%
    \begin{beamercolorbox}[wd=\paperwidth, sep=1.2em, leftskip=1em]{frametitle}
      {\usebeamerfont{frametitle}\color{emphasis}\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
      \fi%
    \end{beamercolorbox}%
  }%
  \begin{tikzpicture}[remember picture, overlay]
    \fill[emphasis]
      (current page.north west) rectangle
      ([xshift=0.4cm, yshift=-\dimexpr\ht\@tempboxa+\dp\@tempboxa\relax]current page.north west);
  \end{tikzpicture}%
  \usebox{\@tempboxa}%
}

\defbeamertemplate{frametitle}{gradient}{%
  \nointerlineskip%
  \sbox{\@tempboxa}{%
    \begin{beamercolorbox}[wd=\paperwidth, sep=0.85em, leftskip=0.15em]{frametitle}
      {\usebeamerfont{frametitle}\color{emphasis}\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70}\insertframesubtitle}%
      \fi%
    \end{beamercolorbox}%
  }%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth, \dimexpr\ht\@tempboxa+\dp\@tempboxa\relax);
    \fill[draw=background, left color=accent!12!background, right color=background]
      (-3em, 0) rectangle (\paperwidth, \dimexpr\ht\@tempboxa+\dp\@tempboxa\relax);
    \node[anchor=south west, inner sep=0pt, outer sep=0pt] at (0,0) {\usebox{\@tempboxa}};
  \end{tikzpicture}%
}

\setbeamertemplate{frametitle}[\celestia@frametitle]
\setbeamertemplate{frametitle continuation}{\usebeamerfont{frametitle}(\insertcontinuationcount)}

% Footline
\setbeamertemplate{footline}{%
  \ifnum \theframenumber=1
  \else
    \leavevmode%
    \setbeamercolor{current author}{fg=main,bg=background}
    \setbeamercolor{current title}{fg=main,bg=background}
    \setbeamercolor{current date}{fg=main,bg=background}
    \setbeamercolor{current page}{fg=main,bg=background}

    \pgfmathsetmacro{\progress}{\inserttotalframenumber > 0 ? \insertframenumber/\inserttotalframenumber : 0}
    \begin{tikzpicture}[remember picture, overlay]
      \coordinate (SW) at (current page.south west);
      \coordinate (SE) at (current page.south east);
    \end{tikzpicture}

    \ifx\celestia@footerstyle\celestia@fs@minimalist
      \begin{tikzpicture}[remember picture, overlay]
        \ifcelestia@progressbar
          \fill[\celestia@decoration!20] (SW) rectangle ([yshift=2pt]SE);
          \fill[\celestia@decoration] (SW) rectangle ([yshift=2pt]$ (SW) + (\progress*\paperwidth, 0) $);
        \fi
        \node[anchor=south east, text=footlinecolor]
        at ([xshift=-1em, yshift=2ex]SE) {
          \scriptsize\insertframenumber};
      \end{tikzpicture}
      \vspace*{3ex}

    \else\ifx\celestia@footerstyle\celestia@fs@prestige
        \begin{tikzpicture}[remember picture, overlay]
          \foreach \x in {0.3, 0.7} {
            \draw[footlinecolor, line width=0.6pt, line cap=round]
              ([xshift=\x*\paperwidth-0.75em, yshift=2.5ex]SW) -- ([xshift=\x*\paperwidth+0.75em, yshift=2.5ex]SW);
          }
        \end{tikzpicture}%
        \hbox{%
          \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=2ex,center]{}
            \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor
          \end{beamercolorbox}%
          \begin{beamercolorbox}[wd=.4\paperwidth,ht=3ex,dp=2ex,center]{}
            \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
            {\begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup}
          \end{beamercolorbox}%
          \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=2ex,center]{}
            \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
            \insertframenumber\,/\,\inserttotalframenumber
          \end{beamercolorbox}%
        }%

      \else\ifx\celestia@footerstyle\celestia@fs@framed
          \begin{tikzpicture}[remember picture, overlay]
            \draw[footlinecolor, line width=0.4pt]
              ([yshift=5.5ex]SW) -- ([yshift=5.5ex]SE);
          \end{tikzpicture}%
          \hbox{%
            \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=2ex,center]{}
              \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor
            \end{beamercolorbox}%
            \begin{beamercolorbox}[wd=.39\paperwidth,ht=3ex,dp=2ex,center]{}
              \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
              {\begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup}
            \end{beamercolorbox}%
            \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=2ex,center]{}
              \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
              \insertframenumber\,/\,\inserttotalframenumber
            \end{beamercolorbox}%
          }%

        \else\ifx\celestia@footerstyle\celestia@fs@ruled
          \begin{tikzpicture}[remember picture, overlay]
            \coordinate (ruled@y) at ([yshift=2.65ex]SW);
            \node[anchor=south, inner sep=0pt] (ruled@author)
              at ([xshift=0.15\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor};
            \node[anchor=south, inner sep=0pt] (ruled@title)
              at ([xshift=0.495\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup};
            \node[anchor=south, inner sep=0pt] (ruled@page)
              at ([xshift=0.845\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \insertframenumber\,/\,\inserttotalframenumber};
            % \draw[footlinecolor, line width=0.4pt]
              % (ruled@y) -- ([xshift=-5pt]ruled@author.west |- ruled@y);
            \draw[footlinecolor, line width=0.4pt]
              ([xshift=5pt]ruled@author.east |- ruled@y) -- ([xshift=-5pt]ruled@title.west |- ruled@y);
            \draw[footlinecolor, line width=0.4pt]
              ([xshift=5pt]ruled@title.east |- ruled@y) -- ([xshift=-5pt]ruled@page.west |- ruled@y);
            % \draw[footlinecolor, line width=0.4pt]
              % ([xshift=5pt]ruled@page.east |- ruled@y) -- ([yshift=2.65ex]SE);
          \end{tikzpicture}%
          \vspace*{4ex}

        \else\ifx\celestia@footerstyle\celestia@fs@boxed
          \begin{tikzpicture}[remember picture, overlay]
            \node[anchor=south, inner xsep=5pt, inner ysep=2pt,
              draw=footlinecolor, line width=0.4pt, rounded corners=4pt] (boxed@author)
              at ([xshift=0.15\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor};
            \node[anchor=south, inner xsep=5pt, inner ysep=2pt,
              draw=footlinecolor, line width=0.4pt, rounded corners=4pt] (boxed@title)
              at ([xshift=0.495\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup};
            \node[anchor=south, inner xsep=5pt, inner ysep=2pt,
              draw=footlinecolor, line width=0.4pt, rounded corners=4pt] (boxed@page)
              at ([xshift=0.845\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \insertframenumber\,/\,\inserttotalframenumber};
          \end{tikzpicture}%
          \vspace*{4ex}

        \else\ifx\celestia@footerstyle\celestia@fs@boxedruled
          \begin{tikzpicture}[remember picture, overlay]
            \coordinate (boxedruled@y) at ([yshift=3.5ex]SW);
            \node[anchor=south, inner xsep=5pt, inner ysep=2pt,
              draw=footlinecolor, line width=0.4pt, rounded corners=4pt] (boxedruled@author)
              at ([xshift=0.15\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor};
            \node[anchor=south, inner xsep=5pt, inner ysep=2pt,
              draw=footlinecolor, line width=0.4pt, rounded corners=4pt] (boxedruled@title)
              at ([xshift=0.495\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup};
            \node[anchor=south, inner xsep=5pt, inner ysep=2pt,
              draw=footlinecolor, line width=0.4pt, rounded corners=4pt] (boxedruled@page)
              at ([xshift=0.845\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \insertframenumber\,/\,\inserttotalframenumber};
            \draw[footlinecolor, line width=0.4pt]
              (boxedruled@y) -- (boxedruled@author.west |- boxedruled@y);
            \draw[footlinecolor, line width=0.4pt]
              (boxedruled@author.east |- boxedruled@y) -- (boxedruled@title.west |- boxedruled@y);
            \draw[footlinecolor, line width=0.4pt]
              (boxedruled@title.east |- boxedruled@y) -- (boxedruled@page.west |- boxedruled@y);
            \draw[footlinecolor, line width=0.4pt]
              (boxedruled@page.east |- boxedruled@y) -- ([yshift=3.5ex]SE);
          \end{tikzpicture}%
          \vspace*{4ex}

        \else\ifx\celestia@footerstyle\celestia@fs@cosmic
          \begin{tikzpicture}[remember picture, overlay]
            \foreach \x in {0.3, 0.69} {
              \fill[footlinecolor]
                ([xshift=\x*\paperwidth, yshift=2.65ex]SW)
                +(-2pt,0) -- +(0,2pt) -- +(2pt,0) -- +(0,-2pt) -- cycle;
            }
          \end{tikzpicture}%
          \hbox{%
            \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=2ex,center]{}
              \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor
            \end{beamercolorbox}%
            \begin{beamercolorbox}[wd=.39\paperwidth,ht=3ex,dp=2ex,center]{}
              \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
              {\begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup}
            \end{beamercolorbox}%
            \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=2ex,center]{}
              \usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
              \insertframenumber\,/\,\inserttotalframenumber
            \end{beamercolorbox}%
          }%

        \else\ifx\celestia@footerstyle\celestia@fs@classic
            \setbeamercolor{current author}{fg=emphasis,bg=background}
            \setbeamercolor{current title}{bg=emphasis,fg=background}
            \setbeamercolor{current date}{fg=emphasis,bg=background}
            \setbeamercolor{current page}{bg=emphasis,fg=background}
            \hbox{%
              \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current author}%
                \usebeamerfont{footline text}\tiny\insertshortauthor%
              \end{beamercolorbox}%
              \begin{beamercolorbox}[wd=.4\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current title}%
                \usebeamerfont{footline text}{\hypersetup{linkcolor=.}\tiny\insertshorttitle}%
              \end{beamercolorbox}%
              \begin{beamercolorbox}[wd=.2\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current date}%
                \usebeamerfont{footline text}\tiny\insertshortdate%
              \end{beamercolorbox}%
              \begin{beamercolorbox}[wd=.1\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current page}%
                \usebeamerfont{footline text}\tiny\insertframenumber/\inserttotalframenumber%
              \end{beamercolorbox}%
            }%

          \else\ifx\celestia@footerstyle\celestia@fs@fullbar
              \setbeamercolor{current author}{bg=emphasis,fg=background}
              \setbeamercolor{current title}{bg=emphasis,fg=background}
              \setbeamercolor{current date}{bg=emphasis,fg=background}
              \setbeamercolor{current page}{bg=emphasis,fg=background}
              \hbox{%
                \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current author}%
                  \usebeamerfont{footline text}\tiny\insertshortauthor%
                \end{beamercolorbox}%
                \begin{beamercolorbox}[wd=.4\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current title}%
                  \usebeamerfont{footline text}{\hypersetup{linkcolor=.}\tiny\insertshorttitle}%
                \end{beamercolorbox}%
                \begin{beamercolorbox}[wd=.2\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current date}%
                  \usebeamerfont{footline text}\tiny\insertshortdate%
                \end{beamercolorbox}%
                \begin{beamercolorbox}[wd=.1\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current page}%
                  \usebeamerfont{footline text}\tiny\insertframenumber/\inserttotalframenumber%
                \end{beamercolorbox}%
              }%
              \begin{tikzpicture}[remember picture, overlay]
                \foreach \x in {0.3, 0.7, 0.9} {
                  \fill[background] ([xshift=\x*\paperwidth, yshift=2.1ex]SW) circle (0.8pt);
                }
              \end{tikzpicture}%

            \else\ifx\celestia@footerstyle\celestia@fs@badge
                \begin{tikzpicture}[remember picture, overlay]
                  \node[anchor=south east, fill=emphasis, text=background, font=\bfseries,
                  inner xsep=6pt, inner ysep=3pt, rounded corners=2pt]
                  at ([xshift=-1.5em, yshift=1.35em]SE)
                  {\insertframenumber\thinspace/\thinspace\inserttotalframenumber};
                  \node[anchor=south west, text=footlinecolor]
                  at ([xshift=1.5em, yshift=1.35em]SW)
                  {\insertshortauthor\quad\textbar\quad{\begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup}};
                \end{tikzpicture}
                \vspace*{4ex}

              \else\ifx\celestia@footerstyle\celestia@fs@info
                  \begin{tikzpicture}[remember picture, overlay]
                    \ifcelestia@progressbar
                      \fill[\celestia@decoration!20] (SW) rectangle ([yshift=2pt]SE);
                      \fill[\celestia@decoration] (SW) rectangle ([yshift=2pt]$ (SW) + (\progress*\paperwidth, 0) $);
                    \fi
                    \node[anchor=south west, text=footlinecolor]
                    at ([xshift=2em, yshift=1.2ex]SW) {
                      \insertshortauthor \quad \textcolor{footlinecolor}{|} \quad \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup
                    };
                    \node[anchor=south east, text=footlinecolor]
                    at ([xshift=-2em, yshift=1.2ex]SE) {
                      \insertframenumber{} \tiny{/} \inserttotalframenumber
                    };
                  \end{tikzpicture}
                  \vspace*{4.5ex}
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
    \fi
    \fi
    \fi
    \fi

    \ifcelestia@progressbar
      \ifx\celestia@footerstyle\celestia@fs@info\else
        \ifx\celestia@footerstyle\celestia@fs@minimalist\else
          \begin{tikzpicture}[remember picture, overlay]
            \fill[\celestia@decoration!15] (SW) rectangle ([yshift=1.5pt]SE);
            \fill[\celestia@decoration] (SW) rectangle ([yshift=1.5pt]$ (SW) + (\progress*\paperwidth, 0) $);
          \end{tikzpicture}
        \fi
      \fi
    \fi
  \fi
}

\defbeamertemplate{footline}{plain with nav}{%
  \ifcelestia@shownavigation%
    \def\celestia@fs@fraction{fraction}\ifx\celestia@footerstyle\celestia@fs@fraction
      \leavevmode%
      \hbox{%
        \hbox to \paperwidth{%
          \hfill%
          \raise1mm\hbox{%
            \usebeamerfont{footline text}%
            \insertslidenavigationsymbol%
            \insertframenavigationsymbol%
            \insertsubsectionnavigationsymbol%
            \insertsectionnavigationsymbol%
            \insertdocnavigationsymbol%
            \insertbackfindforwardnavigationsymbol%
            \hspace{1em}%
          }%
        }%
      }%
    \fi
  \fi
}

\define@key{beamerframe}{standout}[true]{%
  \celestia@standouttrue
  \begingroup
  \setkeys{beamerframe}{c}%
  \setkeys{beamerframe}{noframenumbering}%
  \setbeamercolor{background canvas}{bg=main}%
  \setbeamercolor{normal text}{fg=background}%
  \setbeamercolor{structure}{fg=background}%
  \colorlet{emphasis}{background}%
  \colorlet{decoration}{background}%
  \usebeamercolor[fg]{normal text}%
  \setbeamertemplate{frametitle}{}
  \setbeamertemplate{framesubtitle}{}
  \setbeamertemplate{footline}{}%
  \hypersetup{urlcolor=.}%
  \centering
  \usebeamerfont{frametitle}\huge
}

\pretocmd{\beamer@reseteecodes}{%
  \ifcelestia@standout
    \endgroup\celestia@standoutfalse
  \fi
}{}{}

% --- Title Page ---
\def\celestia@subject{}
\renewcommand{\subject}[1]{%
  \def\celestia@subject{#1}%
  \hypersetup{pdfsubject={#1}}%
}
\newcommand{\insertsubject}{\celestia@subject}

\newdimen\celestia@leftskip
\newdimen\celestia@rightskip

\newlength{\celestia@title@skip}
\setlength{\celestia@title@skip}{1em}

\setbeamertemplate{title page}{%
  \vfill
  \begingroup
  \leftskip=\dimexpr\celestia@margin-1em\relax
  \rightskip=\dimexpr\celestia@margin-1em\relax

  \ifx\celestia@titlebackground\@empty\else
    \begin{tikzpicture}[remember picture, overlay]
      \node[opacity=0.15] at (current page.center) {\includegraphics[width=\paperwidth,height=\paperheight]{\celestia@titlebackground}};
    \end{tikzpicture}
  \fi

  \def\celestia@ta@center{center}
  \def\celestia@ta@right{right}

  \ifx\celestia@titlealign\celestia@ta@center
    \centering
    \leftskip=0pt plus 1fil
    \rightskip=0pt plus 1fil
  \else\ifx\celestia@titlealign\celestia@ta@right
      \raggedleft
      \leftskip=0pt plus 1fil
    \else
      \rightskip=0pt plus 1fil
    \fi\fi

  \ifx\celestia@subject\@empty\else
    {\usebeamercolor[fg]{subject}\usebeamerfont{subject}\celestia@subject\par}
    \vspace{\dimexpr1.5\celestia@title@skip\relax}
  \fi

  \begin{minipage}{0.75\textwidth}
    \ifx\celestia@titlealign\celestia@ta@center\centering\fi
    \ifx\celestia@titlealign\celestia@ta@right\raggedleft\fi

    {\usebeamercolor[fg]{title}\usebeamerfont{title}\selectfont\inserttitle\par}

    \ifx\insertsubtitle\@empty\else
      \vspace{\celestia@title@skip}
      {\usebeamercolor[fg]{subtitle}\usebeamerfont{subtitle}\insertsubtitle\par}
    \fi
  \end{minipage}

  \par\vspace{\dimexpr2\celestia@title@skip\relax}
  \tikz{\draw[\celestia@decoration, line width=0.8pt, line cap=round] (0,0) -- (3em,0);}
  \par\vspace{\dimexpr2\celestia@title@skip\relax}

  {\usebeamercolor[fg]{author}\usebeamerfont{author}\insertauthor\par}
  \vspace{\dimexpr0.5\celestia@title@skip\relax}
  {\usebeamercolor[fg]{institute}\usebeamerfont{institute}\insertinstitute\par}
  \vspace{\dimexpr0.8\celestia@title@skip\relax}
  {\usebeamercolor[fg]{date}\usebeamerfont{date}\insertdate\par}

  \endgroup
  \vfill
}

% Section Page Template
\setbeamertemplate{section page}{%
  \vfill
  \begin{tikzpicture}[remember picture, overlay]
    \fill[decoration, opacity=0.03]
      (current page.south west) rectangle (current page.north east);
  \end{tikzpicture}%
  \begin{center}
    \parbox{.9\textwidth}{%
      \centering
      \ifcelestia@sectionnumber
        \begin{tikzpicture}
          \node[circle, draw=decoration!70!background, line width=1.2pt, text=main, font=\Large\bfseries, minimum size=3em] at (0,0) {\thesection};
        \end{tikzpicture}
        \vskip1.5em
      \fi
      \begingroup
      \hypersetup{hidelinks}
      \usebeamerfont{section title}\LARGE\usebeamercolor[fg]{section title}\insertsectionhead\par
      \endgroup
      \vskip1em
      \begin{tikzpicture}
        \draw[\celestia@decoration!70!background, line width=1pt, line cap=round, path fading=east] (-0.125\textwidth,0) -- (0.125\textwidth,0);
      \end{tikzpicture}
    }%
  \end{center}
  \vfill
}

\ifcelestia@sectionpage
  \AtBeginSection{%
    \begin{frame}[plain,noframenumbering]
      \sectionpage
    \end{frame}
  }
\fi

\newif\ifcelestia@usenativeblocks
\IfSubStr{\celestia@block}{native}{\celestia@usenativeblockstrue}{\celestia@usenativeblocksfalse}

\def\celestia@valid@blocks{,native,native-shadow,native-default,fullbar,bar,sober,soft,shaded,noback,plain,}
\expandafter\IfSubStr\expandafter{\celestia@valid@blocks}{,\celestia@block,}{}{%
  \PackageWarning{celestia}{Unknown block style: \celestia@block}%
}

%% Theorem Settings

\ifdefstring{\celestia@block}{native}{
  \setbeamercolor{block title}{bg=blockcolor!85!background, fg=background}
  \setbeamercolor{block body}{bg=blockcolor!8!background, fg=main}
  \setbeamercolor{block title example}{bg=examplecolor!85!background, fg=background}
  \setbeamercolor{block body example}{bg=examplecolor!8!background, fg=main}
  \setbeamercolor{block title alerted}{bg=alertcolor!85!background, fg=background}
  \setbeamercolor{block body alerted}{bg=alertcolor!8!background, fg=main}
  \setbeamerfont{block title}{size=\normalsize, series=\bfseries}
  \setbeamerfont{block title example}{size=\normalsize, series=\bfseries}
  \setbeamerfont{block title alerted}{size=\normalsize, series=\bfseries}
}{}

\ifdefstring{\celestia@block}{native-shadow}{
  \setbeamertemplate{blocks}[rounded][shadow=true]
  \setbeamercolor{block title}{bg=blockcolor!85!background, fg=background}
  \setbeamercolor{block body}{bg=blockcolor!8!background, fg=main}
  \setbeamercolor{block title example}{bg=examplecolor!85!background, fg=background}
  \setbeamercolor{block body example}{bg=examplecolor!8!background, fg=main}
  \setbeamercolor{block title alerted}{bg=alertcolor!85!background, fg=background}
  \setbeamercolor{block body alerted}{bg=alertcolor!8!background, fg=main}
  \setbeamerfont{block title}{size=\normalsize, series=\bfseries}
  \setbeamerfont{block title example}{size=\normalsize, series=\bfseries}
  \setbeamerfont{block title alerted}{size=\normalsize, series=\bfseries}
}{}

\ifdefstring{\celestia@block}{native-default}{
  \setbeamertemplate{blocks}[default]
  \setbeamercolor{block title}{bg=blockcolor!85!background, fg=background}
  \setbeamercolor{block body}{bg=blockcolor!8!background, fg=main}
  \setbeamercolor{block title example}{bg=examplecolor!85!background, fg=background}
  \setbeamercolor{block body example}{bg=examplecolor!8!background, fg=main}
  \setbeamercolor{block title alerted}{bg=alertcolor!85!background, fg=background}
  \setbeamercolor{block body alerted}{bg=alertcolor!8!background, fg=main}
  \setbeamerfont{block title}{size=\normalsize, series=\bfseries}
  \setbeamerfont{block title example}{size=\normalsize, series=\bfseries}
  \setbeamerfont{block title alerted}{size=\normalsize, series=\bfseries}
}{}

\ifcelestia@usenativeblocks
  \newenvironment{property}[1][]{%
    \begin{block}{\celestia@name@property\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{block}%
  }

  \newenvironment{properties}[1][]{%
    \begin{block}{\celestia@name@properties\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{block}%
  }

  \newenvironment{proposition}[1][]{%
    \begin{block}{\celestia@name@proposition\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{block}%
  }

  \newenvironment{method}[1][]{%
    \begin{alertblock}{\celestia@name@method\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }

  \newenvironment{remark}[1][]{%
    \begin{alertblock}{\celestia@name@remark\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }

  \newenvironment{remarks}[1][]{%
    \begin{alertblock}{\celestia@name@remarks\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }

  \newenvironment{activity}[1][]{%
    \begin{alertblock}{\celestia@name@activity\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }

  \newenvironment{activities}[1][]{%
    \begin{alertblock}{\celestia@name@activities\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }

  \newenvironment{application}[1][]{%
    \begin{alertblock}{\celestia@name@application\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }

  \newenvironment{applications}[1][]{%
    \begin{alertblock}{\celestia@name@applications\ifx\relax#1\relax\else~(#1)\fi}%
    }{%
    \end{alertblock}%
  }
\else
  \tcbset{
    celestia@common/.style={
      enhanced jigsaw,
      boxrule=0pt,
      frame hidden,
      left=6pt, right=6pt, top=4pt, bottom=4pt,
      before skip=1em, after skip=1em,
      no shadow,
      before upper={\color{main}},
    }
  }

\ifdefstring{\celestia@block}{fullbar}{
  \tcbset{
    celestia@blockstyle/.style={
      celestia@common, sharp corners=west,
      colback=blockcolor!5!background,
      colbacktitle=blockcolor!15!background,
      coltitle=blockcolor,
      borderline west={3pt}{0pt}{blockcolor},
      fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#1}, toptitle=2pt, bottomtitle=2pt, separator sign=,
    },
    celestia@exstyle/.style={
      celestia@common, sharp corners=west,
      colback=examplecolor!5!background,
      colbacktitle=examplecolor!15!background,
      coltitle=examplecolor,
      borderline west={3pt}{0pt}{examplecolor},
      fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#1}, toptitle=2pt, bottomtitle=2pt, separator sign=,
    },
    celestia@alertstyle/.style={
      celestia@common, sharp corners=west,
      colback=alertcolor!5!background,
      colbacktitle=alertcolor!15!background,
      coltitle=alertcolor,
      borderline west={3pt}{0pt}{alertcolor},
      fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#1}, toptitle=2pt, bottomtitle=2pt, separator sign=,
    }
  }
}{}

\ifdefstring{\celestia@block}{bar}{
  \tcbset{
    celestia@blockstyle/.style={
      celestia@common, colback=blockcolor!\celestia@baropacity!background,
      borderline west={3pt}{0pt}{blockcolor}, sharp corners=west,
      fonttitle=\csname\celestia@blocktitleweight\endcsname\color{blockcolor},
      title={#1}, attach boxed title to top left, boxed title style={empty, boxsep=2pt},
      coltitle=blockcolor!70!black, separator sign=~~---~,
    },
    celestia@exstyle/.style={
      celestia@common, colback=examplecolor!\celestia@baropacity!background,
      borderline west={3pt}{0pt}{examplecolor}, sharp corners=west,
      fonttitle=\csname\celestia@blocktitleweight\endcsname\color{examplecolor},
      title={#1}, attach boxed title to top left, boxed title style={empty, boxsep=2pt},
      coltitle=examplecolor!70!black, separator sign=~~---~,
    },
    celestia@alertstyle/.style={
      celestia@common, colback=alertcolor!\celestia@baropacity!background,
      borderline west={3pt}{0pt}{alertcolor}, sharp corners=west,
      fonttitle=\csname\celestia@blocktitleweight\endcsname\color{alertcolor},
      title={#1}, attach boxed title to top left, boxed title style={empty, boxsep=2pt},
      coltitle=alertcolor!70!black, separator sign=~~---~,
    }
  }
}{}

\ifdefstring{\celestia@block}{sober}{
  \tcbset{
    celestia@blockstyle/.style={enhanced jigsaw, opacitybacktitle=0, opacityframe=0, sharp corners, colback=blockcolor!\celestia@soberopacity, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{blockcolor}, left=3pt, lefttitle=3pt, top=3pt, bottom=3pt, right=3pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@exstyle/.style={enhanced jigsaw, opacitybacktitle=0, opacityframe=0, sharp corners, colback=examplecolor!\celestia@soberopacity, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{examplecolor}, left=3pt, lefttitle=3pt, top=3pt, bottom=3pt, right=3pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@alertstyle/.style={enhanced jigsaw, opacitybacktitle=0, opacityframe=0, sharp corners, colback=alertcolor!\celestia@soberopacity, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{alertcolor}, left=3pt, lefttitle=3pt, top=3pt, bottom=3pt, right=3pt, title={#1}, separator sign=~~---~, before upper={\color{main}}}
  }
}{}

\ifdefstring{\celestia@block}{soft}{
  \tcbset{
    celestia@blockstyle/.style={colback=blockcolor!\celestia@softopacity, colframe=blockcolor!\celestia@softopacity, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{blockcolor}, left=3pt, bottomtitle=-2pt, toptitle=3pt, top=1pt, bottom=3pt, lefttitle=3pt, right=2pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@exstyle/.style={colback=examplecolor!\celestia@softopacity, colframe=examplecolor!\celestia@softopacity, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{examplecolor}, left=3pt, bottomtitle=-2pt, toptitle=3pt, top=1pt, bottom=3pt, lefttitle=3pt, right=2pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@alertstyle/.style={colback=alertcolor!\celestia@softopacity, colframe=alertcolor!\celestia@softopacity, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{alertcolor}, left=3pt, bottomtitle=-2pt, toptitle=3pt, top=1pt, bottom=3pt, lefttitle=3pt, right=2pt, title={#1}, separator sign=~~---~, before upper={\color{main}}}
  }
}{}

\ifdefstring{\celestia@block}{shaded}{
  \tcbset{
    celestia@blockstyle/.style={colback=blockcolor!15!background, colframe=blockcolor!15!background, boxrule=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{blockcolor}, colbacktitle=blockcolor!\celestia@shadedopacity!background, left=3pt, top=3pt, bottom=3pt, toptitle=2pt, bottomtitle=2pt, lefttitle=3pt, right=3pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@exstyle/.style={colback=examplecolor!15!background, colframe=examplecolor!15!background, boxrule=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{examplecolor}, colbacktitle=examplecolor!\celestia@shadedopacity!background, left=3pt, top=3pt, bottom=3pt, toptitle=2pt, bottomtitle=2pt, lefttitle=3pt, right=3pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@alertstyle/.style={colback=alertcolor!15!background, colframe=alertcolor!15!background, boxrule=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{alertcolor}, colbacktitle=alertcolor!\celestia@shadedopacity!background, left=3pt, top=3pt, bottom=3pt, toptitle=2pt, bottomtitle=2pt, lefttitle=3pt, right=3pt, title={#1}, separator sign=~~---~, before upper={\color{main}}}
  }
}{}

\ifdefstring{\celestia@block}{noback}{
  \tcbset{
    celestia@blockstyle/.style={opacityframe=0, opacityback=0, colback=background, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{blockcolor}, toptitle=5pt, top=5pt, left=0pt, lefttitle=0pt, right=0pt, bottom=0pt, boxrule=0pt, boxsep=0pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@exstyle/.style={opacityframe=0, opacityback=0, colback=background, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{examplecolor}, toptitle=5pt, top=5pt, left=0pt, lefttitle=0pt, right=0pt, bottom=0pt, boxrule=0pt, boxsep=0pt, title={#1}, separator sign=~~---~, before upper={\color{main}}},
    celestia@alertstyle/.style={opacityframe=0, opacityback=0, colback=background, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{alertcolor}, toptitle=5pt, top=5pt, left=0pt, lefttitle=0pt, right=0pt, bottom=0pt, boxrule=0pt, boxsep=0pt, title={#1}, separator sign=~~---~, before upper={\color{main}}}
  }
}{}

\ifdefstring{\celestia@block}{plain}{
  \tcbset{
    celestia@blockstyle/.style={
      enhanced jigsaw, boxrule=0.5pt,
      colback=blockcolor!10!background,
      colframe=blockcolor,
      fonttitle=\csname\celestia@blocktitleweight\endcsname, coltitle=background,
      colbacktitle=blockcolor,
      left=4pt, right=4pt, top=4pt, bottom=4pt,
      title={#1}, separator sign=~~---~,
      before upper={\color{main}}
    },
    celestia@exstyle/.style={
      enhanced jigsaw, boxrule=0.5pt,
      colback=examplecolor!10!background,
      colframe=examplecolor,
      fonttitle=\csname\celestia@blocktitleweight\endcsname, coltitle=background,
      colbacktitle=examplecolor,
      left=4pt, right=4pt, top=4pt, bottom=4pt,
      title={#1}, separator sign=~~---~,
      before upper={\color{main}}
    },
    celestia@alertstyle/.style={
      enhanced jigsaw, boxrule=0.5pt,
      colback=alertcolor!10!background,
      colframe=alertcolor,
      fonttitle=\csname\celestia@blocktitleweight\endcsname, coltitle=background,
      colbacktitle=alertcolor,
      left=4pt, right=4pt, top=4pt, bottom=4pt,
      title={#1}, separator sign=~~---~,
      before upper={\color{main}}
    }
  }
}{}

\setbeamertemplate{block begin}{\begin{tcolorbox}[celestia@blockstyle=\insertblocktitle]}
\setbeamertemplate{block end}{\end{tcolorbox}}

\setbeamertemplate{block alerted begin}{\begin{tcolorbox}[celestia@alertstyle=\insertblocktitle]}
\setbeamertemplate{block alerted end}{\end{tcolorbox}}

\setbeamertemplate{block example begin}{\begin{tcolorbox}[celestia@exstyle=\insertblocktitle]}
\setbeamertemplate{block example end}{\end{tcolorbox}}

\let\theorem\relax
\let\endtheorem\relax
\let\lemma\relax
\let\endlemma\relax
\let\proposition\relax
\let\endproposition\relax
\let\property\relax
\let\endproperty\relax
\let\properties\relax
\let\endproperties\relax
\let\corollary\relax
\let\endcorollary\relax
\let\definition\relax
\let\enddefinition\relax
\let\definitions\relax
\let\enddefinitions\relax
\let\example\relax
\let\endexample\relax
\let\examples\relax
\let\endexamples\relax
\let\remark\relax
\let\endremark\relax
\let\remarks\relax
\let\endremarks\relax
\let\method\relax
\let\endmethod\relax
\let\activity\relax
\let\endactivity\relax
\let\activities\relax
\let\endactivities\relax
\let\application\relax
\let\endapplication\relax
\let\applications\relax
\let\endapplications\relax

\ExplSyntaxOn
\tl_new:N \l__custom_tcb_title_tl
\tl_new:N \l__custom_tcb_label_tl
\tl_new:N \l__custom_tcb_options_tl
\NewDocumentCommand{\celestia@mynewtcbtheorem}{O{}mmmm}{%
  \newtcbtheorem[#1]{#2inner}{#3}{#4}{#5}
  \NewDocumentEnvironment{#2}{O{}}{%
    \keys_set:nn { custom/tcb } { ##1 }
    \tl_if_empty:NTF \l__custom_tcb_options_tl {%
      \use:x {
        \exp_not:N \begin{#2inner}
          {\tl_if_empty:NTF \l__custom_tcb_title_tl
            { }
            { (\exp_not:V \l__custom_tcb_title_tl) }
          }
          {\exp_not:V \l__custom_tcb_label_tl}
        }
      }{%
        \use:x {
          \exp_not:N \begin{#2inner}
            [\exp_not:V \l__custom_tcb_options_tl]
            {\tl_if_empty:NTF \l__custom_tcb_title_tl
              { }
              { (\exp_not:V \l__custom_tcb_title_tl) }
            }
            {\exp_not:V \l__custom_tcb_label_tl}
          }
        }
      }{%
      \end{#2inner}
    }

    \NewDocumentEnvironment{#2*}{O{}}{%
      \keys_set:nn { custom/tcb } { ##1 }
      \tl_if_empty:NTF \l__custom_tcb_options_tl {%
        \use:x {
          \exp_not:N \begin{#2inner*}
            {\tl_if_empty:NTF \l__custom_tcb_title_tl
              { }
              { (\exp_not:V \l__custom_tcb_title_tl) }
            }
            {}
          }
        }{%
          \use:x {
            \exp_not:N \begin{#2inner*}
              [\exp_not:V \l__custom_tcb_options_tl]
              {\tl_if_empty:NTF \l__custom_tcb_title_tl
                { }
                { (\exp_not:V \l__custom_tcb_title_tl) }
              }
              {}
            }
          }
        }{%
        \end{#2inner*}
      }
      \cs_if_exist:cF { c@#5} { \newcounter{#5} }
    }

    \keys_define:nn { custom/tcb } {
      title .tl_set:N = \l__custom_tcb_title_tl,
      label .tl_set:N = \l__custom_tcb_label_tl,
      unknown .code:n = {
        \tl_put_right:Nx \l__custom_tcb_options_tl { \l_keys_key_str = { \exp_not:n {#1} } , }
      }
    }
\ExplSyntaxOff

\celestia@mynewtcbtheorem[auto counter]{theorem}{\celestia@name@theorem}
{celestia@blockstyle}{th}
\celestia@mynewtcbtheorem[auto counter]{lemma}{\celestia@name@lemma}
{celestia@blockstyle}{le}
\celestia@mynewtcbtheorem[auto counter]{proposition}{\celestia@name@proposition}
{celestia@blockstyle}{prop}
\celestia@mynewtcbtheorem[auto counter]{property}{\celestia@name@property}
{celestia@blockstyle}{pr}
\celestia@mynewtcbtheorem[auto counter]{properties}{\celestia@name@properties}
{celestia@blockstyle}{prs}
\celestia@mynewtcbtheorem[auto counter]{corollary}{\celestia@name@corollary}
{celestia@blockstyle}{cor}
\celestia@mynewtcbtheorem[auto counter]{definition}{\celestia@name@definition}
{celestia@exstyle}{def}
\celestia@mynewtcbtheorem[auto counter]{definitions}{\celestia@name@definitions}
{celestia@exstyle}{defs}
\celestia@mynewtcbtheorem[auto counter]{example}{\celestia@name@example}
{celestia@exstyle}{ex}
\celestia@mynewtcbtheorem[auto counter]{examples}{\celestia@name@examples}
{celestia@exstyle}{exs}
\celestia@mynewtcbtheorem[auto counter]{remark}{\celestia@name@remark}
{celestia@alertstyle}{rem}
\celestia@mynewtcbtheorem[auto counter]{remarks}{\celestia@name@remarks}
{celestia@alertstyle}{rems}
\celestia@mynewtcbtheorem[auto counter]{method}{\celestia@name@method}
{celestia@alertstyle}{meth}
\celestia@mynewtcbtheorem[auto counter]{activity}{\celestia@name@activity}
{celestia@alertstyle}{act}
\celestia@mynewtcbtheorem[auto counter]{activities}{\celestia@name@activities}
{celestia@alertstyle}{acts}
\celestia@mynewtcbtheorem[auto counter]{application}{\celestia@name@application}
{celestia@alertstyle}{appl}
\celestia@mynewtcbtheorem[auto counter]{applications}{\celestia@name@applications}
{celestia@alertstyle}{appls}
\fi

\newcommand{\mathterm}[1]{\textcolor{blockcolor}{\mathbf{#1}}}
\newcommand{\mathdef}[1]{\textcolor{examplecolor}{\mathit{#1}}}

\RequirePackage{caption}
\DeclareCaptionFont{celestiaCaption}{\small\color{accent}}
\captionsetup{
  font={celestiaCaption},
  labelfont={bf},
  labelsep=colon,
  justification=raggedright,
  singlelinecheck=false
}
\captionsetup[lstlisting]{
  font={celestiaCaption},
  labelfont={bf},
  justification=raggedright,
  singlelinecheck=false
}
\captionsetup[listing]{
  font={celestiaCaption},
  labelfont={bf},
  justification=raggedright,
  singlelinecheck=false
}

% Code Settings
\def\celestia@cs@frame{frame}
\def\celestia@cs@macos{macos}
\def\celestia@cs@box{box}
\def\celestia@cs@bar{bar}

\ifx\celestia@codestyle\celestia@cs@frame
\tcbset{
  celestia@codestyle/.style={
    enhanced jigsaw,
    colback=codebackground,
    colframe=accent!60,
    boxrule=0.6pt,
    top=3pt, bottom=3pt,
    left=6pt, right=6pt,
    arc=2pt,
    no shadow,
  }
}
\else
  \ifx\celestia@codestyle\celestia@cs@macos
    \tcbset{
      celestia@codestyle/.style={
        enhanced jigsaw,
        colback=codebackground,
        colframe=main!20,
        boxrule=0.6pt,
        arc=5pt,
        top=12pt, bottom=5pt, left=8pt, right=8pt,
        no shadow,
        overlay={
          \fill[red!80!black]    ([xshift=8pt, yshift=-7pt]frame.north west) circle (2.5pt);
          \fill[orange!80!black] ([xshift=17pt, yshift=-7pt]frame.north west) circle (2.5pt);
          \fill[green!70!black]  ([xshift=26pt, yshift=-7pt]frame.north west) circle (2.5pt);
        }
      }
    }
  \else
    \ifx\celestia@codestyle\celestia@cs@box
      \tcbset{
        celestia@codestyle/.style={
          enhanced jigsaw,
          colback=codebackground,
          colframe=main!15,
          boxrule=0.6pt,
          arc=3pt,
          left=5pt, right=5pt,
          top=6pt,
          bottom=4pt,
          sharp corners=north,
          no shadow,
          overlay={
            \fill[accent]
            ([xshift=0.2pt, yshift=-0.2pt]frame.north west)
            -- ([xshift=-0.2pt, yshift=-0.2pt]frame.north east)
            -- ([xshift=-0.2pt, yshift=-2.2pt]frame.north east)
            -- ([xshift=0.2pt, yshift=-2.2pt]frame.north west) -- cycle;
          }
        }
      }
    \else
      \ifx\celestia@codestyle\celestia@cs@bar
        \tcbset{
          celestia@codestyle/.style={
            enhanced jigsaw,
            boxrule=0pt,
            frame hidden,
            left=6pt, right=6pt, top=2pt, bottom=2pt,
            before skip=1em, after skip=1em,
            colback=accent!10!background,
            borderline west={2.5pt}{0pt}{accent},
            colframe=background,
            sharp corners=west,
          }
        }
      \fi
    \fi
  \fi
\fi

\newlength{\celestia@code@skip}
\setlength{\celestia@code@skip}{1em}

\ifdefstring{\celestia@codehandler}{minted}{%
  \RequirePackage{minted}
  \setminted{bgcolor=codebackground, fontsize=\footnotesize, breaklines=true, style=friendly}
  \ifdefstring{\celestia@language}{french}{%
    \AtBeginDocument{%
      \renewcommand{\listingscaption}{Programme}%
      \@ifpackageloaded{babel}{\addto\captionsfrench{\renewcommand{\listingscaption}{Programme}}}{}%
    }%
  }{}
  \ifcelestia@codebox
    \newtcolorbox{lstbox}[1][]{celestia@codestyle, #1}
    \BeforeBeginEnvironment{minted}{\begin{lstbox}}
      \AfterEndEnvironment{minted}{\end{lstbox}}
  \else
    \BeforeBeginEnvironment{minted}{\par\vspace{\celestia@code@skip}}
    \AfterEndEnvironment{minted}{\par\vspace{\celestia@code@skip}}
  \fi
}{%
  \RequirePackage{listings}
  \AtEndPreamble{
    \lstset{
      basicstyle=\ttfamily\footnotesize\color{main},
      keywordstyle=\color{accent}\bfseries,
      emphstyle=\color{accent}\bfseries,
      commentstyle=\color{main!50!background}\itshape,
      stringstyle=\color{examplecolor},
      showstringspaces=false,
      showspaces=false,
      frame=none,
      breaklines=true,
      aboveskip=\ifcelestia@codebox 0pt \else \celestia@code@skip \fi,
      belowskip=\ifcelestia@codebox 0pt \else \celestia@code@skip \fi,
      literate={%
        á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
        {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
        {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
        {À}{{\`A}}1 {È}{{\`E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
        {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
        {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
        {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
        {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
        {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
        {ẞ}{{\SS}}1 {ç}{{\c{c}}}1 {Ç}{{\c{C}}}1 {ø}{{\o}}1 {Ø}{{\O}}1
        {å}{{\aa}}1 {Å}{{\AA}}1 {ã}{{\~a}}1 {õ}{{\~o}}1 {Ã}{{\~A}}1
        {Õ}{{\~O}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1 {¡}{{!`}}1
        {°}{{\textdegree}}1 {º}{{\textordmasculine}}1 {ª}{{\textordfeminine}}1
        {€}{{\euro}}1 {£}{{\pounds}}1 {©}{{\copyright}}1 {®}{{\textregistered}}1
        {«}{{\guillemotleft}}1 {»}{{\guillemotright}}1 {Ð}{{\DH}}1 {ð}{{\dh}}1
        {Ý}{{\'Y}}1 {ý}{{\'y}}1 {Þ}{{\TH}}1 {þ}{{\th}}1 {Ă}{{\u{A}}}1
        {ă}{{\u{a}}}1 {Ą}{{\k{A}}}1 {ą}{{\k{a}}}1 {Ć}{{\'C}}1 {ć}{{\'c}}1
        {Č}{{\v{C}}}1 {č}{{\v{c}}}1 {Ď}{{\v{D}}}1 {ď}{{\v{d}}}1 {Đ}{{\DJ}}1
        {đ}{{\dj}}1 {Ė}{{\.{E}}}1 {ė}{{\.{e}}}1 {Ę}{{\k{E}}}1 {ę}{{\k{e}}}1
        {Ě}{{\v{E}}}1 {ě}{{\v{e}}}1 {Ğ}{{\u{G}}}1 {ğ}{{\u{g}}}1 {Ĩ}{{\~I}}1
        {ĩ}{{\~\i}}1 {Į}{{\k{I}}}1 {į}{{\k{i}}}1 {İ}{{\.{I}}}1 {ı}{{\i}}1
        {Ĺ}{{\'L}}1 {ĺ}{{\'l}}1 {Ľ}{{\v{L}}}1 {ľ}{{\v{l}}}1 {Ł}{{\L{}}}1
        {ł}{{\l{}}}1 {Ń}{{\'N}}1 {ń}{{\'n}}1 {Ň}{{\v{N}}}1 {ň}{{\v{n}}}1
        {Ő}{{\H{O}}}1 {ő}{{\H{o}}}1 {Ŕ}{{\'{R}}}1 {ŕ}{{\'{r}}}1 {Ř}{{\v{R}}}1
        {ř}{{\v{r}}}1 {Ś}{{\'S}}1 {ś}{{\'s}}1 {Ş}{{\c{S}}}1 {ş}{{\c{s}}}1
        {Š}{{\v{S}}}1 {š}{{\v{s}}}1 {Ť}{{\v{T}}}1 {ť}{{\v{t}}}1 {Ũ}{{\~U}}1
      }

    \lstdefinestyle{python}{%
      language=Python,
      morekeywords={%
        @property,@classmethod,@staticmethod,
      },
      emph={%
        range,int,str,list,dict,set,bool,float,
        tuple,super,type,print,len,sum,min,max,
        enumerate,zip,map,filter,any,all,as,assert,
        nonlocal,with,yield,self,True,False,None,
        lambda,raise,await,async,
      },
      morestring=[b]""",
    }

    \ifdefstring{\celestia@language}{french}{%
      \AtBeginDocument{%
        \renewcommand{\lstlistingname}{Programme}%
        \@ifpackageloaded{babel}{\addto\captionsfrench{\renewcommand{\lstlistingname}{Programme}}}{}%
      }%
    }{}
  }

  \ifcelestia@codebox
    \newtcolorbox{lstbox}[1][]{celestia@codestyle, #1}
    \BeforeBeginEnvironment{lstlisting}{\begin{lstbox}}
      \AfterEndEnvironment{lstlisting}{\end{lstbox}}
  \fi
}

% Bibliography
\AtBeginDocument{%
  \IfPackageLoadedTF{biblatex}{%
    \defbibheading{bibliography}{%
      \ifdefstring{\celestia@language}{french}{%
        \frametitle{Références}%
      }{%
        \frametitle{References}%
      }%
    }%
  }{%
    \IfPackageLoadedTF{natbib}{%
      \setbeamertemplate{bibliography item}{\insertbiblabel}%
      \setbeamercolor{bibliography entry author}{fg=main}%
      \setbeamercolor{bibliography entry title}{fg=main}%
      \setbeamercolor{bibliography entry location}{fg=main}%
      \setbeamercolor{bibliography entry note}{fg=main}%
    }{}%
  }%
}

\mode<all>
