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

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{beamerthemeCelestia}[2026/10/05 v2.3.0]

\RequirePackage{iftex}
\RequirePackage{etoolbox}
\RequirePackage{kvoptions}
\RequirePackage{kvsetkeys}
\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}

\def\celestia@palette{nordic}

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

\DeclareBoolOption{allserif}
\DeclareBoolOption[true]{semibold}
\DeclareBoolOption[true]{light}
\newif\ifcelestia@user@light@set
\define@key{celestia}{light}[true]{%
  \IfSubStr{,true,false,}{,#1,}{%
    \celestia@user@light@settrue
    \csname celestia@light#1\endcsname
  }{\PackageWarning{celestia}{Unknown value for light: #1}}%
}
\newif\ifcelestia@user@semibold@set
\define@key{celestia}{semibold}[true]{%
  \IfSubStr{,true,false,}{,#1,}{%
    \celestia@user@semibold@settrue
    \csname celestia@semibold#1\endcsname
  }{\PackageWarning{celestia}{Unknown value for semibold: #1}}%
}
\DeclareBoolOption{unicolor}
\newif\ifcelestia@standout
\DeclareBoolOption{compacttoc}
\DeclareBoolOption{twocoltoc}
\DeclareBoolOption[true]{codebox}
\DeclareBoolOption{nocodeframe}
\DeclareBoolOption[true]{codelabel}
\DeclareStringOption[auto]{codenumbers}[true]
\DeclareBoolOption{shownavigation}
\DeclareBoolOption{boldurl}
\DeclareBoolOption[true]{sectionpage}
\DeclareBoolOption{subsectionpage}
\DeclareStringOption[false]{sectiontoc}[list]
\DeclareBoolOption[true]{motif}
\DeclareBoolOption[false]{sectionnumber}
\DeclareBoolOption[false]{progressbar}

\DeclareStringOption[roles]{block}
\DeclareStringOption[auto]{standardblock}
\DeclareStringOption[auto]{theoremblock}
\DeclareStringOption[auto]{definitionblock}
\DeclareStringOption[auto]{proofblock}
\DeclareStringOption[auto]{exampleblock}
\DeclareStringOption[auto]{nativeexampleblock}
\DeclareStringOption[auto]{remarkblock}
\DeclareStringOption[auto]{methodblock}
\DeclareStringOption[auto]{activityblock}
\DeclareStringOption[auto]{exerciseblock}
\DeclareStringOption[auto]{alertblock}
\DeclareStringOption[auto]{summaryblock}
\DeclareStringOption[auto]{blockfill}[true]
\DeclareStringOption[auto]{blockcorners}
\DeclareStringOption[info]{footerstyle}
\DeclareStringOption[soft]{codestyle}
\DeclareStringOption[left]{titlealign}
\DeclareStringOption{titlebackground}
\DeclareStringOption[auto]{shadedblockopacity}
\DeclareStringOption[auto]{soberblockopacity}
\DeclareStringOption[auto]{softblockopacity}
\DeclareStringOption[auto]{barblockopacity}
\DeclareStringOption[listings]{codehandler}

\DeclareStringOption[sffamily]{headstyle}
\DeclareStringOption[normal]{headshape}
\DeclareStringOption[bfseries]{headweight}
\DeclareStringOption[mdseries]{titleweight}
\DeclareStringOption[bfseries]{blocktitleweight}
\DeclareStringOption[Huge]{titlesize}
\DeclareStringOption[normalsize]{frametitlesize}
\DeclareStringOption[huge]{sectiontitlesize}
\DeclareStringOption[large]{subtitlesize}
\DeclareStringOption[tiny]{footertextsize}

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

\DeclareStringOption[2em]{margin}
\DeclareStringOption[ruled]{frametitle}
\DeclareStringOption{frametitlepadding}
\DeclareStringOption{frametitlebottomskip}

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

\DeclareStringOption[english]{language}
\newif\ifcelestia@user@language@set
\define@key{celestia}{language}{%
  \celestia@user@language@settrue
  \def\celestia@language{#1}%
}
\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}%
  \let\celestia@tints\@empty
  \let\celestia@accentpair\@empty
  \celestia@clear@tones
}
\newcommand{\celestia@set@tints}[5]{%
  \def\celestia@tints{{#1}{#2}{#3}{#4}{#5}}%
}
\let\celestia@accentpair\@empty
\newcommand{\celestia@set@accent}[2]{%
  \def\celestia@accentpair{{#1}{#2}}%
}
\newcommand{\celestia@set@roles}[2]{%
  \def\celestia@remarkcolor{#1}%
  \def\celestia@methodcolor{#2}%
}
\newcommand{\celestia@set@tones}[3]{%
  \@namedef{celestia@tones@#1}{{#2}{#3}}%
}
\newcommand{\celestia@clear@alltones}{%
  \@for\celestia@tonerole:=blockcolor,examplecolor,alertcolor,remarkcolor,methodcolor\do{%
    \expandafter\let\csname celestia@tones@\celestia@tonerole\endcsname\@empty}%
}
\newcommand{\celestia@clear@tones}{%
  \let\celestia@remarkcolor\@empty
  \let\celestia@methodcolor\@empty
  \celestia@clear@alltones
}
\newcommand{\celestia@override}[1]{%
  \IfSubStr{,main,accent,background,block,example,alert,}{,#1,}{\let\celestia@tints\@empty}{}%
  \IfSubStr{,main,accent,background,}{,#1,}{\let\celestia@accentpair\@empty}{}%
  \ifstrequal{#1}{background}{\celestia@clear@alltones}{%
    \ifcsname celestia@tones@#1color\endcsname
      \expandafter\let\csname celestia@tones@#1color\endcsname\@empty
    \fi}%
}

\newcommand{\celestia@scheme@celestia}{%
  \def\celestia@palette{nordic}%
  \def\celestia@frametitle{ruled}%
  \def\celestia@footerstyle{info}%
  \def\celestia@block{roles}%
}

\newcommand{\celestia@scheme@stage}{%
  \def\celestia@palette{midnight}%
  \def\celestia@frametitle{ruled}%
  \def\celestia@footerstyle{minimalist}%
  \def\celestia@block{ribbon}%
  \def\celestia@emphasis{accent}%
  \def\celestia@frametitlesize{Large}%
}

\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}%
  \def\celestia@headstyle{rmfamily}%
  \celestia@user@headstyle@settrue
}

\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}%
}

\define@key{celestia}{style}{%
  \def\celestia@style{#1}%
}

%% Palettes
\newcommand{\celestia@palette@burgundy}{\celestia@set@palette{4F1D28}{A97E2C}{384F68}{376040}{A83825}{FDF8F8}\celestia@set@tints{F2E8E9}{F2E8E9}{F5E7E4}{F2E8E9}{F2E8E9}\celestia@set@accent{8B6200}{EFEAE3}\celestia@set@roles{5F4A84}{774D06}\celestia@set@tones{blockcolor}{A7BFDA}{264F7A}\celestia@set@tones{examplecolor}{A8C5AD}{275B35}\celestia@set@tones{alertcolor}{D9B2AA}{962613}\celestia@set@tones{remarkcolor}{C0B6D7}{5C4780}\celestia@set@tones{methodcolor}{D0B89C}{724800}}
\newcommand{\celestia@palette@chalk}{\celestia@set@palette{2B303A}{A56A06}{4E7E64}{4C8044}{C04040}{E8E4D9}\celestia@set@tints{D0D8D3}{D0D8D3}{E0D2D0}{D0D8D3}{D0D8D3}\celestia@set@accent{815203}{DAD5CE}\celestia@set@roles{495791}{7C510F}\celestia@set@tones{blockcolor}{90B29E}{055032}\celestia@set@tones{examplecolor}{99B095}{1C4F14}\celestia@set@tones{alertcolor}{C49D9A}{8A0013}\celestia@set@tones{remarkcolor}{9EA7C7}{333F77}\celestia@set@tones{methodcolor}{BCA489}{5E3A00}}
\newcommand{\celestia@palette@copper}{\celestia@set@palette{2A3040}{B35D33}{2E5055}{3A6A5A}{A63D40}{F8F9FA}\celestia@set@tints{E7EAF2}{E7EAF2}{F5E6E5}{E7EAF2}{E7EAF2}\celestia@set@accent{A65126}{F1E8E4}\celestia@set@roles{5E4E89}{7A500C}\celestia@set@tones{blockcolor}{99C5CC}{00545D}\celestia@set@tones{examplecolor}{9FC6B7}{005D47}\celestia@set@tones{alertcolor}{D9B1AF}{922A30}\celestia@set@tones{remarkcolor}{BEB7D8}{564680}\celestia@set@tones{methodcolor}{C5BC9A}{714800}}
\newcommand{\celestia@palette@dusk}{\celestia@set@palette{D8EEE8}{CCA030}{52A796}{78AA48}{EA715F}{131C20}\celestia@set@tints{242E2B}{242E2B}{352725}{242E2B}{242E2B}\celestia@set@accent{CCA030}{242E2B}\celestia@set@roles{908EDA}{B6933F}\celestia@set@tones{blockcolor}{265C51}{77CBB9}\celestia@set@tones{examplecolor}{455835}{95C967}\celestia@set@tones{alertcolor}{6E443D}{FF9988}\celestia@set@tones{remarkcolor}{4D4C71}{B1B0FE}\celestia@set@tones{methodcolor}{604F28}{D7B360}}
\newcommand{\celestia@palette@forest}{\celestia@set@palette{183E2B}{B26232}{2D5A48}{31597A}{9D3438}{F7FAF8}\celestia@set@tints{E4EDE8}{E4EDE8}{F5E6E5}{E4EDE8}{E4EDE8}\celestia@set@accent{A25322}{F1E8E4}\celestia@set@roles{5E4983}{764C04}\celestia@set@tones{blockcolor}{A1C6B5}{095C43}\celestia@set@tones{examplecolor}{A4C0D9}{21547C}\celestia@set@tones{alertcolor}{D9B1AF}{932A30}\celestia@set@tones{remarkcolor}{C0B6D7}{5B467F}\celestia@set@tones{methodcolor}{CFB89C}{714700}}
\newcommand{\celestia@palette@graphite}{\celestia@set@palette{2B2E33}{E1791B}{47515E}{2E6544}{A82C38}{FCFBFA}\celestia@set@tints{EBECEF}{EBECEF}{F7E8E8}{EBECEF}{EBECEF}\celestia@set@accent{A65400}{EEEBEA}\celestia@set@roles{5C4C87}{00646D}\celestia@set@tones{blockcolor}{AAC0DD}{2E517E}\celestia@set@tones{examplecolor}{A7C8B1}{215D3B}\celestia@set@tones{alertcolor}{DBB3B2}{9A1C2D}\celestia@set@tones{remarkcolor}{C0B9DA}{594983}\celestia@set@tones{methodcolor}{9BC7CD}{005B63}}
\newcommand{\celestia@palette@horizon}{\celestia@set@palette{183D54}{00788C}{1F4E5F}{01703F}{B91C1C}{F8FAFA}\celestia@set@tints{E4ECF1}{E4ECF1}{F5E7E5}{E4ECF1}{E4ECF1}\celestia@set@accent{017588}{E3EDEF}\celestia@set@roles{664982}{794E09}\celestia@set@tones{blockcolor}{9DC4D4}{005066}\celestia@set@tones{examplecolor}{A5C6B0}{005F34}\celestia@set@tones{alertcolor}{D9B2AC}{A50009}\celestia@set@tones{remarkcolor}{C4B5D5}{61447D}\celestia@set@tones{methodcolor}{C8BC9B}{724700}}
\newcommand{\celestia@palette@imperial}{\celestia@set@palette{1A2535}{8F4D46}{2A4060}{2E5940}{B71C1C}{FAFAFA}\celestia@set@tints{E7ECF3}{E7ECF3}{F6E7E5}{E7ECF3}{E7ECF3}\celestia@set@accent{8F4D46}{F3E9E8}\celestia@set@roles{693D6E}{704600}\celestia@set@tones{blockcolor}{ABBFDC}{213F6C}\celestia@set@tones{examplecolor}{A5C7B1}{1D5C3B}\celestia@set@tones{alertcolor}{DAB2AD}{A5000A}\celestia@set@tones{remarkcolor}{CCB4CF}{693D6E}\celestia@set@tones{methodcolor}{C8BD9B}{704600}}
\newcommand{\celestia@palette@lumiere}{\celestia@set@palette{2C3D55}{A05070}{3A4F6A}{1E6B5E}{8B3050}{F7F6F4}\celestia@set@tints{E3E8EF}{E3E8EF}{F1E3E6}{E3E8EF}{E3E8EF}\celestia@set@accent{9D4D6D}{EEE5E8}\celestia@set@roles{64467E}{754B03}\celestia@set@tones{blockcolor}{A6BBD8}{2B4F7B}\celestia@set@tones{examplecolor}{99C4BA}{005A4D}\celestia@set@tones{alertcolor}{D4ADB7}{872C4D}\celestia@set@tones{remarkcolor}{C2B2D1}{5F4179}\celestia@set@tones{methodcolor}{C5B998}{704600}}
\newcommand{\celestia@palette@manuscript}{\celestia@set@palette{2E2E58}{8A62B8}{2D4A7A}{2C704E}{B03030}{FFFDF5}\celestia@set@tints{ECEDF5}{ECEDF5}{F9EAE8}{ECEDF5}{ECEDF5}\celestia@set@accent{8159AE}{EFECF4}\celestia@set@roles{664C86}{7B510D}\celestia@set@tones{blockcolor}{AEC1DF}{2D4A7A}\celestia@set@tones{examplecolor}{A7CAB5}{19603F}\celestia@set@tones{alertcolor}{DDB5B0}{9F1E22}\celestia@set@tones{remarkcolor}{C6B9D9}{5F457F}\celestia@set@tones{methodcolor}{CABF9E}{744A01}}
\newcommand{\celestia@palette@midnight}{\celestia@set@palette{E0E2F4}{A87AE0}{7096E2}{5AAA7A}{ED6C6A}{161828}\celestia@set@tints{292931}{292931}{342625}{292931}{292931}\celestia@set@accent{AA7CE2}{292931}\celestia@set@roles{A687D0}{B3943F}\celestia@set@tones{blockcolor}{3F5071}{8FB5FF}\celestia@set@tones{examplecolor}{335A42}{7ACB99}\celestia@set@tones{alertcolor}{6D4240}{FF9792}\celestia@set@tones{remarkcolor}{57486B}{C6A7F2}\celestia@set@tones{methodcolor}{5D4E27}{D4B460}}
\newcommand{\celestia@palette@mineral}{\celestia@set@palette{243350}{A0694D}{1E293B}{1E3A8A}{A04701}{FAFAF8}\celestia@set@tints{E7EBF3}{E7EBF3}{F5E8E2}{E7EBF3}{E7EBF3}\celestia@set@accent{935D42}{F2E9E4}\celestia@set@roles{632E57}{05532C}\celestia@set@tones{blockcolor}{ACBEDC}{0D2752}\celestia@set@tones{examplecolor}{AFBDDC}{1E3A8A}\celestia@set@tones{alertcolor}{D7B5A3}{883900}\celestia@set@tones{remarkcolor}{D2B2C8}{632E57}\celestia@set@tones{methodcolor}{A6C6AF}{05532C}}
\newcommand{\celestia@palette@nordic}{\celestia@set@palette{1C3A4E}{3D8AAA}{2D5A6A}{3D6B45}{A8393B}{F5F8F8}\celestia@set@tints{E2EAEF}{E2EAEF}{F3E5E3}{E2EAEF}{E2EAEF}\celestia@set@accent{1F7190}{E2EAEE}\celestia@set@roles{5C528E}{7D5311}\celestia@set@tones{blockcolor}{9BC2D1}{00576F}\celestia@set@tones{examplecolor}{A7C3AA}{295B33}\celestia@set@tones{alertcolor}{D7AFAC}{94252B}\celestia@set@tones{remarkcolor}{B9B6D7}{514681}\celestia@set@tones{methodcolor}{C8B999}{704700}}
\newcommand{\celestia@palette@obsidian}{\celestia@set@palette{E8EAF6}{3FA8D8}{86A9CC}{81C784}{FF7976}{22242E}\celestia@set@tints{31373D}{31373D}{413231}{31373D}{31373D}\celestia@set@accent{41AADA}{31373D}\celestia@set@roles{C695DA}{CCA553}\celestia@set@tones{blockcolor}{42607E}{9ECEFF}\celestia@set@tones{examplecolor}{476648}{96DD98}\celestia@set@tones{alertcolor}{7B4F4D}{FEB2AD}\celestia@set@tones{remarkcolor}{6A5374}{E5B3FA}\celestia@set@tones{methodcolor}{6D5A34}{EAC270}}
\newcommand{\celestia@palette@oxford}{\celestia@set@palette{212F42}{4A7AA8}{2C3E50}{386B61}{922B21}{F9FAFB}\celestia@set@tints{E6EBF3}{E6EBF3}{F6E7E5}{E6EBF3}{E6EBF3}\celestia@set@accent{3E6E9B}{E5ECF3}\celestia@set@roles{663D71}{6F4600}\celestia@set@tones{blockcolor}{A6C0DB}{103E66}\celestia@set@tones{examplecolor}{9DC7BE}{005D51}\celestia@set@tones{alertcolor}{DAB2AC}{922B21}\celestia@set@tones{remarkcolor}{CAB4D1}{663D71}\celestia@set@tones{methodcolor}{C1BF9C}{6F4600}}
\newcommand{\celestia@palette@palatial}{\celestia@set@palette{243868}{B08A20}{1F3A5F}{2D5A27}{A33B20}{F8FAFC}\celestia@set@tints{E7EBF3}{E7EBF3}{F5E7E4}{E7EBF3}{E7EBF3}\celestia@set@accent{856600}{EEEBE2}\celestia@set@roles{643B6D}{6C4300}\celestia@set@tones{blockcolor}{AABFDB}{193A65}\celestia@set@tones{examplecolor}{ADC5A9}{2D5A27}\celestia@set@tones{alertcolor}{D9B3A9}{932C0F}\celestia@set@tones{remarkcolor}{CBB4D0}{643B6D}\celestia@set@tones{methodcolor}{CABC9B}{6C4300}}
\newcommand{\celestia@palette@petrol}{\celestia@set@palette{14404E}{957D48}{1F4A44}{546A15}{A04030}{F9FBF9}\celestia@set@tints{E4EDF1}{E4EDF1}{F6E8E5}{E4EDF1}{E4EDF1}\celestia@set@accent{7E6732}{EFEBE3}\celestia@set@roles{524E89}{774C05}\celestia@set@tones{blockcolor}{9CC8C0}{004D45}\celestia@set@tones{examplecolor}{B7C3A2}{455A00}\celestia@set@tones{alertcolor}{DAB3AB}{903122}\celestia@set@tones{remarkcolor}{BABADB}{4D4983}\celestia@set@tones{methodcolor}{CBBC9C}{734900}}
\newcommand{\celestia@palette@prestige}{\celestia@set@palette{283D62}{A83858}{2D3F5E}{1E6B5E}{A03050}{F8F7F5}\celestia@set@tints{E4E9F0}{E4E9F0}{F3E4E6}{E4E9F0}{E4E9F0}\celestia@set@accent{A83858}{F0E6E7}\celestia@set@roles{664278}{734900}\celestia@set@tones{blockcolor}{AABBD9}{243E6B}\celestia@set@tones{examplecolor}{9AC5BB}{005C4F}\celestia@set@tones{alertcolor}{D6AEB5}{922245}\celestia@set@tones{remarkcolor}{C6B2D0}{644076}\celestia@set@tones{methodcolor}{C4BA99}{714700}}
\newcommand{\celestia@palette@royal}{\celestia@set@palette{233348}{1A7A9A}{1A4A5A}{2D5A4C}{AF392D}{FCFCFD}\celestia@set@tints{E8EEF5}{E8EEF5}{F8EAE7}{E8EEF5}{E8EEF5}\celestia@set@accent{0F7494}{E6EFF3}\celestia@set@roles{60447D}{734900}\celestia@set@tones{blockcolor}{9FC6D6}{004B60}\celestia@set@tones{examplecolor}{A1C9BB}{005F4A}\celestia@set@tones{alertcolor}{DCB4AE}{9B241B}\celestia@set@tones{remarkcolor}{C6B8D8}{60447D}\celestia@set@tones{methodcolor}{C6C09E}{734900}}
\newcommand{\celestia@palette@sakura}{\celestia@set@palette{4A4A4A}{C4607A}{8A79BA}{6D8A6C}{DD4D70}{FFF9FB}\celestia@set@tints{ECEBF3}{ECEBF3}{F6E8E9}{ECEBF3}{ECEBF3}\celestia@set@accent{AB4A64}{F3E9EB}\celestia@set@roles{02738C}{8C6023}\celestia@set@tones{blockcolor}{C0B8DA}{584783}\celestia@set@tones{examplecolor}{ACC6AB}{315D31}\celestia@set@tones{alertcolor}{DAB2B7}{A20541}\celestia@set@tones{remarkcolor}{9DC6D3}{005B70}\celestia@set@tones{methodcolor}{CFBB9D}{734800}}
\newcommand{\celestia@palette@sapphire}{\celestia@set@palette{1E2E50}{2C5FD6}{334155}{007069}{BE123C}{FDFDFD}\celestia@set@tints{EAEEF6}{EAEEF6}{F9EAEA}{EAEEF6}{EAEEF6}\celestia@set@accent{2C5FD6}{EAEEF6}\celestia@set@roles{6D467B}{784E08}\celestia@set@tones{blockcolor}{ADC2DF}{21406C}\celestia@set@tones{examplecolor}{9ECAC5}{005F59}\celestia@set@tones{alertcolor}{DDB4B5}{A70030}\celestia@set@tones{remarkcolor}{CDB7D4}{6A4377}\celestia@set@tones{methodcolor}{C6C29F}{744B02}}
\newcommand{\celestia@palette@steel}{\celestia@set@palette{1E2E48}{3D6BAA}{1E293B}{3C6B54}{941111}{F8FAFC}\celestia@set@tints{E7EBF2}{E7EBF2}{F6E7E5}{E7EBF2}{E7EBF2}\celestia@set@accent{3D6BAA}{E6EBF2}\celestia@set@roles{5F3364}{643E00}\celestia@set@tones{blockcolor}{ACBEDC}{0D2752}\celestia@set@tones{examplecolor}{A3C7B3}{155D40}\celestia@set@tones{alertcolor}{DAB2AC}{941111}\celestia@set@tones{remarkcolor}{CCB3CE}{5F3364}\celestia@set@tones{methodcolor}{C6BD9B}{643E00}}
\newcommand{\celestia@palette@terracotta}{\celestia@set@palette{4A2C20}{B05E27}{6A5A4A}{4C6A4C}{AD3906}{FFF9F5}\celestia@set@tints{F2E9E6}{F2E9E6}{F6E8E4}{F2E9E6}{F2E9E6}\celestia@set@accent{A5541A}{F1E9E5}\celestia@set@roles{4C5E97}{844A71}\celestia@set@tones{blockcolor}{D2B89E}{704715}\celestia@set@tones{examplecolor}{ABC6AB}{305C31}\celestia@set@tones{alertcolor}{DAB2B1}{942B00}\celestia@set@tones{remarkcolor}{B1BDDC}{3E4F86}\celestia@set@tones{methodcolor}{D3B2C7}{753D63}}
\newcommand{\celestia@palette@velours}{\celestia@set@palette{EAE0EC}{C8A030}{A585D6}{44A191}{EB6976}{1C1420}\celestia@set@tints{29272E}{29272E}{322424}{29272E}{29272E}\celestia@set@accent{C8A030}{29272E}\celestia@set@roles{509DD2}{B1913C}\celestia@set@tones{blockcolor}{534669}{C3A3F6}\celestia@set@tones{examplecolor}{21584F}{6CC7B6}\celestia@set@tones{alertcolor}{6B4042}{FF929A}\celestia@set@tones{remarkcolor}{2D526B}{6FBBF2}\celestia@set@tones{methodcolor}{5B4C24}{D0AF5B}}
\newcommand{\celestia@palette@velvet}{\celestia@set@palette{3D2838}{8A7430}{593254}{17626E}{8B3A2A}{FBF9F8}\celestia@set@tints{F0E8ED}{F0E8ED}{F5E7E4}{F0E8ED}{F0E8ED}\celestia@set@accent{7E6823}{EDEBE3}\celestia@set@roles{37467D}{684000}\celestia@set@tones{blockcolor}{CFB2CA}{5C2F56}\celestia@set@tones{examplecolor}{9AC5CE}{005A66}\celestia@set@tones{alertcolor}{D9B2AA}{873727}\celestia@set@tones{remarkcolor}{B1BCDC}{37467D}\celestia@set@tones{methodcolor}{C8BC9B}{684000}}

\newcommand{\celestia@define@tints}[5]{%
  \definecolor{blockcolortint}{HTML}{#1}%
  \definecolor{examplecolortint}{HTML}{#2}%
  \definecolor{alertcolortint}{HTML}{#3}%
  \definecolor{maintint}{HTML}{#4}%
  \definecolor{accenttint}{HTML}{#5}%
}
\newcommand{\celestia@define@accent}[2]{%
  \definecolor{accenttext}{HTML}{#1}%
  \definecolor{celestia@accenthue}{HTML}{#2}%
}
\newcommand{\celestia@mix@tones}[1]{%
  \colorlet{#1veil}{#1!7!background}%
  \colorlet{#1band}{#1!26!background}%
  \colorlet{#1d1}{#1!15!background}%
  \colorlet{#1d2}{#1!21!background}%
  \colorlet{#1d3}{#1!28!background}%
}
\newcommand{\celestia@define@tones}[3]{%
  \celestia@mix@tones{#1}%
  \definecolor{#1rule}{HTML}{#2}%
  \definecolor{#1ink}{HTML}{#3}%
}
\newcommand{\celestia@fallback@tones}[1]{%
  \celestia@mix@tones{#1}%
  \colorlet{#1rule}{#1!40!background}%
  \colorlet{#1ink}{#1!80!main}%
}

\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}%
  \let\celestia@tints\@empty
  \let\celestia@accentpair\@empty
  \celestia@clear@tones
}

\define@key{celestia}{palette}[nordic]{%
  \expandafter\ifx\csname celestia@palette@#1\endcsname\relax
    \PackageWarning{celestia}{Unknown palette: #1}%
  \else
    \def\celestia@palette{#1}%
    \def\celestia@given@palette{#1}%
    \csname celestia@palette@#1\endcsname
  \fi
}

\define@key{celestia}{custompalette}{%
  \def\celestia@custompalette@value{#1}%
  \celestia@parse@custompalette{#1}%
}
\define@key{celestia}{maincolor}{\def\celestia@user@maincolor{#1}}
\define@key{celestia}{accentcolor}{\def\celestia@user@accentcolor{#1}}
\define@key{celestia}{backgroundcolor}{\def\celestia@user@backgroundcolor{#1}}
\define@key{celestia}{blockcolor}{\def\celestia@user@blockcolor{#1}}
\define@key{celestia}{examplecolor}{\def\celestia@user@examplecolor{#1}}
\define@key{celestia}{alertcolor}{\def\celestia@user@alertcolor{#1}}
\define@key{celestia}{remarkcolor}{\def\celestia@user@remarkcolor{#1}}
\define@key{celestia}{methodcolor}{\def\celestia@user@methodcolor{#1}}

\newif\ifcelestia@user@sansfaceoptions@set
\newif\ifcelestia@user@decoration@set
\newif\ifcelestia@user@headstyle@set
\newif\ifcelestia@user@mathface@set
\newif\ifcelestia@monoscaled

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

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

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

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

\define@key{celestia}{footerstyle}{%
  \def\celestia@footerstyle{#1}%
  \def\celestia@given@footerstyle{#1}%
}
\@for\celestia@tmp:=block,emphasis,titlealign,frametitlesize\do{%
  \edef\celestia@tmpb{%
    \noexpand\define@key{celestia}{\celestia@tmp}{%
      \noexpand\@namedef{celestia@\celestia@tmp}{##1}%
      \noexpand\@namedef{celestia@given@\celestia@tmp}{##1}}}%
  \celestia@tmpb
}

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

\ProcessKeyvalOptions*

\ifdefined\celestia@style
  \ifcsname celestia@scheme@\celestia@style\endcsname
    \csname celestia@scheme@\celestia@style\endcsname
    \@for\celestia@tmp:=palette,frametitle,footerstyle,block,emphasis,titlealign,frametitlesize,headstyle\do{%
      \ifcsname celestia@given@\celestia@tmp\endcsname
        \expandafter\let\csname celestia@\celestia@tmp\expandafter\endcsname
          \csname celestia@given@\celestia@tmp\endcsname
      \fi}%
  \else
    \PackageWarning{celestia}{Unknown style: \celestia@style}%
  \fi
\fi

\csname celestia@palette@\celestia@palette\endcsname
\ifdefined\celestia@custompalette@value
  \expandafter\celestia@parse@custompalette\expandafter{\celestia@custompalette@value}%
\fi
\@for\celestia@role:=main,accent,background,block,example,alert,remark,method\do{%
  \ifcsname celestia@user@\celestia@role color\endcsname
    \expandafter\let\csname celestia@\celestia@role color\expandafter\endcsname
      \csname celestia@user@\celestia@role color\endcsname
    \expandafter\celestia@override\expandafter{\celestia@role}%
  \fi
}

\ifcelestia@user@light@set\else
  \IfSubStr{,dusk,midnight,obsidian,velours,}{,\celestia@palette,}{\celestia@lightfalse}{}
  \ifcelestia@allserif\celestia@lightfalse\fi
\fi
\IfSubStr{,clean,elegant,plain,cosmic,line,subtle,plainrule,ruled,leftbar,gradient,}{,\celestia@frametitle,}{}{%
  \PackageWarning{celestia}{Unknown frametitle: \celestia@frametitle}%
  \def\celestia@frametitle{ruled}%
}
\IfSubStr{,left,center,right,}{,\celestia@titlealign,}{}{%
  \PackageWarning{celestia}{Unknown titlealign: \celestia@titlealign}%
  \def\celestia@titlealign{left}%
}
\IfSubStr{,normal,sc,it,}{,\celestia@headshape,}{}{%
  \PackageWarning{celestia}{Unknown headshape: \celestia@headshape}%
  \def\celestia@headshape{normal}%
}
\IfSubStr{,main,accent,}{,\celestia@emphasis,}{}{%
  \PackageWarning{celestia}{Unknown emphasis: \celestia@emphasis}%
  \def\celestia@emphasis{main}%
}
\IfSubStr{,main,accent,}{,\celestia@decoration,}{}{%
  \PackageWarning{celestia}{Unknown decoration: \celestia@decoration}%
  \let\celestia@decoration\celestia@emphasis
}
\ifcelestia@user@light@set
  \ifcelestia@light\else
    \ifcelestia@user@semibold@set\else\celestia@semiboldfalse\fi
  \fi
\fi

\IfStrEq{\celestia@mathface}{inter}{%
  \IfFileExists{OMLInter-TLF.fd}{%
    \ifcelestia@user@mathface@set\else
      \IfStrEq{\celestia@sansface}{inter}{%
        \ifcelestia@allserif\def\celestia@mathface{iwona}\fi
      }{%
        \def\celestia@mathface{iwona}%
      }%
    \fi
  }{%
    \def\celestia@mathface{iwona}%
  }%
}{}

\newcommand{\celestia@readlanguage}[1]{%
  \IfSubStr{,french,francais,frenchb,acadian,}{,#1,}{\def\celestia@language{french}}{\def\celestia@language{english}}%
}
\newcommand{\celestia@langfromdoc}{%
  \@ifpackageloaded{babel}{%
    \ifdefined\bbl@main@language
      \celestia@readlanguage{\bbl@main@language}%
    \else
      \celestia@readlanguage{\languagename}%
    \fi
  }{%
    \@ifpackageloaded{polyglossia}{%
      \ifdefined\mainlanguagename\celestia@readlanguage{\mainlanguagename}\fi
    }{}%
  }%
}
\newcommand{\celestia@loadbabel}{%
  \@ifpackageloaded{babel}{}{\@ifpackageloaded{polyglossia}{}{\RequirePackage[\celestia@language]{babel}}}%
}
\newif\ifcelestia@classlanguage
\def\celestia@classlanguages{}
\ifcelestia@user@language@set
  \celestia@loadbabel
\else
  \ifx\@classoptionslist\relax\else
    \@for\celestia@tmp:=\@classoptionslist\do{%
      \IfSubStr{,french,francais,frenchb,acadian,english,american,british,UKenglish,USenglish,}{,\celestia@tmp,}{%
        \celestia@classlanguagetrue\edef\celestia@classlanguages{\celestia@classlanguages,\celestia@tmp}}{}}%
  \fi
  \ifcelestia@classlanguage
    \@ifpackageloaded{babel}{}{\@ifpackageloaded{polyglossia}{}{%
      \edef\celestia@tmp{\noexpand\RequirePackage[\expandafter\@gobble\celestia@classlanguages]{babel}}\celestia@tmp}}%
  \fi
  \celestia@langfromdoc
  \AtEndPreamble{%
    \celestia@loadbabel
    \celestia@langfromdoc
    \celestia@setnames
  }
\fi

\newcommand{\celestia@setnames}{%
\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}%
\def\celestia@name@exercise{Exercise}%
\def\celestia@name@exercises{Exercises}%
\def\celestia@name@summary{Key points}%
\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@name@exercise{Exercice}%
  \def\celestia@name@exercises{Exercices}%
  \def\celestia@name@summary{À retenir}%
}{}%
}
\celestia@setnames

\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

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

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

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

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


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

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

\usefonttheme{professionalfonts}

\newcommand{\celestia@intermath}[2]{%
  \providecommand*{\Inter@scale}{0.88}%
  \DeclareSymbolFont{celestia@interup}{OT1}{Inter-TLF}{#1}{n}%
  \SetSymbolFont{celestia@interup}{bold}{OT1}{Inter-TLF}{#2}{n}%
  \DeclareSymbolFont{celestia@interit}{OML}{Inter-TLF}{#1}{it}%
  \SetSymbolFont{celestia@interit}{bold}{OML}{Inter-TLF}{#2}{it}%
  \DeclareSymbolFontAlphabet{\mathrm}{celestia@interup}%
  \DeclareSymbolFontAlphabet{\mathnormal}{celestia@interit}%
  \def\operator@font{\mathgroup\symcelestia@interup}%
  \SetMathAlphabet{\mathit}{normal}{OT1}{Inter-TLF}{#1}{it}%
  \SetMathAlphabet{\mathit}{bold}{OT1}{Inter-TLF}{#2}{it}%
  \SetMathAlphabet{\mathbf}{normal}{OT1}{Inter-TLF}{#2}{n}%
  \SetMathAlphabet{\mathbf}{bold}{OT1}{Inter-TLF}{#2}{n}%
  \SetMathAlphabet{\mathsf}{normal}{OT1}{Inter-TLF}{#1}{n}%
  \SetMathAlphabet{\mathsf}{bold}{OT1}{Inter-TLF}{#2}{n}%
  \def\celestia@do##1{%
    \ifx##1\relax\else
      \DeclareMathSymbol{##1}{\mathalpha}{celestia@interit}{`##1}%
      \expandafter\celestia@do
    \fi}%
  \celestia@do abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\relax
  \def\celestia@do##1{%
    \ifx##1\relax\else
      \DeclareMathSymbol{##1}{\mathalpha}{celestia@interup}{`##1}%
      \expandafter\celestia@do
    \fi}%
  \celestia@do 0123456789\relax
  \count@="0B
  \@for\celestia@tmp:=alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,%
    kappa,lambda,mu,nu,xi,pi,rho,sigma,tau,upsilon,phi,chi,psi,omega,%
    varepsilon,vartheta,varpi,varrho,varsigma,varphi\do{%
    \ifnum\count@="17 \else
      \expandafter\DeclareMathSymbol\csname\celestia@tmp\endcsname
        {\mathord}{celestia@interit}{\count@}%
    \fi
    \advance\count@\@ne}%
  \count@=\z@
  \@for\celestia@tmp:=Gamma,Delta,Theta,Lambda,Xi,Pi,Sigma,Upsilon,Phi,Psi,%
    Omega\do{%
    \expandafter\DeclareMathSymbol\csname\celestia@tmp\endcsname
      {\mathalpha}{celestia@interup}{\count@}%
    \advance\count@\@ne}%
  \DeclareMathSymbol{\partial}{\mathord}{celestia@interit}{"40}%
  \DeclareMathSymbol{\ell}{\mathord}{celestia@interit}{"60}%
  \DeclareMathSymbol{\imath}{\mathord}{celestia@interit}{"7B}%
  \DeclareMathSymbol{\jmath}{\mathord}{celestia@interit}{"7C}%
  \DeclareMathSymbol{!}{\mathclose}{celestia@interup}{"21}%
  \DeclareMathSymbol{;}{\mathpunct}{celestia@interup}{"3B}%
  \DeclareMathSymbol{?}{\mathclose}{celestia@interup}{"3F}%
  \DeclareMathSymbol{,}{\mathpunct}{celestia@interit}{"3B}%
}

\newcommand{\celestia@legacymath}[2]{%
  \SetSymbolFont{operators}{normal}{OT1}{#1}{m}{n}%
  \SetSymbolFont{operators}{bold}{OT1}{#1}{b}{n}%
  \SetSymbolFont{letters}{normal}{OML}{#1}{m}{it}%
  \SetSymbolFont{letters}{bold}{OML}{#1}{b}{it}%
  \SetSymbolFont{symbols}{normal}{OMS}{#1}{m}{n}%
  \SetSymbolFont{symbols}{bold}{OMS}{#1}{b}{n}%
  \SetSymbolFont{largesymbols}{normal}{OMX}{#1}{m}{n}%
  \SetMathAlphabet{\mathrm}{normal}{OT1}{#1}{m}{n}
  \SetMathAlphabet{\mathrm}{bold}{OT1}{#1}{b}{n}
  \SetMathAlphabet{\mathbf}{normal}{OT1}{#1}{b}{n}
  \SetMathAlphabet{\mathbf}{bold}{OT1}{#1}{eb}{n}
  \SetMathAlphabet{\mathit}{normal}{OT1}{#1}{m}{it}
  \SetMathAlphabet{\mathit}{bold}{OT1}{#1}{b}{it}
  \SetMathAlphabet{\mathsf}{normal}{OT1}{#1}{m}{n}
  \SetMathAlphabet{\mathsf}{bold}{OT1}{#1}{b}{n}
  \DeclareMathAlphabet{\mathtt}{#2}{\ttdefault}{m}{n}
  \DeclareSymbolFont{celestia@doublebar}{OMS}{cmsy}{m}{n}%
  \SetSymbolFont{celestia@doublebar}{bold}{OMS}{cmsy}{b}{n}%
  \DeclareMathDelimiter{\|}{\mathord}{celestia@doublebar}{"6B}{largesymbols}{"0D}%
  \DeclareMathDelimiter{\Vert}{\mathord}{celestia@doublebar}{"6B}{largesymbols}{"0D}%
  \DeclareMathDelimiter{\lVert}{\mathopen}{celestia@doublebar}{"6B}{largesymbols}{"0D}%
  \DeclareMathDelimiter{\rVert}{\mathclose}{celestia@doublebar}{"6B}{largesymbols}{"0D}%
  \DeclareMathDelimiter{\Arrowvert}{\mathord}{celestia@doublebar}{"6B}{largesymbols}{"3D}%
  \DeclareMathSymbol{\parallel}{\mathrel}{celestia@doublebar}{"6B}%
  \SetMathAlphabet{\mathtt}{bold}{#2}{\ttdefault}{b}{n}
  \ifcsname symlegacymaths\endcsname
    \SetSymbolFont{legacymaths}{normal}{OT1}{#1}{m}{n}%
    \SetSymbolFont{legacymaths}{bold}{OT1}{#1}{b}{n}%
  \fi
}

\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
  \IfStrEq{\celestia@mathface}{inter}{\PassOptionsToPackage{no-math}{fontspec}}{}
  \IfStrEq{\celestia@mathface}{iwona}{\PassOptionsToPackage{no-math}{fontspec}}{}
  \IfStrEq{\celestia@mathface}{kurier}{\PassOptionsToPackage{no-math}{fontspec}}{}
  \RequirePackage{fontspec}
  \defaultfontfeatures{Scale=MatchLowercase}

  \def\celestia@interfile@up{Regular}
  \def\celestia@interfile@it{Italic}
  \def\celestia@interfile@bf{Bold}
  \def\celestia@interfile@bfit{BoldItalic}
  \ifcelestia@light
    \def\celestia@interfile@up{Light}
    \def\celestia@interfile@it{LightItalic}
  \fi
  \ifcelestia@semibold
    \def\celestia@interfile@bf{SemiBold}
    \def\celestia@interfile@bfit{SemiBoldItalic}
  \fi
  \newcommand{\celestia@inter@static}[1]{%
    \edef\celestia@tmp{\noexpand\IfFontExistsTF{Inter-\celestia@interfile@up.otf}}%
    \celestia@tmp{%
      \edef\celestia@tmp{\noexpand\setsansfont{Inter}[Scale=0.88, Extension=.otf,
        UprightFont=*-\celestia@interfile@up,
        ItalicFont=*-\celestia@interfile@it,
        BoldFont=*-\celestia@interfile@bf,
        BoldItalicFont=*-\celestia@interfile@bfit]}%
      \celestia@tmp
    }{#1}%
  }

  \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}, ItalicFont={Inter Light Italic}, BoldFont={Inter SemiBold}, BoldItalicFont={Inter SemiBold Italic}]
              }{%
                \setsansfont{Inter}[Scale=0.88, UprightFont={Inter Light}, ItalicFont={Inter Light Italic}, \celestia@sansfaceoptions]
              }
            \else
              \setsansfont{Inter}[Scale=0.88, UprightFont={Inter Light}, ItalicFont={Inter Light Italic}, BoldFont={Inter Bold}, BoldItalicFont={Inter Bold Italic}]
            \fi
          }{%
            \celestia@inter@static{%
              \setsansfont{Inter}[Scale=0.88, \celestia@sansfaceoptions]}
          }
        \else
          \ifcelestia@semibold
            \IfFontExistsTF{Inter SemiBold}{%
              \setsansfont{Inter}[Scale=0.88, BoldFont={Inter SemiBold}, BoldItalicFont={Inter SemiBold Italic}]
            }{%
              \celestia@inter@static{%
                \setsansfont{Inter}[Scale=0.88, \celestia@sansfaceoptions]}
            }
          \else
            \IfFontExistsTF{Inter Bold}{%
              \setsansfont{Inter}[Scale=0.88, BoldFont={Inter Bold}, BoldItalicFont={Inter Bold Italic}]
            }{%
              \celestia@inter@static{%
                \setsansfont{Inter}[Scale=0.88]}
            }
          \fi
        \fi
      \fi
    }{%
      \celestia@inter@static{%
        \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}{%
      \ifcelestia@light
        \IfFontExistsTF{IBM Plex Mono Light}{%
          \setmonofont{IBM Plex Mono}[Scale=0.875, UprightFont={IBM Plex Mono Light}, ItalicFont={IBM Plex Mono Light Italic}, BoldFont={IBM Plex Mono Bold}, BoldItalicFont={IBM Plex Mono Bold Italic}, \celestia@monofaceoptions]
        }{%
          \setmonofont{IBM Plex Mono}[Scale=0.875, \celestia@monofaceoptions]
        }
      \else
        \setmonofont{IBM Plex Mono}[Scale=0.875, \celestia@monofaceoptions]
      \fi
      \IfSubStr{\celestia@monofaceoptions}{Scale}{}{\celestia@monoscaledtrue}
    }{%
      \IfFontExistsTF{IBMPlexMono-Regular.otf}{%
        \def\celestia@plexfile@up{IBMPlexMono-Regular.otf}
        \def\celestia@plexfile@it{IBMPlexMono-Italic.otf}
        \ifcelestia@light
          \IfFontExistsTF{IBMPlexMono-Light.otf}{%
            \def\celestia@plexfile@up{IBMPlexMono-Light.otf}
            \def\celestia@plexfile@it{IBMPlexMono-LightItalic.otf}
          }{}
        \fi
        \edef\celestia@tmp{\noexpand\setmonofont{\celestia@plexfile@up}[
        Scale=0.875,
        BoldFont=IBMPlexMono-Bold.otf,
        ItalicFont=\celestia@plexfile@it,
        BoldItalicFont=IBMPlexMono-BoldItalic.otf,
        ]}%
        \celestia@tmp
        \celestia@monoscaledtrue
      }{%
        \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}{inter}{%
      \AtBeginDocument{%
        \edef\celestia@tmp{\noexpand\celestia@intermath
          {\ifcelestia@user@sansfaceoptions@set m\else
             \ifcelestia@light l\else m\fi\fi}%
          {\ifcelestia@semibold sb\else b\fi}}%
        \celestia@tmp
        \DeclareMathAlphabet{\mathtt}{TU}{\ttdefault}{m}{n}%
        \SetMathAlphabet{\mathtt}{bold}{TU}{\ttdefault}{b}{n}%
      }%
    }{%
    \IfStrEq{\celestia@mathface}{iwona}{%
      \AtBeginDocument{\celestia@legacymath{iwona}{TU}}%
    }{%
    \IfStrEq{\celestia@mathface}{kurier}{%
      \AtBeginDocument{\celestia@legacymath{kurier}{TU}}%
    }{%
    \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}
      \newcommand{\celestia@setmathfont}[1]{%
        \begingroup
        \edef\celestia@setmathfont@do{\endgroup
          \noexpand\setmathfont{#1}[\celestia@mathfaceoptions]}%
        \celestia@setmathfont@do
      }
      \IfStrEq{\celestia@mathface}{pagella}{%
        \celestia@setmathfont{TeX Gyre Pagella Math}
      }{%
        \IfStrEq{\celestia@mathface}{termes}{%
          \celestia@setmathfont{TeX Gyre Termes Math}
        }{%
          \IfStrEq{\celestia@mathface}{stix}{%
            \celestia@setmathfont{STIX Two Math}
          }{%
            \IfStrEq{\celestia@mathface}{libertinus}{%
              \celestia@setmathfont{Libertinus Math}
            }{%
              \IfStrEq{\celestia@mathface}{fira}{%
                \celestia@setmathfont{Fira Math}
              }{%
                \celestia@setmathfont{\celestia@mathface}
              }
            }
          }
        }
      }
    }}}}}
  \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,proportional}{inter}
        \else
          \PassOptionsToPackage{\celestia@sansfaceoptions}{inter}
        \fi
      \else
        \ifcelestia@light
          \PassOptionsToPackage{light,scaled=0.88,proportional}{inter}
        \else
          \PassOptionsToPackage{scaled=0.88,proportional}{inter}
        \fi
        \ifcelestia@semibold
          \PassOptionsToPackage{semibold}{inter}
        \fi
      \fi
      \RequirePackage{inter}
    }{%
      \RequirePackage{helvet}
      \renewcommand{\familydefault}{\sfdefault}
    }
  }{%
    \PassOptionsToPackage{\celestia@sansfaceoptions}{\celestia@sansface}
    \let\celestia@tmp\sfdefault
    \RequirePackage{\celestia@sansface}
    \ifx\celestia@tmp\sfdefault
      \PackageWarning{celestia}{Package \celestia@sansface\space did not change the sans\MessageBreak font; give its option with sansfaceoptions}%
    \fi
  }

  \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.875}{plex-mono}
      \RequirePackage{plex-mono}
      \celestia@monoscaledtrue
    }{%
      \RequirePackage{courier}
    }
  }{%
    \PassOptionsToPackage{\celestia@monofaceoptions}{\celestia@monoface}
    \RequirePackage{\celestia@monoface}
  }

  \ifcelestia@allserif
    \renewcommand{\familydefault}{\rmdefault}
    \ifcelestia@user@headstyle@set\else
      \def\celestia@headstyle{rmfamily}%
    \fi
  \fi
  \IfSubStr{,fira,noto,}{,\celestia@mathface,}{%
    \PackageWarning{celestia}{mathface=\celestia@mathface\space needs LuaLaTeX or XeLaTeX;\MessageBreak iwona is used}%
    \def\celestia@mathface{iwona}}{}%
  \ifx\celestia@mathface\@empty\else
    \IfStrEq{\celestia@mathface}{inter}{%
      \edef\celestia@tmp{\noexpand\celestia@intermath
        {\mdseries@sf}{\ifcelestia@semibold sb\else b\fi}}%
      \celestia@tmp
      \DeclareMathAlphabet{\mathtt}{T1}{\ttdefault}{m}{n}%
      \SetMathAlphabet{\mathtt}{bold}{T1}{\ttdefault}{b}{n}%
    }{%
    \IfStrEq{\celestia@mathface}{pagella}{%
      \RequirePackage{mathpazo}
    }{%
      \IfStrEq{\celestia@mathface}{termes}{%
        \RequirePackage{newtxmath}
      }{%
        \IfStrEq{\celestia@mathface}{stix}{%
          \RequirePackage[notext,notextcomp]{stix2}
        }{%
          \IfStrEq{\celestia@mathface}{libertinus}{%
            \RequirePackage{libertinust1math}
            \@ifpackageloaded{XCharter}{\let\thdefault\@undefined}{}
          }{%
            \IfStrEq{\celestia@mathface}{iwona}{%
              \celestia@legacymath{iwona}{T1}%
            }{%
              \IfStrEq{\celestia@mathface}{kurier}{%
                \celestia@legacymath{kurier}{T1}%
              }{%
                \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

\newcommand{\celestia@seriesdefault}[4]{%
  \begingroup\fontencoding{T1}\fontfamily{#2}\try@load@fontshape\endgroup
  \ifcsname T1/#2/#4/n\endcsname\DeclareFontSeriesDefault[#1]{#3}{#4}\fi}
\ifcelestia@semibold
  \iftutex\else
    \AtBeginDocument{\celestia@seriesdefault{sf}{\sfdefault}{bf}{sb}}
    \AtBeginDocument{\celestia@seriesdefault{rm}{\rmdefault}{bf}{sb}}
  \fi
\fi

\ifcelestia@light
  \iftutex\else
    \AtBeginDocument{\celestia@seriesdefault{tt}{\ttdefault}{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}

\newcommand{\celestia@tstrut}{\vrule width\z@ height 0.772em depth 0.216em\relax}

\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,
}

\newcommand{\celestia@applyheadshape}{%
  \def\celestia@headshape@cmd{upshape}%
  \ifdefstring{\celestia@headshape}{sc}{\def\celestia@headshape@cmd{scshape}}{}%
  \ifdefstring{\celestia@headshape}{it}{\def\celestia@headshape@cmd{itshape}}{}%
}
\celestia@applyheadshape
\setbeamerfont{title}{size=\csname\celestia@titlesize\endcsname, family=\csname\celestia@headstyle\endcsname, series=\csname\celestia@titleweight\endcsname, shape=\csname\celestia@headshape@cmd\endcsname, parent=structure}
\setbeamerfont{subject}{size=\footnotesize}
\setbeamerfont{subtitle}{series=\mdseries, size=\csname\celestia@subtitlesize\endcsname}
\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, shape=\csname\celestia@headshape@cmd\endcsname, parent=structure}
\setbeamerfont{framesubtitle}{size=\small, series=\mdseries, parent=structure}

\setbeamerfont{section title}{size=\csname\celestia@sectiontitlesize\endcsname, family=\csname\celestia@headstyle\endcsname, series=\csname\celestia@titleweight\endcsname, shape=\csname\celestia@headshape@cmd\endcsname, parent=structure}
\setbeamerfont{subsection title}{size=\LARGE, family=\csname\celestia@headstyle\endcsname, series=\csname\celestia@titleweight\endcsname, shape=\csname\celestia@headshape@cmd\endcsname, 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=main!65!background}
\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{\celestia@textmark}[3]{%
  \iftutex
    \iffontchar\font"#1\relax\scalebox{1.15}{\char"#1\relax}\else#3\fi
  \else
    {\fontencoding{TS1}\selectfont
     \iffontchar\font#2\relax\scalebox{1.15}{\char#2\relax}\else#3\fi}%
  \fi}
\newcommand{\celestiaCircle}{%
  \celestia@textmark{2022}{136}{\raisebox{0.1ex}{\scalebox{1.2}{$\bullet$}}}%
}
\newcommand{\celestiaSmallCircle}{%
  \celestia@textmark{25E6}{158}{\raisebox{0.2ex}{\scalebox{1}{$\circ$}}}%
}
\newcommand{\celestia@motif}[1]{%
  \begin{tikzpicture}[remember picture, overlay]
    \coordinate (celestia disc) at ([xshift=0.01\paperwidth, yshift=-0.025\paperheight]current page.south east);
    \ifstrequal{#1}{section}{%
      \ifcelestia@motif
        \fill[emphasistint] (current page.south west) rectangle (current page.north east);
        \fill[emphasistint!66!background] (celestia disc) circle (0.43\paperheight);
        \fill[emphasistint!33!background] (celestia disc) circle (0.365\paperheight);
        \fill[background] (celestia disc) circle (0.30\paperheight);
      \else
        \fill[decoration, opacity=0.03] (current page.south west) rectangle (current page.north east);
      \fi
    }{%
      \ifcelestia@motif
        \ifx\celestia@titlebackground\@empty
          \fill[emphasistint!33!background] (celestia disc) circle (0.43\paperheight);
          \fill[emphasistint!66!background] (celestia disc) circle (0.365\paperheight);
          \fill[emphasistint] (celestia disc) circle (0.30\paperheight);
        \fi
      \fi
    }%
  \end{tikzpicture}%
}
\newcommand{\celestia@rule}{%
  \tikz{\fill[main!22!background] (0,0) rectangle (0.75\textwidth,0.4pt);
    \ifdefstring{\celestia@titlealign}{center}{}{%
      \ifdefstring{\celestia@titlealign}{right}{%
        \fill[\celestia@decoration!60!background] (\dimexpr0.75\textwidth-2cm\relax,-0.2pt) rectangle (0.75\textwidth,0.6pt);
      }{%
        \fill[\celestia@decoration!60!background] (0,-0.2pt) rectangle (2cm,0.6pt);
      }}}%
}
\newcommand{\celestiaDiamond}{%
  \tikz[baseline={(0,-0.58ex)}]\draw[line width=0.42pt, line join=miter] (0,0) -- (0.19em,0.19em) -- (0.38em,0) -- (0.19em,-0.19em) -- cycle;%
}

\newcommand{\celestia@applycolors}{%
  \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
  \ifx\celestia@tints\@empty
    \colorlet{blockcolortint}{main!9!background}%
    \colorlet{examplecolortint}{main!9!background}%
    \colorlet{alertcolortint}{alertcolor!9!background}%
    \colorlet{maintint}{main!9!background}%
    \colorlet{accenttint}{main!9!background}%
  \else
    \expandafter\celestia@define@tints\celestia@tints
  \fi
  \ifx\celestia@accentpair\@empty
    \colorlet{accenttext}{accent}%
    \colorlet{celestia@accenthue}{accent!9!background}%
  \else
    \expandafter\celestia@define@accent\celestia@accentpair
  \fi
  \ifx\celestia@remarkcolor\@empty
    \colorlet{remarkcolor}{main}%
  \else
    \definecolor{remarkcolor}{HTML}{\celestia@remarkcolor}%
  \fi
  \ifx\celestia@methodcolor\@empty
    \colorlet{methodcolor}{accent!70!main}%
  \else
    \definecolor{methodcolor}{HTML}{\celestia@methodcolor}%
  \fi
  \ifdefstring{\celestia@emphasis}{main}{%
    \colorlet{emphasis}{main}%
    \colorlet{emphasistint}{maintint}%
    \colorlet{decoration}{accent!80!main}%
  }{%
    \colorlet{emphasis}{accenttext}%
    \colorlet{emphasistint}{celestia@accenthue}%
    \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{remarkcolor}{emphasis}%
    \colorlet{methodcolor}{emphasis}%
    \colorlet{decoration}{emphasis}%
    \setbeamercolor{normal text}{fg=emphasis}%
  \else
    \setbeamercolor{normal text}{fg=main}%
  \fi
  \@for\celestia@tonerole:=blockcolor,examplecolor,alertcolor,remarkcolor,methodcolor\do{%
    \expandafter\ifx\csname celestia@tones@\celestia@tonerole\endcsname\@empty
      \edef\celestia@tmp{\noexpand\celestia@fallback@tones{\celestia@tonerole}}%
    \else
      \edef\celestia@tmp{\noexpand\celestia@define@tones{\celestia@tonerole}%
        \csname celestia@tones@\celestia@tonerole\endcsname}%
    \fi
    \celestia@tmp
  }%
  \ifcelestia@unicolor
    \celestia@fallback@tones{blockcolor}%
    \celestia@fallback@tones{examplecolor}%
    \celestia@fallback@tones{remarkcolor}%
    \celestia@fallback@tones{methodcolor}%
  \fi
  \colorlet{mainveil}{remarkcolorveil}%
  \colorlet{accentveil}{methodcolorveil}%
  \colorlet{mainband}{remarkcolorband}%
  \colorlet{accentband}{methodcolorband}%
  \colorlet{footlinecolor}{main!40!background}%
  \colorlet{accentink}{accent!70!main}%
  \extractcolorspec{background}\celestia@tmp
  \expandafter\convertcolorspec\celestia@tmp{gray}\celestia@tmp
  \ifdim\celestia@tmp pt<0.5pt
    \setbeamercolor{elegant frametitle}{bg=emphasis!16!background,fg=emphasis}%
    \colorlet{celestia@barbg}{emphasis!16!background}%
    \colorlet{celestia@barfg}{emphasis}%
    \colorlet{celestia@bardot}{emphasis!45!background}%
    \def\celestia@solidband##1{##1band}%
    \def\celestia@solidtext##1{##1ink}%
  \else
    \setbeamercolor{elegant frametitle}{bg=emphasis,fg=background}%
    \colorlet{celestia@barbg}{emphasis}%
    \colorlet{celestia@barfg}{background}%
    \colorlet{celestia@bardot}{background}%
    \def\celestia@solidband##1{##1}%
    \def\celestia@solidtext##1{background}%
  \fi
}
\celestia@applycolors
\setbeamercolor{alerted text}{fg=alertcolor}
\setbeamercolor{example text}{fg=examplecolor}
\setbeamercolor{structure}{fg=main}

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

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

\setbeamercolor{subtitle}{fg=main!80!background}
\setbeamercolor{subject}{fg=\celestia@decoration!80!main}
\setbeamercolor{author}{fg=main}
\setbeamercolor{institute}{fg=main!78!background}
\setbeamercolor{date}{fg=main!70!background}

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

\setbeamercolor{description item}{fg=emphasis}
\newcommand{\celestia@desclabelwidth}{5em}
\def\@@description{%
  \usebeamerfont{description body}%
  \usebeamercolor[fg]{description body}%
  \usebeamertemplate{description body begin}%
  \list
  {}
  {\setlength\labelwidth{\celestia@desclabelwidth}%
   \setlength\leftmargin{\dimexpr\celestia@desclabelwidth+\labelsep\relax}%
   \setlength\itemindent{\z@}%
   \let\makelabel\beamer@descriptionitem}%
  \beamer@cramped%
  \raggedright%
  \beamer@firstlineitemizeunskip%
}
\long\def\beamer@descriptionitem#1{%
  \GetTitleString{#1}%
  \let\@currentlabelname\GetTitleStringResult
  \def\insertdescriptionitem{#1}%
  {\usebeamerfont*{description item}%
   \usebeamercolor[fg]{description item}%
   \insertdescriptionitem}\hfil%
}

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

\newcommand{\celestia@applycodecolors}{%
  \ifx\celestia@codebackgroundcolor\@empty
    \colorlet{codebackground}{main!8!background}%
    \colorlet{celestia@codetint}{maintint}%
    \colorlet{celestia@codesoft}{maintint!50!background}%
  \else
    \definecolor{codebackground}{HTML}{\celestia@codebackgroundcolor}%
    \colorlet{celestia@codetint}{codebackground}%
    \colorlet{celestia@codesoft}{codebackground}%
  \fi
  \colorlet{codeKeyword}{blockcolor}%
  \colorlet{codeComment}{blockcolor!60!background}%
  \colorlet{codeString}{examplecolor}%
  \colorlet{codeIdentifier}{main}%
}
\AtEndPreamble{%
  \AtBeginDocument{%
    \celestia@applycodecolors
  }%
}

\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}{%
  \usebeamerfont*{enumerate item}\textcolor{\celestia@decoration}{\insertenumlabel.}}
\setbeamertemplate{enumerate subitem}{%
  \usebeamerfont*{enumerate subitem}\textcolor{\celestia@decoration}{\alph{enumii}.}}
\setbeamertemplate{enumerate subsubitem}{%
  \usebeamerfont*{enumerate subsubitem}\textcolor{\celestia@decoration}{\insertsubsubenumlabel.}}

\newcounter{quizchoice}
\newenvironment{quiz}{%
  \setcounter{quizchoice}{0}%
  \begin{list}{%
      \stepcounter{quizchoice}%
      {\color{\celestia@decoration}\bfseries\Alph{quizchoice}.}%
    }{%
      \setlength{\leftmargin}{\leftmargini}%
      \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}%
}

\ifdefstring{\celestia@codehandler}{minted}{%
  \newcommand{\celestia@verb}{\mintinline[fontsize=\footnotesize]{latex}}%
}{%
  \newcommand{\celestia@verb}{%
    \lstinline[style=latex,basicstyle=\ttfamily\footnotesize\color{main},keywordstyle=\color{main}\bfseries]%
  }%
}
\newcommand{\cverb}{\celestia@verb}

\hypersetup{colorlinks=true, linkcolor=., urlcolor=blockcolor}

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

\def\celestia@toc@max{0}
\def\celestia@toc@numwidth{\ifnum\celestia@toc@max>9 2.15em\else 1.6em\fi}
\AtEndDocument{%
  \ifnum\c@section>\celestia@toc@max\relax\xdef\celestia@toc@max{\the\c@section}\fi
  \immediate\write\@auxout{\string\gdef\string\celestia@toc@max{\celestia@toc@max}}%
}
\setbeamertemplate{section in toc}{%
  \leavevmode%
  \ifnum\inserttocsectionnumber>\celestia@toc@max\relax\xdef\celestia@toc@max{\inserttocsectionnumber}\fi
  \hbox to \celestia@toc@numwidth{\color{\celestia@decoration}\bfseries\inserttocsectionnumber.\hfil}%
  \hypersetup{linkcolor=main}%
  {\usebeamerfont{section in toc}\usebeamercolor[fg]{section in toc}\inserttocsection}\par%
}

\setbeamertemplate{subsection in toc}{%
  \leavevmode\leftskip=\celestia@toc@numwidth\relax
  \hbox to \dimexpr\celestia@toc@numwidth+0.6em\relax{\color{main!55!background}\inserttocsectionnumber.\inserttocsubsectionnumber\hfil}%
  \hypersetup{linkcolor=main!80!background}%
  {\usebeamerfont{subsection in toc}\usebeamercolor[fg]{subsection in toc}\inserttocsubsection}\par%
}

\ifcelestia@compacttoc
  \newcommand{\celestia@tocskip}{\vskip\itemsep}
\else
  \newcommand{\celestia@tocskip}{\vskip 0.9em minus 0.9em}
\fi
\patchcmd{\beamer@sectionintoc}
  {\vfill}
  {\celestia@tocskip}
  {}
  {\PackageWarning{celestia}{Could not adapt the table of contents}}
\newcommand{\celestia@tochidskip}{\vskip1.5em}
\patchcmd{\beamer@sectionintoc}
  {\vskip1.5em}
  {\celestia@tochidskip}
  {}
  {\PackageWarning{celestia}{Could not adapt the table of contents}}

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

% Frametitles

\newlength{\celestia@ft@left@margin}
\setlength{\celestia@ft@left@margin}{2em}
\newlength{\celestia@ft@barx}
\newlength{\celestia@ft@bary}
\newsavebox{\celestia@ft@box}
\newsavebox{\celestia@ft@boxtop}

\newcommand{\celestia@ft@strut}{\vrule width\z@ height 0.947em depth 0.216em\relax}
\newcommand{\celestia@ft@title}{%
  \celestia@ft@strut\begingroup\hypersetup{hidelinks}\insertframetitle\endgroup\celestia@ft@strut}
\newcommand{\celestia@ft@subtitle}{\insertframesubtitle\vrule width\z@ depth 0.216em\relax}
\newlength{\celestia@ft@delta}
\newcommand{\celestia@ft@up}{%
  \par{\usebeamerfont{frametitle}\global\celestia@ft@delta=0.2195em}%
  \nointerlineskip\vskip-\celestia@ft@delta\leavevmode}
\newcommand{\celestia@ft@down}{%
  \ifx\insertframesubtitle\@empty
    {\usebeamerfont{frametitle}\vskip-0.216em}%
  \else
    {\usebeamerfont{framesubtitle}\vskip-0.216em}%
  \fi}

\def\celestia@ftsep#1{\ifx\celestia@frametitlepadding\@empty#1\else\celestia@frametitlepadding\fi}
\def\celestia@ftvskip#1{\ifx\celestia@frametitlebottomskip\@empty#1\else\celestia@frametitlebottomskip\fi}

\defbeamertemplate{frametitle}{clean}{%
  \setlength{\celestia@ft@left@margin}{\dimexpr\beamer@leftmargin+0.5em\relax}%
  \setlength{\celestia@ft@bary}{\celestia@ftsep{1.5em}}%
  \addtolength{\celestia@ft@bary}{-0.425em}%
  \ifx\celestia@frametitlepadding\@empty
    \setlength{\celestia@ft@barx}{\dimexpr\celestia@ft@left@margin-0.5em\relax}%
  \else
    \setlength{\celestia@ft@barx}{\dimexpr\celestia@ft@left@margin-0.5em\relax}%
    \addtolength{\celestia@ft@barx}{\celestia@frametitlepadding}%
    \divide\celestia@ft@barx by 2%
  \fi
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\celestia@ft@left@margin-0.5em,
    rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{1.5em}\relax plus 1fil,
    sep=\celestia@ftsep{1.5em}]{frametitle}
    \setbox\celestia@ft@box\vbox{%
      \hsize\dimexpr\hsize-\leftskip-\rightskip\relax
      \leftskip\z@
      \rightskip\z@ plus 1fil\relax
      {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70!background}\celestia@ft@subtitle}%
      \fi%
      \par
    }%
    \setbox\celestia@ft@boxtop\vtop{\unvcopy\celestia@ft@box}%
    \celestia@ft@up
    \rlap{\smash{\kern\dimexpr\celestia@ft@barx-\leftskip\relax
      \color{emphasis}\vrule width 0.3em
        height\dimexpr\ht\celestia@ft@boxtop+0.425em-\celestia@ft@delta\relax
        depth\dimexpr\ht\celestia@ft@box-\ht\celestia@ft@boxtop+0.5em\relax}}%
    \vtop{\unvbox\celestia@ft@box}%
    \par\celestia@ft@down
  \end{beamercolorbox}%
  \ifx\celestia@frametitlebottomskip\@empty
    \ifx\insertframesubtitle\@empty
      \vskip-1em%
    \else
      \vskip-0.5em%
    \fi
  \else
    \vskip\celestia@frametitlebottomskip%
  \fi
}

\defbeamertemplate{frametitle}{elegant}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{0.75em}\relax,
    rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{0.75em}\relax plus 1fil,
    sep=\celestia@ftsep{0.75em}]{elegant frametitle}
    \celestia@ft@up
    \usebeamerfont{frametitle}\mdseries\celestia@ft@title%
    \ifx\insertframesubtitle\@empty\else%
      \par{\usebeamerfont{framesubtitle}\celestia@ft@subtitle}%
    \fi%
    \par\celestia@ft@down
  \end{beamercolorbox}%
}

\defbeamertemplate{frametitle}{plain}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.35em}\relax,
    sep=\celestia@ftsep{1.35em}]{frametitle}
    \celestia@ft@up
    \parbox[t]{\textwidth}{
        {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
        \ifx\insertframesubtitle\@empty\else%
            \par{\usebeamerfont{framesubtitle}\color{main!70!background}\celestia@ft@subtitle}%
        \fi%
    }
    \par\celestia@ft@down
  \end{beamercolorbox}%
  \vskip\celestia@ftvskip{-1em}%
}

\defbeamertemplate{frametitle}{cosmic}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.35em}\relax,
    sep=\celestia@ftsep{1.35em}]{frametitle}
    \celestia@ft@up
    \parbox[t]{\textwidth}{%
      {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70!background}\insertframesubtitle}%
      \fi%

      \ifx\celestia@frametitlepadding\@empty\else
        \setlength{\@tempdima}{\celestia@frametitlepadding}%
        \vspace*{\dimexpr0.6\@tempdima-0.8em\relax}%
      \fi%
      \tikz[remember picture, overlay] \coordinate (anchorY);
    }
    \begin{tikzpicture}[remember picture, overlay]
      \coordinate (L) at (current page.north west |- anchorY);
      \coordinate (R) at ([xshift=-\beamer@rightmargin]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\celestia@ftvskip{-1em}%
}

\defbeamertemplate{frametitle}{line}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.35em}\relax,
    sep=\celestia@ftsep{1.35em}]{frametitle}
    \celestia@ft@up
    \parbox[t]{\textwidth}{%
      {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70!background}\insertframesubtitle}%
      \fi%

      \ifx\celestia@frametitlepadding\@empty\else
        \setlength{\@tempdima}{\celestia@frametitlepadding}%
        \vspace*{\dimexpr0.6\@tempdima-0.8em\relax}%
      \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\celestia@ftvskip{-1em}%
}

\defbeamertemplate{frametitle}{subtle}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.35em}\relax,
    rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{1.35em}\relax plus 1fil,
    sep=\celestia@ftsep{1.35em}]{frametitle}
    \celestia@ft@up
    {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}\par%
    \ifx\insertframesubtitle\@empty\else%
      {\usebeamerfont{framesubtitle}\color{main!70!background}\insertframesubtitle\par}%
    \fi%
    \ifx\celestia@frametitlepadding\@empty
    \else
      \setlength{\@tempdima}{\celestia@frametitlepadding}%
      \vspace*{\dimexpr0.5\@tempdima-0.875em\relax}%
    \fi
    \tikz{\draw[\celestia@decoration!60!background, line width=0.8pt, line cap=round] (0,0) -- (2cm,0);}
  \end{beamercolorbox}%
  \vskip\celestia@ftvskip{-1em}%
}

\defbeamertemplate{frametitle}{plainrule}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.35em}\relax,
    rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{1.35em}\relax plus 1fil,
    sep=\celestia@ftsep{1.35em}]{frametitle}
    \celestia@ft@up
    {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
    \ifx\insertframesubtitle\@empty\else%
      \par{\usebeamerfont{framesubtitle}\color{main!70!background}\insertframesubtitle}%
    \fi%
    \par\vspace*{-0.25em}%
    \begin{tikzpicture}[remember picture, overlay]
      \fill[main!25!background]
        ([xshift=\beamer@leftmargin]current page.west |- 0, 0) rectangle
        ([xshift=-\beamer@rightmargin]current page.east |- 0, 0.4pt);
    \end{tikzpicture}
  \end{beamercolorbox}%
  \vskip\celestia@ftvskip{-1em}%
}

\defbeamertemplate{frametitle}{ruled}{%
  \nointerlineskip%
  \begin{beamercolorbox}[wd=\paperwidth,
    leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.35em}\relax,
    rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{1.35em}\relax plus 1fil,
    sep=\celestia@ftsep{1.35em}]{frametitle}
    \celestia@ft@up
    {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
    \ifx\insertframesubtitle\@empty\else%
      \par{\usebeamerfont{framesubtitle}\color{main!70!background}\insertframesubtitle}%
    \fi%
    \par\vspace*{-0.25em}%
    \begin{tikzpicture}[overlay]
      \fill[main!22!background] (0, 0) rectangle (\textwidth, 0.4pt);
      \fill[\celestia@decoration!60!background] (0, -0.2pt) rectangle (2cm, 0.6pt);
    \end{tikzpicture}
  \end{beamercolorbox}%
  \vskip\celestia@ftvskip{-1em}%
}

\defbeamertemplate{frametitle}{leftbar}{%
  \nointerlineskip
  \sbox{\@tempboxa}{%
    \begin{beamercolorbox}[wd=\paperwidth, sep=\celestia@ftsep{1.2em},
      leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{1.2em}\relax,
      rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{1.2em}\relax plus 1fil]{frametitle}
      \celestia@ft@up
      {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70!background}\celestia@ft@subtitle}%
      \fi%
      \par\celestia@ft@down
    \end{beamercolorbox}%
  }%
  \begin{tikzpicture}[remember picture, overlay]
    \fill[emphasis]
      (current page.north west) rectangle
      ([xshift=0.2cm, 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=\celestia@ftsep{0.85em},
      leftskip=\dimexpr\beamer@leftmargin-\celestia@ftsep{0.85em}\relax,
      rightskip=\dimexpr\beamer@rightmargin-\celestia@ftsep{0.85em}\relax plus 1fil]{frametitle}
      \celestia@ft@up
      {\usebeamerfont{frametitle}\color{emphasis}\celestia@ft@title}%
      \ifx\insertframesubtitle\@empty\else%
        \par{\usebeamerfont{framesubtitle}\color{main!70!background}\celestia@ft@subtitle}%
      \fi%
      \par\celestia@ft@down
    \end{beamercolorbox}%
  }%
  \makebox[\textwidth][l]{%
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle (\paperwidth, \dimexpr\ht\@tempboxa+\dp\@tempboxa\relax);
    \fill[accenttint]
      (-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)}

\newcommand{\celestia@framenumber}{%
  \ifbeamer@inappendix
    \ifdefined\appendixtotalframenumber\insertframenumber\else\insertframenumberinappendix\fi
  \else\insertframenumber\fi}
\newcommand{\celestia@pagecount}{%
  \ifbeamer@inappendix
    \ifdefined\appendixtotalframenumber
      \insertframenumber\,/\,\inserttotalframenumber
    \else
      \insertframenumberinappendix\,/\,\insertappendixframenumber
    \fi
  \else
    \insertframenumber\,/\,\insertmainframenumber
  \fi}
\def\celestia@titlepages{,}
\def\celestia@titlepages@new{,}
\newif\ifcelestia@ontitleframe
\AtBeginDocument{%
  \ifdefined\celestia@titlepages@aux
    \let\celestia@titlepages\celestia@titlepages@aux
  \fi}
\AtEndDocument{%
  \immediate\write\@auxout{%
    \string\gdef\string\celestia@titlepages@aux{\celestia@titlepages@new}}}

% Footline
\setbeamertemplate{footline}{%
  \IfSubStr{\celestia@titlepages}{,\the\c@page,}%
    {\celestia@ontitleframetrue}{\celestia@ontitleframefalse}%
  \ifcelestia@ontitleframe
    \setbox\z@\hbox{\celestia@footline@body}%
  \else
    \celestia@footline@body
  \fi
}
\newcommand{\celestia@footline@body}{%
    \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}

    \ifnum\insertmainframenumber>\z@
      \pgfmathsetmacro{\progress}{min(1, \insertframenumber/\insertmainframenumber)}%
    \else
      \def\progress{0}%
    \fi
    \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!15!background] (SW) rectangle ([yshift=1.5pt]SE);
          \fill[\celestia@decoration] (SW) rectangle ([yshift=1.5pt]$ (SW) + (\progress*\paperwidth, 0) $);
        \fi
        \node[anchor=south east, inner xsep=0pt, font=\usebeamerfont{footline text}]
        at ([xshift=-\beamer@rightmargin, yshift=2ex]SE) {
          \usebeamercolor[fg]{footline text}\celestia@framenumber};
      \end{tikzpicture}
      \vspace*{3ex}

    \else\ifx\celestia@footerstyle\celestia@fs@prestige
        \begin{tikzpicture}[remember picture, overlay]
          \foreach \x in {0.3, 0.7} {
            \node[anchor=base, inner sep=0pt, font=\usebeamerfont{footline text}]
              at ([xshift=\x*\paperwidth, yshift=2ex]SW) {\usebeamercolor[fg]{footline text}\textperiodcentered};
          }
        \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}%
            \celestia@pagecount
          \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}%
              \celestia@pagecount
            \end{beamercolorbox}%
          }%

        \else\ifx\celestia@footerstyle\celestia@fs@ruled
          \begin{tikzpicture}[remember picture, overlay]
            \node[anchor=base, inner sep=0pt] (ruled@author)
              at ([xshift=0.15\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor};
            \node[anchor=base, 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=base, inner sep=0pt] (ruled@page)
              at ([xshift=0.845\paperwidth, yshift=2ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \celestia@pagecount};
            \draw[footlinecolor, line width=0.4pt]
              ([xshift=\beamer@leftmargin, yshift=4.6ex]SW) -- ([xshift=-\beamer@rightmargin, yshift=4.6ex]SE);
          \end{tikzpicture}%
          \vspace*{4.75ex}

        \else\ifx\celestia@footerstyle\celestia@fs@boxed
          \begin{tikzpicture}[remember picture, overlay]
            \node[anchor=base, inner xsep=5pt, inner ysep=2pt, text height=1.45ex, text depth=0.45ex] (boxed@author)
              at ([xshift=0.15\paperwidth, yshift=3ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor};
            \node[anchor=base, inner xsep=5pt, inner ysep=2pt, text height=1.45ex, text depth=0.45ex] (boxed@title)
              at ([xshift=0.495\paperwidth, yshift=3ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup};
            \node[anchor=base, inner xsep=5pt, inner ysep=2pt, text height=1.45ex, text depth=0.45ex,
              fill=maintint, rounded corners=1pt] (boxed@page)
              at ([xshift=0.845\paperwidth, yshift=3ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \celestia@pagecount};
          \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=base, inner xsep=5pt, inner ysep=2pt, text height=1.45ex, text depth=0.45ex] (boxedruled@author)
              at ([xshift=0.15\paperwidth, yshift=3ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}\insertshortauthor};
            \node[anchor=base, inner xsep=5pt, inner ysep=2pt, text height=1.45ex, text depth=0.45ex] (boxedruled@title)
              at ([xshift=0.495\paperwidth, yshift=3ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup};
            \node[anchor=base, inner xsep=5pt, inner ysep=2pt, text height=1.45ex, text depth=0.45ex,
              fill=maintint, rounded corners=1pt] (boxedruled@page)
              at ([xshift=0.845\paperwidth, yshift=3ex]SW)
              {\usebeamerfont{footline text}\usebeamercolor[fg]{footline text}%
               \celestia@pagecount};
            \draw[footlinecolor, line width=0.4pt]
              ([xshift=\beamer@leftmargin, yshift=5.6ex]SW) -- ([xshift=-\beamer@rightmargin, yshift=5.6ex]SE);
          \end{tikzpicture}%
          \vspace*{6ex}

        \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}%
              \celestia@pagecount
            \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}\insertshortauthor%
              \end{beamercolorbox}%
              \begin{beamercolorbox}[wd=.4\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current title}%
                \usebeamerfont{footline text}{\hypersetup{linkcolor=.}\insertshorttitle}%
              \end{beamercolorbox}%
              \begin{beamercolorbox}[wd=.2\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current date}%
                \usebeamerfont{footline text}\insertshortdate%
              \end{beamercolorbox}%
              \begin{beamercolorbox}[wd=.1\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current page}%
                \usebeamerfont{footline text}\celestia@pagecount%
              \end{beamercolorbox}%
            }%

          \else\ifx\celestia@footerstyle\celestia@fs@fullbar
              \setbeamercolor{current author}{bg=celestia@barbg,fg=celestia@barfg}
              \setbeamercolor{current title}{bg=celestia@barbg,fg=celestia@barfg}
              \setbeamercolor{current date}{bg=celestia@barbg,fg=celestia@barfg}
              \setbeamercolor{current page}{bg=celestia@barbg,fg=celestia@barfg}
              \hbox{%
                \begin{beamercolorbox}[wd=.3\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current author}%
                  \usebeamerfont{footline text}\insertshortauthor%
                \end{beamercolorbox}%
                \begin{beamercolorbox}[wd=.4\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current title}%
                  \usebeamerfont{footline text}{\hypersetup{linkcolor=.}\insertshorttitle}%
                \end{beamercolorbox}%
                \begin{beamercolorbox}[wd=.2\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current date}%
                  \usebeamerfont{footline text}\insertshortdate%
                \end{beamercolorbox}%
                \begin{beamercolorbox}[wd=.1\paperwidth,ht=3ex,dp=1.5ex,center,sep=-1ex]{current page}%
                  \usebeamerfont{footline text}\celestia@pagecount%
                \end{beamercolorbox}%
              }%
              \begin{tikzpicture}[remember picture, overlay]
                \foreach \x in {0.3, 0.7, 0.9} {
                  \fill[celestia@bardot] ([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=\usebeamerfont{footline text}\bfseries,
                  inner xsep=5pt, inner ysep=2.5pt, rounded corners=1.5pt]
                  at ([xshift=-\beamer@rightmargin, yshift=1.35em]SE)
                  {\celestia@pagecount};
                  \node[anchor=south west, inner xsep=0pt, font=\usebeamerfont{footline text}]
                  at ([xshift=\beamer@leftmargin, yshift=1.35em]SW)
                  {\usebeamercolor[fg]{footline text}%
                   \ifx\beamer@shortauthor\@empty\else\insertshortauthor\quad\textcolor{footlinecolor}{\textbar}\quad\fi
                   \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup};
                \end{tikzpicture}
                \vspace*{6ex}

              \else\ifx\celestia@footerstyle\celestia@fs@info
                  \begin{tikzpicture}[remember picture, overlay]
                    \ifcelestia@progressbar
                      \fill[\celestia@decoration!15!background] (SW) rectangle ([yshift=1.5pt]SE);
                      \fill[\celestia@decoration] (SW) rectangle ([yshift=1.5pt]$ (SW) + (\progress*\paperwidth, 0) $);
                    \fi
                    \node[anchor=south west, inner xsep=0pt, text=main!65!background, font=\usebeamerfont{footline text}]
                    at ([xshift=\beamer@leftmargin, yshift=1.2ex]SW) {
                      \ifx\beamer@shortauthor\@empty\else
                        \insertshortauthor \quad \textperiodcentered \quad
                      \fi
                      \begingroup\hypersetup{hidelinks}\insertshorttitle\endgroup
                    };
                    \node[anchor=south east, inner xsep=0pt, text=main!65!background, font=\usebeamerfont{footline text}]
                    at ([xshift=-\beamer@rightmargin, yshift=1.2ex]SE) {
                      \celestia@pagecount
                    };
                  \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!background] (SW) rectangle ([yshift=1.5pt]SE);
            \fill[\celestia@decoration] (SW) rectangle ([yshift=1.5pt]$ (SW) + (\progress*\paperwidth, 0) $);
          \end{tikzpicture}
        \fi
      \fi
    \fi
}

\newif\ifcelestia@framegroup
\newcommand{\celestia@framegroup}{%
  \ifcelestia@framegroup\else
    \begingroup
    \celestia@framegrouptrue
  \fi
}
\newcommand{\celestia@endframekey}{\def\KV@prefix{KV@beamerframe@}}
\pretocmd{\beamer@reseteecodes}{\ifcelestia@framegroup\endgroup\fi}{}{\PackageWarning{celestia}{Could not adapt the frame options}}
\newcommand{\celestia@standout@colors}{%
  \setbeamercolor{background canvas}{bg=main}%
  \setbeamercolor{normal text}{fg=background}%
  \setbeamercolor{structure}{fg=background}%
  \colorlet{emphasis}{background}%
  \colorlet{decoration}{background}%
  \def\celestia@decoration{background}%
  \usebeamercolor[fg]{normal text}%
}
\define@key{beamerframe}{c}[true]{%
  \beamer@frametopskip=0pt plus 1fill\relax
  \beamer@framebottomskip=0pt plus 2fill\relax
  \beamer@frametopskipautobreak=0pt plus .4\paperheight\relax
  \beamer@framebottomskipautobreak=0pt plus .6\paperheight\relax
}
\define@key{beamerframe}{standout}[true]{%
  \celestia@framegroup
  \celestia@standouttrue
  \setkeys{beamerframe}{c}%
  \beamer@framebottomskip=0pt plus 1.5fill\relax
  \setkeys{beamerframe}{noframenumbering}%
  \celestia@standout@colors
  \setbeamertemplate{frametitle}{}
  \setbeamertemplate{framesubtitle}{}
  \setbeamertemplate{footline}{}%
  \ifcelestia@motif
    \setbeamertemplate{background}{%
      \begin{tikzpicture}[remember picture, overlay]
        \coordinate (celestia disc) at ([xshift=0.01\paperwidth, yshift=-0.025\paperheight]current page.south east);
        \fill[main!96.5!background] (celestia disc) circle (0.43\paperheight);
        \fill[main!93!background] (celestia disc) circle (0.365\paperheight);
        \fill[main!90!background] (celestia disc) circle (0.30\paperheight);
      \end{tikzpicture}}%
  \fi
  \hypersetup{urlcolor=.}%
  \centering
  \usebeamerfont{frametitle}\huge
  \celestia@endframekey
}

% --- Title Page ---
\def\celestia@subject{}
\renewcommand{\subject}[1]{%
  \def\celestia@subject{#1}%
  \hypersetup{pdfsubject={#1}}%
}
\newcommand{\insertsubject}{\celestia@subject}
\newcommand{\celestia@caps}[1]{%
  \begingroup
  \iftutex
    \addfontfeatures{LetterSpace=8}%
  \else
    \ifdefined\letterspacefont
      \letterspacefont\celestia@lsfont\font 80\relax\celestia@lsfont
    \fi
  \fi
  \MakeUppercase{#1}%
  \endgroup
}

\setbeamertemplate{title page}{%
  \IfSubStr{\celestia@titlepages@new}{,\the\c@page,}{}{%
    \xdef\celestia@titlepages@new{\celestia@titlepages@new\the\c@page,}}%
  \celestia@motif{cover}%
  \vskip 0pt plus 1filll
  \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
  \ifx\inserttitlegraphic\@empty\else
    \ifdefstring{\celestia@titlealign}{center}{}{%
      \begin{tikzpicture}[remember picture, overlay]
        \node[anchor=north east, inner sep=0pt] at ([xshift=-\beamer@rightmargin, yshift=-2em]current page.north east) {\inserttitlegraphic};
      \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\inserttitlegraphic\@empty\else
    \ifdefstring{\celestia@titlealign}{center}{%
      {\centering\inserttitlegraphic\par}
      \vspace{\dimexpr1.2\baselineskip\relax}
    }{}
  \fi
  \ifx\celestia@subject\@empty\else
    {\usebeamercolor[fg]{subject}\usebeamerfont{subject}\celestia@caps{\celestia@subject}\par}
    \vspace{\dimexpr0.9\baselineskip\relax}
  \fi

  \begin{minipage}{0.75\textwidth}
    \ifx\celestia@titlealign\celestia@ta@center
      \centering
    \else\ifx\celestia@titlealign\celestia@ta@right
      \raggedleft
    \else
      \raggedright
    \fi\fi
    \hyphenpenalty=10000 \exhyphenpenalty=10000 \relax

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

    \ifx\insertsubtitle\@empty\else
      \vspace{\dimexpr0.6\baselineskip\relax}
      {\usebeamercolor[fg]{subtitle}\usebeamerfont{subtitle}\insertsubtitle\par}
    \fi
  \end{minipage}

  \setbox\z@\hbox{\insertauthor\insertinstitute\insertdate}%
  \ifdim\wd\z@>\z@
    \par\vspace{\dimexpr1.2\baselineskip\relax}
    \celestia@rule
    \par\vspace{\dimexpr1.2\baselineskip\relax}
  \fi

  {\usebeamercolor[fg]{author}\usebeamerfont{author}\insertauthor\par}
  \ifx\insertinstitute\@empty\else
    \vspace{\dimexpr0.35\baselineskip\relax}
    {\usebeamercolor[fg]{institute}\usebeamerfont{institute}\insertinstitute\par}
  \fi
  \ifx\insertdate\@empty\else
    \vspace{\dimexpr0.6\baselineskip\relax}
    {\usebeamercolor[fg]{date}\usebeamerfont{date}\insertdate\par}
  \fi

  \endgroup
  \vskip 0pt plus 2filll
}

% Section Page Template
\setbeamerfont{section number}{size=\csname\celestia@sectiontitlesize\endcsname, family=\csname\celestia@headstyle\endcsname, series=\mdseries}
\setbeamercolor{section number}{fg=\celestia@decoration}
\setbeamercolor{subsection title}{fg=main}
\setbeamerfont{subsection number}{size=\LARGE, family=\csname\celestia@headstyle\endcsname, series=\mdseries}
\setbeamercolor{subsection number}{fg=\celestia@decoration}
\newcommand{\celestia@sectionpage@begin}{%
  \celestia@motif{section}%
  \vskip 0pt plus 1filll
  \begingroup
  \leftskip=\dimexpr\celestia@margin-1em\relax
  \rightskip=\dimexpr\celestia@margin-1em\relax
  \ifdefstring{\celestia@titlealign}{center}{\centering}{\rightskip=0pt plus 1fil}%
  \hypersetup{hidelinks}%
  \hyphenpenalty=10000 \exhyphenpenalty=10000 \relax
}
\newcommand{\celestia@sectionpage@head}[4]{%
  \ifcelestia@sectionnumber
    \setbox\z@\hbox{\usebeamerfont{#1}\usebeamercolor[fg]{#1}#2\quad}%
    \ifdefstring{\celestia@titlealign}{center}{}{\hangindent=\wd\z@ \hangafter=1 }%
    \noindent\box\z@
  \else
    \noindent
  \fi
  {\usebeamerfont{#3}\usebeamercolor[fg]{#3}#4\par}%
}
\newcommand{\celestia@sectionpage@end}{%
  \endgroup
  \vskip 0pt plus 2filll
}
\newbox\celestia@planbox
\newdimen\celestia@plandim
\newdimen\celestia@planwidth
\newcount\celestia@plancount
\newif\ifcelestia@planlist
\newcommand{\celestia@sectionpage@overline}{%
  \setbox\z@\hbox{\beamer@shorttitle}%
  \ifdim\wd\z@>\z@
    {\usebeamerfont{subject}\usebeamercolor[fg]{subject}\celestia@caps{\beamer@shorttitle}\par}%
    \vspace{\dimexpr0.9\baselineskip\relax}%
  \fi
}
\newcommand{\celestia@plannum}[1]{\ifcelestia@sectionnumber\hbox to \celestia@planwidth{#1\hfil}\fi}
\newcommand{\celestia@plan@hang}{%
  \ifcelestia@sectionnumber
    \ifdefstring{\celestia@titlealign}{center}{}{\hangindent=\celestia@planwidth \hangafter=1 }%
  \fi
}
\newcommand{\celestia@plan@build}{%
  \setbox\celestia@planbox\hbox{\usebeamerfont{section number}%
    \ifnum\celestia@toc@max>19 00\else\ifnum\celestia@toc@max>9 10\else 0\fi\fi\kern0.3em}%
  \celestia@planwidth=\wd\celestia@planbox
  \global\celestia@plancount=0
  \setbox\celestia@planbox\vbox{%
    \offinterlineskip
    \def\celestia@tocskip{\vskip 0.15em plus 0.9em\relax}%
    \let\celestia@tochidskip\celestia@tocskip
    \setbeamertemplate{section in toc}{%
      \global\advance\celestia@plancount 1
      \@tempdima=0.3em
      \vskip0.55em
      \usebeamerfont{section title}\normalbaselines
      \celestia@plan@hang
      \noindent\strut
      \celestia@plannum{\usebeamerfont{section number}\usebeamercolor[fg]{section number}\inserttocsectionnumber}%
      {\usebeamercolor[fg]{section title}\inserttocsection}\par
      \vskip\@tempdima}%
    \setbeamertemplate{section in toc shaded}{%
      \global\advance\celestia@plancount 1
      \small\normalbaselines
      \celestia@plan@hang
      \noindent\strut
      \celestia@plannum{\color{main!45!background}\inserttocsectionnumber}%
      {\color{main!58!background}\inserttocsection}\par}%
    \vskip 0.35em plus -0.9em\relax
    \celestia@tableofcontents[currentsection,hideallsubsections]%
    \unskip
  }%
}
\newcommand{\celestia@plan@dots}{%
  \vspace{1.6\baselineskip}%
  \celestia@plandim=\dimexpr(\paperwidth-2\celestia@margin)/\celestia@toc@max\relax
  \ifdim\celestia@plandim>1.55em \celestia@plandim=1.55em\fi
  \edef\celestia@picserial{\the\pgf@picture@serial@count}%
  \noindent\hspace{0.1em}\begin{tikzpicture}[baseline=-0.6ex]
    \celestia@plancount=0
    \loop\ifnum\celestia@plancount<\celestia@toc@max\relax
      \advance\celestia@plancount 1
      \ifnum\celestia@plancount=\c@section
        \fill[emphasis] (\the\celestia@plancount*\celestia@plandim,0) circle (0.58em);
        \node[text=\ifcelestia@motif emphasistint\else background\fi, font=\ifnum\celestia@plancount>9 \scriptsize\else\footnotesize\fi\bfseries, inner sep=0pt]
          at (\the\celestia@plancount*\celestia@plandim,0) {\the\celestia@plancount};
      \else
        \ifnum\celestia@plancount<\c@section
          \fill[main!45!background] (\the\celestia@plancount*\celestia@plandim,0) circle (0.24em);
        \else
          \draw[main!45!background, line width=0.6pt] (\the\celestia@plancount*\celestia@plandim,0) circle (0.24em);
        \fi
      \fi
    \repeat
  \end{tikzpicture}\par
  \global\pgf@picture@serial@count=\celestia@picserial\relax
}
\setbeamertemplate{section page}{%
  \celestia@sectionpage@begin
  \celestia@planlistfalse
  \ifdefstring{\celestia@sectiontoc}{list}{\celestia@planlisttrue}{}%
  \ifdefstring{\celestia@sectiontoc}{true}{\celestia@planlisttrue}{}%
  \ifcelestia@planlist
    \celestia@plan@build
    \setbox\z@\vbox{\celestia@sectionpage@overline}%
    \celestia@plandim=\dimexpr0.8\paperheight-\ht\z@-\dp\z@-\dp\celestia@planbox\relax
    \ifnum\celestia@plancount<2 \celestia@planlistfalse\fi
    \ifdim\ht\celestia@planbox>\celestia@plandim \celestia@planlistfalse\fi
  \fi
  \celestia@sectionpage@overline
  \ifcelestia@planlist
    \@tempdima=\dimexpr\ht\celestia@planbox+0.9em*\numexpr\celestia@plancount-1\relax\relax
    \ifdim\@tempdima>\celestia@plandim \@tempdima=\celestia@plandim\fi
    \nointerlineskip
    \vbox to \@tempdima{\unvbox\celestia@planbox}%
  \else
    \celestia@sectionpage@head{section number}{\thesection}{section title}{\insertsectionhead}%
    \ifdefstring{\celestia@sectiontoc}{false}{}{\ifnum\celestia@toc@max>1 \celestia@plan@dots\fi}%
  \fi
  \celestia@sectionpage@end
}
\setbeamertemplate{subsection page}{%
  \celestia@sectionpage@begin
  {\usebeamerfont{subject}\usebeamercolor[fg]{subject}\celestia@caps{\insertsection}\par}%
  \vspace{\dimexpr0.9\baselineskip\relax}%
  \celestia@sectionpage@head{subsection number}{\insertsectionnumber.\insertsubsectionnumber}{subsection title}{\insertsubsectionhead}%
  \celestia@sectionpage@end
}

\newcommand{\celestia@installsectionpage}{%
  \AtBeginSection{%
    \ifcelestia@sectionpage
      \expandafter\@firstofone
    \else
      \expandafter\@gobble
    \fi
    {\begin{frame}[plain,noframenumbering]
      \sectionpage
    \end{frame}}%
  }%
}
\newcommand{\celestia@installsubsectionpage}{%
  \AtBeginSubsection{%
    \ifcelestia@subsectionpage
      \expandafter\@firstofone
    \else
      \expandafter\@gobble
    \fi
    {\begin{frame}[plain,noframenumbering]
      \subsectionpage
    \end{frame}}%
  }%
}
\ifcelestia@sectionpage
  \celestia@installsectionpage
\fi
\ifcelestia@subsectionpage
  \celestia@installsubsectionpage
\fi

\def\celestia@valid@designs{,fullbar,bar,ribbon,line,sober,soft,shaded,noback,plain,card,ruled,underline,discs,framed,outline,callout,mast,masthead,mastbox,bracket,legend,legendbox,badge,softbadge,}
\edef\celestia@valid@blocks{,roles,native,native-shadow,native-default\celestia@valid@designs}
\expandafter\IfSubStr\expandafter{\celestia@valid@blocks}{,\celestia@block,}{}{%
  \PackageWarning{celestia}{Unknown block style: \celestia@block}%
  \def\celestia@block{roles}%
}
\newif\ifcelestia@usenativeblocks
\IfSubStr{\celestia@block}{native}{\celestia@usenativeblockstrue}{\celestia@usenativeblocksfalse}
\IfSubStr{,false,true,list,dots,}{,\celestia@sectiontoc,}{}{%
  \PackageWarning{celestia}{Unknown value for sectiontoc: \celestia@sectiontoc}%
  \def\celestia@sectiontoc{false}%
}
\IfSubStr{,auto,true,false,}{,\celestia@codenumbers,}{}{%
  \PackageWarning{celestia}{Unknown value for codenumbers: \celestia@codenumbers}%
  \def\celestia@codenumbers{auto}%
}
\IfSubStr{,soft,minimal,hairline,tint,bar,frame,macos,box,}{,\celestia@codestyle,}{}{%
  \PackageWarning{celestia}{Unknown code style: \celestia@codestyle}%
  \def\celestia@codestyle{soft}%
}
\newif\ifcelestia@codenumbers
\newif\ifcelestia@codenumauto
\newif\ifcelestia@numhere
\newif\ifcelestia@numthis
\newif\ifcelestia@inbox
\newif\ifcelestia@codeflush
\newif\ifcelestia@numnest
\newif\ifcelestia@inminted
\newif\ifcelestia@nonum
\newif\ifcelestia@yesnum
\let\celestia@hairnow\@empty
\def\celestia@codehair{accent!38!background}
\newcount\celestia@lstid
\newdimen\celestia@numcolw
\newcommand{\celestia@lstdigits}[2]{\expandafter\xdef\csname celestia@lstd@#1\endcsname{#2}}
\AtEndDocument{\def\celestia@lstdigits#1#2{\edef\celestia@tmp{#2}\expandafter\ifx\csname celestia@lstd@#1\endcsname\celestia@tmp\else\global\@tempswatrue\fi}}
\newcommand{\celestia@sync@codenumbers}{%
  \celestia@codenumbersfalse
  \celestia@codenumautofalse
  \ifdefstring{\celestia@codenumbers}{true}{\celestia@codenumberstrue}{}%
  \ifdefstring{\celestia@codenumbers}{auto}{\celestia@codenumautotrue}{}%
}
\celestia@sync@codenumbers
\IfSubStr{,auto,true,false,}{,\celestia@blockfill,}{}{%
  \PackageWarning{celestia}{Unknown value for blockfill: \celestia@blockfill}%
  \def\celestia@blockfill{auto}%
}
\IfSubStr{,auto,rounded,sharp,}{,\celestia@blockcorners,}{}{%
  \PackageWarning{celestia}{Unknown value for blockcorners: \celestia@blockcorners}%
  \def\celestia@blockcorners{auto}%
}
\newif\ifcelestia@blockfilled
\newif\ifcelestia@blockrounded
\newcommand{\celestia@resolvedesign}{%
  \edef\celestia@blockeff{\celestia@fam@name}%
  \celestia@blockfilledtrue
  \ifdefstring{\celestia@fam@fill}{true}{%
    \ifdefstring{\celestia@fam@name}{line}{\def\celestia@blockeff{bar}}{}%
    \ifdefstring{\celestia@fam@name}{ribbon}{\def\celestia@blockeff{fullbar}}{}%
    \ifdefstring{\celestia@fam@name}{noback}{\def\celestia@blockeff{soft}}{}%
  }{}%
  \ifdefstring{\celestia@fam@fill}{false}{%
    \celestia@blockfilledfalse
    \ifdefstring{\celestia@fam@name}{bar}{\def\celestia@blockeff{line}}{}%
    \ifdefstring{\celestia@fam@name}{fullbar}{\def\celestia@blockeff{ribbon}}{}%
    \ifdefstring{\celestia@fam@name}{soft}{\def\celestia@blockeff{noback}}{}%
    \ifdefstring{\celestia@fam@name}{sober}{\def\celestia@blockeff{noback}}{}%
    \ifdefstring{\celestia@fam@name}{discs}{\celestia@blockfilledtrue}{}%
  }{}%
  \ifdefstring{\celestia@fam@fill}{auto}{%
    \IfSubStr{,framed,plain,outline,}{,\celestia@fam@name,}{\celestia@blockfilledfalse}{}%
  }{}%
  \IfSubStr{,mast,masthead,mastbox,bracket,legend,legendbox,}{,\celestia@fam@name,}{\celestia@blockfilledfalse}{}%
  \celestia@blockroundedfalse
  \ifdefstring{\celestia@fam@name}{plain}{\celestia@blockroundedtrue}{}%
  \ifdefstring{\celestia@fam@corners}{rounded}{\celestia@blockroundedtrue}{}%
  \ifdefstring{\celestia@fam@corners}{sharp}{\celestia@blockroundedfalse}{}%
}
\def\celestia@families{standard,theorem,definition,proof,example,nativeexample,remark,method,activity,exercise,alert,summary}
\newcommand{\celestia@deffamily}[4]{%
  \@namedef{celestia@famkey@#1}{#2}%
  \@namedef{celestia@famcolor@#1}{#3}%
  \@namedef{celestia@role@#1}{#4}%
}
\celestia@deffamily{standard}{celestia@blockstyle}{blockcolor}{framed}
\celestia@deffamily{theorem}{celestia@theoremstyle}{blockcolor}{callout}
\celestia@deffamily{definition}{celestia@definitionstyle}{examplecolor}{callout}
\celestia@deffamily{proof}{celestia@proofstyle}{blockcolor}{mast}
\celestia@deffamily{example}{celestia@exstyle}{examplecolor}{mast}
\celestia@deffamily{nativeexample}{celestia@exblockstyle}{examplecolor}{framed}
\celestia@deffamily{remark}{celestia@remarkstyle}{remarkcolor}{mast}
\celestia@deffamily{method}{celestia@methodstyle}{methodcolor}{callout}
\celestia@deffamily{activity}{celestia@activitystyle}{methodcolor}{mast}
\celestia@deffamily{exercise}{celestia@exercisestyle}{methodcolor}{ruled,nofill}
\celestia@deffamily{alert}{celestia@alertstyle}{alertcolor}{framed}
\celestia@deffamily{summary}{celestia@summarystyle}{blockcolor}{card}
\newcommand{\celestia@fam@word}[1]{%
  \StrDel{\celestia@fam@item}{ }[\celestia@fam@item]%
  \ifdefstring{\celestia@fam@item}{}{}{%
  \ifdefstring{\celestia@fam@item}{auto}{}{%
  \ifdefstring{\celestia@fam@item}{fill}{\def\celestia@fam@fill{true}}{%
  \ifdefstring{\celestia@fam@item}{nofill}{\def\celestia@fam@fill{false}}{%
  \ifdefstring{\celestia@fam@item}{rounded}{\def\celestia@fam@corners{rounded}}{%
  \ifdefstring{\celestia@fam@item}{sharp}{\def\celestia@fam@corners{sharp}}{%
  \expandafter\IfSubStr\expandafter{\celestia@valid@designs}{,\celestia@fam@item,}{%
    \let\celestia@fam@name\celestia@fam@item
  }{%
    \celestia@fam@warning{#1}%
  }}}}}}}%
}
\newcommand{\celestia@fam@warning}[1]{%
  \PackageWarning{celestia}{Unknown value for #1block: \celestia@fam@item}}
\newcommand{\celestia@fam@words}[2]{%
  \edef\celestia@fam@spec{#2}%
  \ifx\celestia@fam@spec\@empty\else
    \expandafter\@for\expandafter\celestia@fam@item\expandafter:\expandafter=\celestia@fam@spec\do{%
      \celestia@fam@word{#1}}%
  \fi
}
\newcommand{\celestia@readfamily}[1]{%
  \let\celestia@fam@fill\celestia@blockfill
  \let\celestia@fam@corners\celestia@blockcorners
  \let\celestia@fam@name\@empty
  \celestia@fam@words{#1}{\csname celestia@#1block\endcsname}%
  \ifx\celestia@fam@name\@empty
    \ifdefstring{\celestia@block}{roles}{%
      \let\celestia@fam@setfill\celestia@fam@fill
      \let\celestia@fam@setcorners\celestia@fam@corners
      \celestia@fam@words{#1}{\csname celestia@role@#1\endcsname}%
      \ifdefstring{\celestia@fam@setfill}{auto}{}{\let\celestia@fam@fill\celestia@fam@setfill}%
      \ifdefstring{\celestia@fam@setcorners}{auto}{}{\let\celestia@fam@corners\celestia@fam@setcorners}%
    }{%
      \let\celestia@fam@name\celestia@block
    }%
  \fi
}

%% Theorem Settings

\ifdefstring{\celestia@block}{native-shadow}{
  \setbeamertemplate{blocks}[rounded][shadow=true]
}{}

\ifdefstring{\celestia@block}{native-default}{
  \setbeamertemplate{blocks}[default]
  \setbeamertemplate{block begin}{%
    \par\vskip\medskipamount
    \ifx\insertblocktitle\@empty\else
      \begin{beamercolorbox}[colsep*=.75ex]{block title}
        \usebeamerfont*{block title}\insertblocktitle
      \end{beamercolorbox}\noframebreak
      {\parskip0pt\par}%
      \ifbeamercolorempty[bg]{block title}{}{%
        \ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
    \fi
    \usebeamerfont{block body}%
    \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}%
      \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
  }
}{}

\ExplSyntaxOn
\tl_new:N \l__celestia_native_title_tl
\cs_new_protected:Npn \celestia@native@keys #1
  {
    \tl_clear:N \l__celestia_native_title_tl
    \keyval_parse:nnn { \use_none:n } { \__celestia_native_key:nn } { #1 }
    \tl_if_empty:NF \l__celestia_native_title_tl { \nobreakspace ( \tl_use:N \l__celestia_native_title_tl ) }
  }
\cs_new_protected:Npn \__celestia_native_key:nn #1#2
  { \str_if_eq:nnT { #1 } { title } { \tl_set:Nn \l__celestia_native_title_tl { #2 } } }
\ExplSyntaxOff

\ifcelestia@usenativeblocks
  \setbeamercolor{block title}{bg=blockcolor!85!background, fg=background}
  \setbeamercolor{block body}{bg=blockcolorveil, fg=main}
  \setbeamercolor{block title example}{bg=examplecolor!85!background, fg=background}
  \setbeamercolor{block body example}{bg=examplecolorveil, fg=main}
  \setbeamercolor{block title alerted}{bg=alertcolor!85!background, fg=background}
  \setbeamercolor{block body alerted}{bg=alertcolorveil, 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}
  \@for\celestia@fam@loop:=\celestia@families\do{%
    \edef\celestia@tmp{\csname celestia@\celestia@fam@loop block\endcsname}%
    \ifx\celestia@tmp\@empty\else
      \ifdefstring{\celestia@tmp}{auto}{}{%
        \PackageWarning{celestia}{With native blocks, option \celestia@fam@loop block\MessageBreak
          is ignored}}%
    \fi}%
  \AtEndPreamble{%
    \ifdefstring{\celestia@language}{french}{%
      \uselanguage{French}\languagepath{French}%
    }{}%
  }%
  \newcommand{\celestia@native@addition}[1]{%
    \if\relax\detokenize{#1}\relax\else
      \IfSubStr{#1}{title=}{\celestia@native@keys{#1}}{%
        \IfSubStr{#1}{label=}{\celestia@native@keys{#1}}{~(#1)}}%
    \fi}
  \setbeamertemplate{proof begin}{\begin{block}{\let\@addpunct\@gobble\insertproofname}}
  \setbeamertemplate{theorem begin}{%
    \normalfont
    \begin{\inserttheoremblockenv}{%
      \inserttheoremname
      \expandafter\celestia@native@addition\expandafter{\inserttheoremaddition}}%
  }
  \newcommand{\celestia@native@env}[1]{%
    \celestia@native@defenv{#1}{#1}\celestia@native@defenv{#1*}{#1}}
  \newcommand{\celestia@native@defenv}[2]{%
    \DeclareDocumentEnvironment{#1}{d<>O{}}{%
      \IfValueT{##1}{\begin{actionenv}<##1>}%
      \begin{block}{\csname celestia@name@#2\endcsname\celestia@native@addition{##2}}}{%
      \end{block}\IfValueT{##1}{\end{actionenv}}}}
  \@for\celestia@env@loop:=property,properties,proposition,method,remark,remarks,activity,activities,application,applications,summary\do{%
    \expandafter\let\csname\celestia@env@loop\endcsname\relax
    \expandafter\let\csname end\celestia@env@loop\endcsname\relax
    \expandafter\celestia@native@env\expandafter{\celestia@env@loop}}

  \AtBeginDocument{%
    \@ifundefined{exercise}{\celestia@native@env{exercise}}{}%
    \@ifundefined{exercises}{\celestia@native@env{exercises}}{}%
    \@for\celestia@env@loop:=theorem,lemma,proposition,property,properties,corollary,definition,definitions,example,examples,remark,remarks,method,activity,activities,application,applications,summary,exercise,exercises\do{%
      \@ifundefined{\celestia@env@loop}{}{\@ifundefined{\celestia@env@loop*}{%
        \expandafter\let\csname\celestia@env@loop*\expandafter\endcsname\csname\celestia@env@loop\endcsname
        \expandafter\let\csname end\celestia@env@loop*\expandafter\endcsname\csname end\celestia@env@loop\endcsname}{}}}%
  }
\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}},
    }
  }

\newcommand{\celestia@fill@sober}[1]{#1veil}
\newcommand{\celestia@fill@soft}[1]{#1veil}
\newcommand{\celestia@fill@bar}[1]{#1veil}
\newcommand{\celestia@fill@shaded}[1]{#1veil}
\newcommand{\celestia@band@shaded}[1]{#1band}
\newcommand{\celestia@title@shaded}[1]{#1ink}
\ifdefstring{\celestia@soberblockopacity}{auto}{}{%
  \renewcommand{\celestia@fill@sober}[1]{#1!\celestia@soberopacity!background}}
\ifdefstring{\celestia@softblockopacity}{auto}{}{%
  \renewcommand{\celestia@fill@soft}[1]{#1!\celestia@softopacity!background}}
\ifdefstring{\celestia@barblockopacity}{auto}{}{%
  \renewcommand{\celestia@fill@bar}[1]{#1!\celestia@baropacity!background}}
\ifdefstring{\celestia@shadedblockopacity}{auto}{}{%
  \renewcommand{\celestia@fill@shaded}[1]{#1!15!background}%
  \renewcommand{\celestia@band@shaded}[1]{#1!\celestia@shadedopacity!background}%
  \renewcommand{\celestia@title@shaded}[1]{#1!80!main}}
\newcommand{\celestia@underlined}[1]{%
  \sbox\@tempboxa{\color{#1}\csname\celestia@blocktitleweight\endcsname\tcbtitle}%
  \ifdim\wd\@tempboxa>\linewidth
    {\color{#1}\csname\celestia@blocktitleweight\endcsname\raggedright\tcbtitle\par}%
    \nointerlineskip\vspace{2pt}{\color{#1}\rule{\linewidth}{1.3pt}}\par
  \else
    \usebox\@tempboxa\par
    \nointerlineskip\vspace{2pt}{\color{#1}\rule{\wd\@tempboxa}{1.3pt}}\par
  \fi
  \vspace{2.5pt}%
  \@setminipage
}
\providecommand{\celestia@framedrule}{0.8pt}
\tcbset{
  celestia@fullbar/.style 2 args={celestia@common, sharp corners, colback=#1veil, colbacktitle=#1band, colframe=#1veil, titlerule=0pt, coltitle=#1ink, borderline west={3pt}{0pt}{#1}, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, toptitle=3pt, bottomtitle=2pt, top=3pt, bottom=3pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@fullbar/.style={}
}
\tcbset{
  celestia@bar/.style 2 args={celestia@common, sharp corners, colback=\celestia@fill@bar{#1}, colbacktitle=\celestia@fill@bar{#1}, colframe=\celestia@fill@bar{#1}, titlerule=0pt, coltitle=#1, borderline west={3.5pt}{0pt}{#1}, left=8pt, lefttitle=8pt, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, toptitle=3pt, bottomtitle=0pt, top=1pt, bottom=3pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@bar/.style={top=5.5pt}
}
\tcbset{
  celestia@ribbon/.style 2 args={celestia@common, sharp corners, opacityback=0, colback=background, colframe=background, colbacktitle=#1!15!background, titlerule=0pt, coltitle=#1, borderline west={2pt}{0pt}{#1}, left=8pt, lefttitle=8pt, right=0pt, righttitle=6pt, toptitle=2.5pt, bottomtitle=2.5pt, top=4pt, bottom=1pt, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@ribbon/.style={top=1pt}
}
\tcbset{
  celestia@line/.style 2 args={celestia@common, sharp corners, opacityback=0, opacitybacktitle=0, colback=background, colbacktitle=background, colframe=background, titlerule=0pt, coltitle=#1, borderline west={3.5pt}{0pt}{#1}, left=8pt, lefttitle=8pt, right=0pt, righttitle=0pt, toptitle=0pt, bottomtitle=0pt, top=1pt, bottom=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@line/.style={}
}
\tcbset{
  celestia@sober/.style 2 args={celestia@common, sharp corners, colback=\celestia@fill@sober{#1}, colbacktitle=\celestia@fill@sober{#1}, colframe=\celestia@fill@sober{#1}, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, toptitle=3pt, bottomtitle=0pt, top=1pt, bottom=3pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@sober/.style={top=5.5pt}
}
\tcbset{
  celestia@soft/.style 2 args={celestia@common, sharp corners, colback=\celestia@fill@soft{#1}, colbacktitle=\celestia@fill@soft{#1}, colframe=\celestia@fill@soft{#1}, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, toptitle=3pt, bottomtitle=0pt, top=1pt, bottom=3pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@soft/.style={top=5.5pt}
}
\tcbset{
  celestia@shaded/.style 2 args={celestia@common, sharp corners, colback=\celestia@fill@shaded{#1}, colbacktitle=\celestia@band@shaded{#1}, colframe=\celestia@fill@shaded{#1}, titlerule=0pt, coltitle=\celestia@title@shaded{#1}, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, toptitle=3pt, bottomtitle=2pt, top=3pt, bottom=3pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, celestia@paper},
  celestia@notitle@shaded/.style={}
}
\tcbset{
  celestia@noback/.style 2 args={opacityframe=0, opacityback=0, colback=background, colframe=background, fonttitle=\csname\celestia@blocktitleweight\endcsname\color{#1}, toptitle=3pt, top=6.5pt, left=0pt, lefttitle=0pt, right=0pt, bottom=0pt, boxrule=0pt, boxsep=0pt, title={#2}, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before upper={\color{main}}},
  celestia@notitle@noback/.style={}
}
\tcbset{
  celestia@plain/.style 2 args={enhanced jigsaw, celestia@corners, boxrule=0.5pt, colback=#1veil, colframe=\celestia@solidband{#1}, fonttitle=\csname\celestia@blocktitleweight\endcsname, coltitle=\celestia@solidtext{#1}, colbacktitle=\celestia@solidband{#1}, left=4pt, right=4pt, top=4pt, bottom=4pt, toptitle=1.2pt, bottomtitle=0pt, title={#2}, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before upper={\color{main}}, celestia@paper},
  celestia@notitle@plain/.style={}
}
\tcbset{
  celestia@card/.style 2 args={celestia@plain={#1}{#2}, left=5.5pt, right=5.5pt},
  celestia@notitle@card/.style={}
}
\tcbset{
  celestia@framed@fill/.style 2 args={enhanced jigsaw, celestia@corners, boxrule=\celestia@framedrule, colframe=#1band, colback=#1veil, colbacktitle=#1band, coltitle=#1ink, titlerule=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, left=5.2pt, right=5.2pt, lefttitle=5.2pt, righttitle=5.2pt, toptitle=2.5pt, bottomtitle=2.5pt, top=2.2pt, bottom=2.2pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before upper={\color{main}}},
  celestia@notitle@framed@fill/.style={}
}
\tcbset{
  celestia@framed@nofill/.style 2 args={enhanced jigsaw, celestia@corners, boxrule=\celestia@framedrule, colframe=#1!15!background, colback=background, opacityback=0, colbacktitle=#1!15!background, coltitle=#1, titlerule=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, left=5.2pt, right=5.2pt, lefttitle=5.2pt, righttitle=5.2pt, toptitle=2.5pt, bottomtitle=2.5pt, top=2.2pt, bottom=2.2pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before upper={\color{main}}},
  celestia@notitle@framed@nofill/.style={}
}
\tcbset{
  celestia@ruled@fill/.style 2 args={celestia@common, sharp corners, colback=#1veil, colbacktitle=#1veil, colframe=#1veil, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, boxsep=1mm, left=6pt, right=6pt, lefttitle=6pt, righttitle=6pt, toptitle=3.5pt, bottomtitle=5pt, top=5pt, bottom=5pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut,
        overlay={%
          \fill[#1rule] ([xshift=6pt+1mm]title.south west) rectangle ([xshift=-6pt-1mm,yshift=0.4pt]title.south east);
          \fill[#1] ([xshift=6pt+1mm,yshift=-0.4pt]title.south west) rectangle ([xshift=6pt+1mm+2.2em,yshift=0.8pt]title.south west);}},
  celestia@notitle@ruled@fill/.style={no overlay, top=5pt}
}
\tcbset{
  celestia@ruled@nofill/.style 2 args={celestia@common, sharp corners, opacityback=0, opacitybacktitle=0, colback=background, colbacktitle=background, colframe=background, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, boxsep=0pt, left=0pt, right=0pt, lefttitle=0pt, righttitle=0pt, toptitle=2.85pt, bottomtitle=6.35pt, top=7.35pt, bottom=2.85pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut,
        overlay={%
          \fill[#1!30!background] (title.south west) rectangle ([yshift=0.4pt]title.south east);
          \fill[#1] ([yshift=-0.4pt]title.south west) rectangle ([xshift=2.2em,yshift=0.8pt]title.south west);}},
  celestia@notitle@ruled@nofill/.style={no overlay, top=3.85pt}
}
\tcbset{
  celestia@underline@fill/.style 2 args={celestia@common, sharp corners, colback=#1veil, colbacktitle=#1veil, colframe=#1veil, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, detach title, left=6pt, right=6pt, top=4.5pt, bottom=5pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before upper={\color{main}\celestia@underlined{#1}}},
  celestia@notitle@underline@fill/.style={before upper={\color{main}}, top=5pt}
}
\tcbset{
  celestia@underline@nofill/.style 2 args={celestia@common, sharp corners, opacityback=0, opacitybacktitle=0, colback=background, colbacktitle=background, colframe=background, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, detach title, boxsep=0pt, left=0pt, right=0pt, top=3.85pt, bottom=2.85pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before upper={\color{main}\celestia@underlined{#1}}},
  celestia@notitle@underline@nofill/.style={before upper={\color{main}}}
}
\tcbset{
  celestia@discs/.style 2 args={celestia@common, sharp corners, colback=#1veil, colbacktitle=#1veil, colframe=#1veil, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, left=6pt, right=6pt, lefttitle=6pt, righttitle=24pt, toptitle=3.5pt, bottomtitle=1pt, top=2pt, bottom=5pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut,
      overlay={%
        \begin{scope}
          \clip (frame.south west) rectangle (frame.north east);
          \fill[#1d1] ([xshift=4pt,yshift=4pt]frame.north east) circle (24pt);
          \fill[#1d2] ([xshift=4pt,yshift=4pt]frame.north east) circle (17pt);
          \fill[#1d3] ([xshift=4pt,yshift=4pt]frame.north east) circle (10pt);
        \end{scope}}},
  celestia@notitle@discs/.style={top=5.5pt}
}
\tcbset{
  celestia@callout/.style 2 args={enhanced jigsaw, no shadow, celestia@corners, arc=2.5pt, boxrule=0pt, leftrule=3.5pt, colframe=#1, colback=#1veil, coltitle=#1!90!main, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, detach title, left=4.5pt, right=6pt, top=4.5pt, bottom=4.5pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before upper={\color{main}\ifx\tcbtitletext\@empty\else{\raggedright\csname\celestia@blocktitleweight\endcsname\tcbtitle\par}\vspace{0.35em}\@setminipage\fi}, celestia@paper},
  celestia@notitle@callout/.style={}
}
\tcbset{
  celestia@bare/.style 2 args={celestia@common, sharp corners, opacityback=0, opacitybacktitle=0, colback=background, colbacktitle=background, colframe=background, titlerule=0pt, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, halign title=flush left, boxsep=0pt, left=0pt, right=0pt, lefttitle=0pt, righttitle=0pt, toptitle=0pt, bottomtitle=0pt, top=1pt, bottom=0pt, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut}
}
\tcbset{
  celestia@mast/.style 2 args={celestia@bare={#1}{#2}, left=10.845pt, lefttitle=10.845pt, top=6.7pt, bottom=10pt,
      overlay={%
        \iftcb@hasTitle
          \fill[#1!38!background] ([xshift=1.4pt,yshift=0.0945em-1.675pt]title.south west) rectangle ([xshift=2.1pt]frame.south west);
          \fill[#1] ([yshift=1.675pt+0.0795em]title.north west) rectangle ([xshift=3.5pt,yshift=0.0945em-1.675pt]title.south west);
        \else
          \fill[#1!38!background] ([xshift=1.4pt]frame.north west) rectangle ([xshift=2.1pt]frame.south west);
          \fill[#1] (frame.north west) rectangle ([xshift=3.5pt,yshift=-1em]frame.north west);
        \fi
        \fill[#1!38!background] ([xshift=1.4pt]frame.south west) rectangle ([xshift=1.4pt+0.4cm,yshift=0.7pt]frame.south west);}},
  celestia@notitle@mast/.style={top=1pt}
}
\tcbset{
  celestia@masthead/.style 2 args={celestia@bare={#1}{#2}, left=10.845pt, lefttitle=10.845pt, top=6.7pt,
      overlay={\iftcb@hasTitle\fill[#1] ([yshift=1.675pt+0.0795em]title.north west) rectangle ([xshift=3.5pt,yshift=0.0945em-1.675pt]title.south west);\fi}},
  celestia@notitle@masthead/.style={top=1pt}
}
\tcbset{
  celestia@mastbox/.style 2 args={celestia@bare={#1}{#2}, left=10.845pt, lefttitle=10.845pt, right=9.445pt, righttitle=9.445pt, toptitle=9.4pt, top=6.7pt, bottom=10pt,
      overlay={%
        \fill[#1!38!background] ([xshift=1.4pt]frame.north west) rectangle ([xshift=2.1pt]frame.south west);
        \iftcb@hasTitle
          \fill[#1] ([yshift=1.0675em+1.675pt]title.south west) rectangle ([xshift=3.5pt,yshift=0.0945em-1.675pt]title.south west);
        \else
          \fill[#1] ([yshift=-3mm]frame.north west) rectangle ([xshift=3.5pt,yshift=-3mm-1em]frame.north west);
        \fi
        \fill[#1!38!background] ([xshift=1.4pt]frame.south west) rectangle ([yshift=0.7pt]frame.south east);
        \fill[#1!38!background] ([xshift=1.4pt,yshift=-0.7pt]frame.north west) rectangle (frame.north east);
        \fill[#1!38!background] ([xshift=-0.7pt]frame.north east) rectangle (frame.south east);}},
  celestia@notitle@mastbox/.style={top=10pt}
}
\tcbset{
  celestia@bracket/.style 2 args={celestia@bare={#1}{#2}, left=11pt, lefttitle=11pt, toptitle=3.5pt, top=6.7pt, bottom=4pt,
      overlay={\draw[#1, line width=0.8pt] ([xshift=5.4pt,yshift=-0.4pt]frame.north west) -- ([xshift=0.4pt,yshift=-0.4pt]frame.north west) -- ([xshift=0.4pt,yshift=0.4pt]frame.south west) -- ([xshift=5.4pt,yshift=0.4pt]frame.south west);}},
  celestia@notitle@bracket/.style={top=4pt}
}
\tcbset{
  celestia@legend/.style 2 args={enhanced jigsaw, no shadow, sharp corners, boxrule=0.5pt, colframe=#1rule, colback=background, opacityback=0, coltitle=#1, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, attach boxed title to top left={xshift=6pt, yshift*=-\tcboxedtitleheight/2}, varwidth boxed title*=-12pt, halign title=flush left, boxed title style={sharp corners, boxrule=0pt, frame hidden, colback=background, left=3pt, right=3pt, top=0pt, bottom=0pt, boxsep=0pt}, boxsep=0pt, left=9pt, right=9pt, top=3pt, bottom=6pt, before upper={\color{main}}, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before skip=\dimexpr0.5\baselineskip+3mm\relax, after skip=\dimexpr0.5\baselineskip+0.5mm\relax},
  celestia@notitle@legend/.style={top=6pt}
}
\tcbset{
  celestia@legendbox/.style 2 args={celestia@legend={#1}{#2}, fonttitle=\small\csname\celestia@blocktitleweight\endcsname, attach boxed title to top left={xshift=8pt, yshift*=-\tcboxedtitleheight/2}, top=10pt, boxed title style={sharp corners, boxrule=0pt, frame hidden, colback=background, borderline={0.5pt}{0pt}{#1rule}, left=7.5pt, right=7.5pt, top=2.6pt, bottom=2pt, boxsep=0pt}, before skip=\dimexpr0.5\baselineskip+4.5mm\relax},
  celestia@notitle@legendbox/.style={top=6pt}
}
\tcbset{
  celestia@badge@base/.style 2 args={enhanced jigsaw, no shadow, sharp corners, boxrule=0pt, frame hidden, colback=#1veil, coltitle=\celestia@solidtext{#1}, fonttitle=\small\csname\celestia@blocktitleweight\endcsname, title={#2}, attach boxed title to top left={xshift=7pt, yshift*=-\tcboxedtitleheight/2}, varwidth boxed title*=-29pt, halign title=flush left, boxed title style={sharp corners, boxrule=0pt, frame hidden, colback=\celestia@solidband{#1}, left=7.5pt, right=7.5pt, top=2.6pt, bottom=2pt, boxsep=0pt}, boxsep=0pt, left=14.5pt, right=7pt, top=10.5pt, bottom=4pt, before upper={\color{main}}, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut, before skip=\dimexpr\baselineskip+1mm\relax, after skip=\dimexpr0.5\baselineskip+0.5mm\relax, celestia@paper}
}
\tcbset{
  celestia@badge/.style 2 args={celestia@badge@base={#1}{#2}, borderline={0.5pt}{0pt}{\celestia@solidband{#1}}},
  celestia@notitle@badge/.style={top=4pt}
}
\tcbset{
  celestia@softbadge/.style 2 args={celestia@badge@base={#1}{#2}, coltitle=#1ink, boxed title style={colback=#1band}},
  celestia@notitle@softbadge/.style={top=4pt}
}
\tcbset{
  celestia@outline@nofill/.style 2 args={enhanced jigsaw, no shadow, celestia@corners, boxrule=0.5pt, colframe=#1rule, colback=background, opacityback=0, colbacktitle=background, opacitybacktitle=0, coltitle=#1, titlerule=0pt, fonttitle=\csname\celestia@blocktitleweight\endcsname, title={#2}, halign title=flush left, boxsep=0pt, left=9pt, right=9pt, lefttitle=9pt, righttitle=9pt, toptitle=5pt, bottomtitle=0pt, top=4pt, bottom=6pt, before upper={\color{main}}, beforeafter skip balanced=\dimexpr0.5\baselineskip+0.5mm\relax, separator sign=, before title=\celestia@tstrut, after title=\celestia@tstrut},
  celestia@notitle@outline@nofill/.style={top=6pt}
}
\tcbset{
  celestia@outline@fill/.style 2 args={celestia@outline@nofill={#1}{#2}, colback=#1veil, opacityback=1, colbacktitle=#1veil, opacitybacktitle=1},
  celestia@notitle@outline@fill/.style={top=6pt}
}
\tcbset{celestia@paper/.style={}, celestia@corners/.style={sharp corners}}
\newcommand{\celestia@applyfamily}[1]{%
  \celestia@readfamily{#1}%
  \celestia@resolvedesign
  \edef\celestia@blockkey{\celestia@blockeff}%
  \IfSubStr{,framed,ruled,underline,outline,}{,\celestia@blockeff,}{%
    \edef\celestia@blockkey{\celestia@blockeff @\ifcelestia@blockfilled fill\else nofill\fi}}{}%
  \edef\celestia@fam@color{\csname celestia@famcolor@#1\endcsname}%
  \edef\celestia@tmp{\noexpand\tcbset{%
    \csname celestia@famkey@#1\endcsname/.style={%
      code={\noexpand\def\noexpand\celestia@codehair{\celestia@fam@color!38!background}},
      celestia@paper/.style={\ifcelestia@blockfilled\else colback=background, opacityback=0\fi},
      celestia@corners/.style={\ifcelestia@blockrounded rounded corners, arc=1mm\else sharp corners\fi},
      celestia@\celestia@blockkey={\celestia@fam@color}{####1}},
    \csname celestia@famkey@#1\endcsname @notitle/.style={celestia@notitle@\celestia@blockkey}}}%
  \celestia@tmp
  \def\celestia@fam@bg{background}%
  \IfSubStr{,fullbar,discs,}{,\celestia@blockeff,}{\edef\celestia@fam@bg{\celestia@fam@color veil}}{}%
  \ifdefstring{\celestia@blockeff}{bar}{\edef\celestia@fam@bg{\celestia@fill@bar{\celestia@fam@color}}}{}%
  \ifdefstring{\celestia@blockeff}{sober}{\edef\celestia@fam@bg{\celestia@fill@sober{\celestia@fam@color}}}{}%
  \ifdefstring{\celestia@blockeff}{soft}{\edef\celestia@fam@bg{\celestia@fill@soft{\celestia@fam@color}}}{}%
  \ifcelestia@blockfilled
    \ifdefstring{\celestia@blockeff}{shaded}{\edef\celestia@fam@bg{\celestia@fill@shaded{\celestia@fam@color}}}{}%
    \IfSubStr{,plain,card,ruled,underline,framed,outline,callout,badge,softbadge,}{,\celestia@blockeff,}{%
      \edef\celestia@fam@bg{\celestia@fam@color veil}}{}%
  \fi
  \expandafter\let\csname celestia@fambg@#1\endcsname\celestia@fam@bg
}
\newcommand{\celestia@applyblockstyle}{%
  \@for\celestia@fam@loop:=\celestia@families\do{%
    \expandafter\celestia@applyfamily\expandafter{\celestia@fam@loop}}%
}
\celestia@applyblockstyle

\newcommand{\celestia@tcbblock}[1]{%
  \expandafter\celestia@tcbblock@i\expandafter{\insertblocktitle}{#1}}
\newcommand{\celestia@tcbblock@i}[2]{%
  \if\relax\detokenize{#1}\relax
    \begin{tcolorbox}[#2={#1}, #2@notitle]%
  \else
    \begin{tcolorbox}[#2={#1}]%
  \fi
  \def\celestia@standardkey{celestia@blockstyle}%
  \def\celestia@examplekey{celestia@exblockstyle}}

\def\celestia@standardkey{celestia@blockstyle}
\def\celestia@examplekey{celestia@exblockstyle}
\setbeamertemplate{block begin}{\expandafter\celestia@tcbblock\expandafter{\celestia@standardkey}}
\setbeamertemplate{block end}{\end{tcolorbox}}

\setbeamertemplate{block alerted begin}{\celestia@tcbblock{celestia@alertstyle}}
\setbeamertemplate{block alerted end}{\end{tcolorbox}}

\setbeamertemplate{block example begin}{\expandafter\celestia@tcbblock\expandafter{\celestia@examplekey}}
\setbeamertemplate{block example end}{\end{tcolorbox}}

\setbeamertemplate{proof begin}{\def\celestia@standardkey{celestia@proofstyle}\begin{block}{\let\@addpunct\@gobble\insertproofname}}
\setbeamertemplate{proof end}{\end{block}}
\addtobeamertemplate{theorem begin}{\def\celestia@standardkey{celestia@theoremstyle}\def\celestia@examplekey{celestia@exstyle}}{}

\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
\let\summary\relax
\let\endsummary\relax

\ExplSyntaxOn
\tl_new:N \l__celestia_tcb_title_tl
\tl_new:N \l__celestia_tcb_label_tl
\tl_new:N \l__celestia_tcb_options_tl
\NewDocumentCommand{\celestia@mynewtcbtheorem}{O{}mmmm}{%
  \newtcbtheorem[#1]{#2inner}{#3}{#4}{#5}
  \cs_if_exist:cT { c@tcb@cnt@#2inner } { \resetcounteronoverlays{tcb@cnt@#2inner} }
  \NewDocumentEnvironment{#2}{d<>O{}}{%
    \IfValueT{##1}{\begin{actionenv}<##1>}%
    \tl_clear:N \l__celestia_tcb_title_tl
    \tl_clear:N \l__celestia_tcb_label_tl
    \tl_clear:N \l__celestia_tcb_options_tl
    \keys_set:nn { celestia/tcb } { ##2 }
    \tl_if_empty:NTF \l__celestia_tcb_options_tl {%
      \use:x {
        \exp_not:N \begin{#2inner}
          {\tl_if_empty:NTF \l__celestia_tcb_title_tl
            { }
            { (\exp_not:V \l__celestia_tcb_title_tl) }
          }
          {\exp_not:V \l__celestia_tcb_label_tl}
        }
      }{%
        \use:x {
          \exp_not:N \begin{#2inner}
            [\exp_not:V \l__celestia_tcb_options_tl]
            {\tl_if_empty:NTF \l__celestia_tcb_title_tl
              { }
              { (\exp_not:V \l__celestia_tcb_title_tl) }
            }
            {\exp_not:V \l__celestia_tcb_label_tl}
          }
        }
      }{%
      \end{#2inner}
      \IfValueT{##1}{\end{actionenv}}%
    }

    \NewDocumentEnvironment{#2*}{d<>O{}}{%
      \IfValueT{##1}{\begin{actionenv}<##1>}%
      \tl_clear:N \l__celestia_tcb_title_tl
      \tl_clear:N \l__celestia_tcb_label_tl
      \tl_clear:N \l__celestia_tcb_options_tl
      \keys_set:nn { celestia/tcb } { ##2 }
      \tl_if_empty:NTF \l__celestia_tcb_options_tl {%
        \use:x {
          \exp_not:N \begin{#2inner*}
            {\tl_if_empty:NTF \l__celestia_tcb_title_tl
              { }
              { (\exp_not:V \l__celestia_tcb_title_tl) }
            }
          }
        }{%
          \use:x {
            \exp_not:N \begin{#2inner*}
              [\exp_not:V \l__celestia_tcb_options_tl]
              {\tl_if_empty:NTF \l__celestia_tcb_title_tl
                { }
                { (\exp_not:V \l__celestia_tcb_title_tl) }
              }
            }
          }
        }{%
        \end{#2inner*}
        \IfValueT{##1}{\end{actionenv}}%
      }
    }

    \keys_define:nn { celestia/tcb } {
      title .tl_set:N = \l__celestia_tcb_title_tl,
      label .tl_set:N = \l__celestia_tcb_label_tl,
      unknown .code:n = {
        \bool_lazy_or:nnTF { \tl_if_novalue_p:n {#1} } { \tl_if_blank_p:n {#1} }
          { \tl_put_right:Nx \l__celestia_tcb_options_tl { \l_keys_key_str , } }
          { \tl_put_right:Nx \l__celestia_tcb_options_tl { \l_keys_key_str = { \exp_not:n {#1} } , } }
      }
    }
\ExplSyntaxOff

\celestia@mynewtcbtheorem[auto counter]{theorem}{\celestia@name@theorem}
{celestia@theoremstyle}{th}
\celestia@mynewtcbtheorem[auto counter]{lemma}{\celestia@name@lemma}
{celestia@theoremstyle}{le}
\celestia@mynewtcbtheorem[auto counter]{proposition}{\celestia@name@proposition}
{celestia@theoremstyle}{prop}
\celestia@mynewtcbtheorem[auto counter]{property}{\celestia@name@property}
{celestia@theoremstyle}{pr}
\celestia@mynewtcbtheorem[auto counter]{properties}{\celestia@name@properties}
{celestia@theoremstyle}{prs}
\celestia@mynewtcbtheorem[auto counter]{corollary}{\celestia@name@corollary}
{celestia@theoremstyle}{cor}
\celestia@mynewtcbtheorem[auto counter]{definition}{\celestia@name@definition}
{celestia@definitionstyle}{def}
\celestia@mynewtcbtheorem[auto counter]{definitions}{\celestia@name@definitions}
{celestia@definitionstyle}{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@remarkstyle}{rem}
\celestia@mynewtcbtheorem[auto counter]{remarks}{\celestia@name@remarks}
{celestia@remarkstyle}{rems}
\celestia@mynewtcbtheorem[auto counter]{method}{\celestia@name@method}
{celestia@methodstyle}{meth}
\celestia@mynewtcbtheorem[auto counter]{activity}{\celestia@name@activity}
{celestia@activitystyle}{act}
\celestia@mynewtcbtheorem[auto counter]{activities}{\celestia@name@activities}
{celestia@activitystyle}{acts}
\celestia@mynewtcbtheorem[auto counter]{application}{\celestia@name@application}
{celestia@activitystyle}{appl}
\celestia@mynewtcbtheorem[auto counter]{applications}{\celestia@name@applications}
{celestia@activitystyle}{appls}
\celestia@mynewtcbtheorem[no counter]{summary}{\celestia@name@summary}
{theorem name, celestia@summarystyle}{summ}
\AtBeginDocument{%
  \@ifundefined{exercise}{%
    \celestia@mynewtcbtheorem[auto counter]{exercise}{\celestia@name@exercise}{celestia@exercisestyle}{exer}}{}%
  \@ifundefined{exercises}{%
    \celestia@mynewtcbtheorem[auto counter]{exercises}{\celestia@name@exercises}{celestia@exercisestyle}{exers}}{}%
}
\fi

\newcommand{\celestia@setbackgrounds}[3]{%
  \colorlet{blockbackground}{#1}%
  \colorlet{examplebackground}{#2}%
  \colorlet{alertbackground}{#3}%
}
\newcommand{\celestia@applybackgrounds}{%
  \ifcelestia@usenativeblocks
    \celestia@setbackgrounds{blockcolorveil}{examplecolorveil}{alertcolorveil}%
  \else
    \celestia@setbackgrounds{\celestia@fambg@standard}{\celestia@fambg@nativeexample}{\celestia@fambg@alert}%
  \fi
}
\celestia@applybackgrounds
\newcommand{\celestia@applyblock}{%
  \ifcelestia@usenativeblocks\else\celestia@applyblockstyle\fi
  \celestia@applybackgrounds
}

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

\RequirePackage{caption}
\DeclareCaptionFont{celestiaCaption}{\small\color{accenttext}}
\captionsetup{
  font={celestiaCaption},
  labelfont={bf},
  labelsep=colon,
  justification=centering
}
\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!background,
    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!background,
        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!background,
          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

\ifdefstring{\celestia@codestyle}{tint}{%
  \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=celestia@codetint,
      sharp corners,
      no shadow,
    }
  }
}{}

\ifdefstring{\celestia@codestyle}{hairline}{%
  \tcbset{
    celestia@codestyle/.style={
      enhanced jigsaw,
      boxrule=0pt,
      frame hidden,
      left=8pt, right=6pt, top=2pt, bottom=2pt,
      before skip=1em, after skip=1em,
      colback=celestia@codetint,
      sharp corners,
      no shadow,
      overlay={%
        \ifcelestia@codeflush
          \celestia@hairdraw
        \else
          \ifcelestia@numhere
            \fill[accent!38!background] ([xshift=\celestia@gutter-0.35pt,yshift=3pt]frame.south west) rectangle ([xshift=\celestia@gutter+0.35pt,yshift=-3pt]frame.north west);
          \else
            \fill[accent!38!background] ([xshift=5.05pt,yshift=3pt]frame.south west) rectangle ([xshift=5.75pt,yshift=-3pt]frame.north west);
          \fi
        \fi},
    }
  }
}{}

\newcommand{\celestia@hairdraw}{%
  \ifx\celestia@hairnow\@empty\else
    \ifcelestia@numhere
      \fill[\celestia@hairnow] ([xshift=\celestia@numcolw+5.1pt]frame.south west) rectangle ([xshift=\celestia@numcolw+5.8pt]frame.north west);
    \else
      \ifdefstring{\celestia@codestyle}{hairline}{%
        \fill[\celestia@hairnow] (frame.south west) rectangle ([xshift=0.7pt]frame.north west);}{}%
    \fi
  \fi}

\ifdefstring{\celestia@codestyle}{soft}{%
  \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=celestia@codesoft,
      sharp corners,
      no shadow,
      overlay={%
        \ifcelestia@codeflush
          \celestia@hairdraw
        \else
          \ifcelestia@numhere
            \fill[accent!38!background] ([xshift=\celestia@gutter-0.35pt,yshift=3pt]frame.south west) rectangle ([xshift=\celestia@gutter+0.35pt,yshift=-3pt]frame.north west);
          \fi
        \fi},
    }
  }
}{}

\ifdefstring{\celestia@codestyle}{minimal}{%
  \tcbset{
    celestia@codestyle/.style={
      enhanced jigsaw,
      boxrule=0pt,
      frame hidden,
      left=-1mm, right=-1mm, top=2pt, bottom=2pt,
      before skip=1em, after skip=1em,
      colback=background, opacityback=0,
      sharp corners,
      no shadow,
      overlay={\celestia@hairdraw},
    }
  }
}{}

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

\newif\ifcelestia@codefirst
\newdimen\celestia@codefirstwidth
\newdimen\celestia@codelinewidth
\gdef\celestia@codelang{}
\newlength{\celestia@gutter}
\AtBeginDocument{\setlength{\celestia@gutter}{1.7em}}
\ifcelestia@monoscaled
  \newcommand{\celestia@codecomp}{\fontsize{\strip@pt\dimexpr1.064\dimexpr\f@size pt\relax\relax}{\f@baselineskip}\selectfont}
\else
  \newcommand{\celestia@codecomp}{}
\fi
\newcommand{\celestia@gutternum}[1]{%
  \makebox[\celestia@gutter][c]{\ttfamily\tiny\celestia@codecomp\color{main!58!background}#1}%
}
\newcommand{\celestia@nestnum}[1]{%
  \makebox[\celestia@numcolw][r]{\ttfamily\tiny\celestia@codecomp\color{main!58!background}#1}%
}
\newcommand{\celestia@codelabel@text}{\tiny\bfseries\celestia@caps{\celestia@codelang}}
\newcommand{\celestia@codelabel@ysep}{3.5pt}
\ifx\celestia@codestyle\celestia@cs@box\renewcommand{\celestia@codelabel@ysep}{5.7pt}\fi
\newcommand{\celestia@codelabel@draw}{%
  \ifx\celestia@codelang\@empty\else
    \ifdim\celestia@codelinewidth>\ifnum\c@tcblayer>\@ne\maxdimen\else0.45\paperwidth\fi
      \StrLen{\celestia@codelang}[\celestia@tmp]%
      \ifdim\dimexpr\celestia@codefirstwidth+\celestia@tmp\dimexpr4.4pt\relax+14pt\relax<\celestia@codelinewidth
        \node[anchor=north east, inner xsep=6pt, inner ysep=\celestia@codelabel@ysep, text=main!50!background]
          at (frame.north east) {\celestia@codelabel@text};
      \fi
    \fi
  \fi
  \gdef\celestia@codelang{}%
}
\newcommand{\celestia@gutterfill}{%
  \IfSubStr{,hairline,soft,}{,\celestia@codestyle,}{}{\ifcelestia@codeflush\else
    \begin{tcbclipinterior}
      \fill[main, fill opacity=0.07] (interior.south west) rectangle ([xshift=\celestia@gutter]interior.north west);
    \end{tcbclipinterior}\fi}%
}
\newtcolorbox{celestia@resultsbox}{enhanced jigsaw, boxrule=0pt, frame hidden, boxsep=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0.8em, colback=background, opacityback=0, sharp corners, no shadow}
\newcommand{\celestia@resultsbefore}{%
  \par
  \ifnum\lastnodetype=11 \ifdim\lastskip=\z@\unskip\fi\fi
  \ifnum\lastnodetype=11
    \ifdim\lastskip=\dimexpr1em-\parskip\relax\unskip\vskip0.4em
    \else\ifdim\lastskip=\dimexpr0.8em-\parskip\relax\unskip\vskip0.4em
    \else\addvspace{0.8em}\fi\fi
  \else
    \addvspace{0.8em}%
  \fi}
\newcommand{\celestia@codewide}{%
  \pgfmathsetlength\@tempdima{\linewidth-(\kvtcb@left@rule)-(\kvtcb@right@rule)-2*(\kvtcb@boxsep)-(\kvtcb@leftupper)-(\kvtcb@rightupper)}%
  \ifdim\@tempdima>0.45\paperwidth\global\celestia@numheretrue\fi
}
\newcommand{\celestia@applycodebox}{%
  \ifcelestia@codenumbers
    \tcbset{celestia@codegutter/.style={underlay={\ifcelestia@numhere\celestia@gutterfill\fi}}}%
  \else
    \ifdefstring{\celestia@codehandler}{minted}{%
      \tcbset{celestia@codegutter/.code={%
        \global\celestia@numherefalse
        \ifcelestia@codenumauto
          \celestia@codewide
          \ifcelestia@numhere\setminted{linenos=true}\fi
        \fi
        \pgfkeysalso{underlay={\ifcelestia@numhere\celestia@gutterfill\fi}}}}%
    }{%
      \tcbset{celestia@codegutter/.style={underlay={\ifcelestia@numhere\celestia@gutterfill\fi}}}%
    }%
  \fi
  \ifcelestia@codelabel
    \ifdefstring{\celestia@codestyle}{minimal}{%
      \tcbset{celestia@codelabel/.style={}}%
    }{%
      \tcbset{celestia@codelabel/.style={underlay={\celestia@codelabel@draw}}}%
    }%
  \else
    \tcbset{celestia@codelabel/.style={}}%
  \fi
}
\celestia@applycodebox

\ifdefstring{\celestia@codehandler}{minted}{%
  \RequirePackage{minted}
  \setminted{bgcolor=codebackground, fontsize=\footnotesize\celestia@codecomp, breaklines=true, style=friendly}
  \AtBeginDocument{%
    \ifdefstring{\celestia@language}{french}{%
      \renewcommand{\listingscaption}{Programme}%
      \@ifpackageloaded{babel}{\addto\captionsfrench{\renewcommand{\listingscaption}{Programme}}}{}%
    }{}%
  }
  \AtBeginDocument{%
    \@ifundefined{code}{%
      \NewDocumentEnvironment{code}{O{}m}{\VerbatimEnvironment\begin{minted}[linenos=true,#1]{#2}}{\end{minted}}%
      \NewDocumentEnvironment{code*}{O{}m}{\VerbatimEnvironment\begin{minted}[linenos=false,#1]{#2}}{\end{minted}}%
    }{}%
    \@ifundefined{results}{%
      \DefineVerbatimEnvironment{results}{Verbatim}{fontsize=\footnotesize\celestia@codecomp, formatcom=\color{main}, numbers=none, xleftmargin=0pt, breaklines=true}%
      \BeforeBeginEnvironment{results}{\celestia@resultsbefore\begin{celestia@resultsbox}}%
      \AfterEndEnvironment{results}{\end{celestia@resultsbox}}%
    }{}%
  }
  \ifcelestia@codebox
    \newtcolorbox{lstbox}[1][]{celestia@codestyle, celestia@codegutter, code={\global\celestia@numherefalse\celestia@inboxtrue\celestia@codeflushfalse\let\celestia@hairnow\@empty\ifnum\c@tcblayer>\@ne\pgfkeysalso{opacityback=0}\setminted{bgcolor=none}\else\IfSubStr{,soft,minimal,}{,\celestia@codestyle,}{\setminted{bgcolor=none}}{}\fi\IfSubStr{,soft,minimal,hairline,tint,}{,\celestia@codestyle,}{\ifnum\c@tcblayer>\@ne\celestia@codeflushtrue\else\ifdefstring{\celestia@codestyle}{minimal}{\celestia@codeflushtrue}{}\fi}{}\ifcelestia@codeflush\ifdefstring{\celestia@codestyle}{tint}{}{\let\celestia@hairnow\celestia@codehair}\pgfkeysalso{boxsep=0pt, top=0pt, bottom=0pt, before skip=0.8em, after skip=0.8em}\ifdefstring{\celestia@codestyle}{hairline}{\pgfkeysalso{left=\dimexpr3pt+1mm\relax}}{\pgfkeysalso{left=0pt}}\ifdefstring{\celestia@codestyle}{minimal}{\pgfkeysalso{right=0pt}}{\pgfkeysalso{right=\dimexpr6pt+1mm\relax}}\fi}, #1}
    \BeforeBeginEnvironment{minted}{\begin{lstbox}}
      \AfterEndEnvironment{minted}{\celestia@mintend\end{lstbox}}
  \else
    \BeforeBeginEnvironment{minted}{\par\vspace{\celestia@code@skip}\global\celestia@inmintedtrue}
    \AfterEndEnvironment{minted}{\global\celestia@inmintedfalse\par\vspace{\celestia@code@skip}}
  \fi
  \let\celestia@FV@SetLineWidth\FV@SetLineWidth
  \def\FV@SetLineWidth{%
    \ifcelestia@inbox
      \ifx\FV@LeftListNumber\relax\else
        \global\celestia@numheretrue
        \ifcelestia@codeflush
          \global\celestia@numnesttrue
          \global\advance\celestia@lstid\@ne
          \setbox\z@\hbox{\ttfamily\tiny\celestia@codecomp 0}%
          \@tempcnta=\ifcsname celestia@lstd@\the\celestia@lstid\endcsname\csname celestia@lstd@\the\celestia@lstid\endcsname\else\@ne\fi\relax
          \global\celestia@numcolw=\@tempcnta\wd\z@
          \def\theFancyVerbLine{\celestia@nestnum{\arabic{FancyVerbLine}}}%
          \ifx\celestia@hairnow\@empty\@tempdimb=6pt\else\@tempdimb=10.9pt\fi
          \pgfmathsetlength\@tempdima{\celestia@numcolw+\@tempdimb-(\kvtcb@boxsep)-(\kvtcb@leftupper)}%
        \else
          \def\theFancyVerbLine{\celestia@gutternum{\arabic{FancyVerbLine}}}%
          \@tempdimb=6pt
          \pgfmathsetlength\@tempdima{\celestia@gutter+6pt-(\kvtcb@boxsep)-(\kvtcb@leftupper)}%
        \fi
        \edef\FV@NumberSep{\number\@tempdimb sp\relax}%
        \edef\FV@XLeftMargin{\the\@tempdima}%
      \fi
    \else
      \ifcelestia@inminted
        \ifx\FV@LeftListNumber\relax\def\FV@XLeftMargin{\z@}\fi
      \fi
    \fi
    \celestia@FV@SetLineWidth}
  \newcommand{\celestia@mintend}{%
    \ifcelestia@numnest
      \global\celestia@numnestfalse
      \immediate\write\@auxout{\string\celestia@lstdigits{\the\celestia@lstid}{\ifnum\c@FancyVerbLine<10 1\else\ifnum\c@FancyVerbLine<100 2\else 3\fi\fi}}%
    \fi}
  \newcommand{\celestia@applycode}{%
    \celestia@applycodebox
    \ifcelestia@codenumbers
      \setminted{linenos=true, numbersep=6pt}%
      \ifcelestia@codebox\else
        \setminted{xleftmargin=\dimexpr\celestia@gutter+6pt\relax}%
      \fi
      \renewcommand{\theFancyVerbLine}{\celestia@gutternum{\arabic{FancyVerbLine}}}%
    \else
      \setminted{linenos=false}%
      \ifcelestia@codebox\else
        \setminted{xleftmargin=0pt}%
      \fi
    \fi
  }
  \ifcelestia@codenumbers
    \celestia@applycode
  \fi
}{%
  \RequirePackage{listings}
  \lst@AddToHook{Init}{%
    \global\celestia@codefirsttrue
    \global\celestia@codelinewidth\linewidth
    \ifx\lst@language\@undefined
      \gdef\celestia@codelang{}%
    \else
      \global\let\celestia@codelang\lst@language
      \ifdefstring{\lst@language}{tex}{%
        \ifx\lst@dialect\@empty\else\global\let\celestia@codelang\lst@dialect\fi
      }{}%
    \fi
  }
  \gdef\celestia@numbersgiven{}
  \let\celestia@lst@numbers\KV@lst@numbers
  \def\KV@lst@numbers#1{\celestia@lst@numbers{#1}\gdef\celestia@numbersgiven{#1}}
  \lst@AddToHook{PreSet}{\gdef\celestia@numbersgiven{}}
  \lst@AddToHook{Init}{%
    \global\celestia@numherefalse
    \celestia@numthisfalse
    \ifcelestia@nonum\def\celestia@numbersgiven{none}\fi
    \ifcelestia@yesnum\def\celestia@numbersgiven{left}\fi
    \lst@ifdisplaystyle
      \ifdefstring{\celestia@numbersgiven}{none}{}{%
        \ifdefstring{\celestia@numbersgiven}{}{%
          \ifcelestia@codenumbers
            \celestia@numthistrue
          \else
            \ifcelestia@codenumauto
              \ifx\celestia@codelang\@empty\else
                \ifdim\linewidth>0.45\paperwidth
                  \celestia@numthistrue
                \fi
              \fi
            \fi
          \fi
        }{\celestia@numthistrue}%
      }%
      \ifcelestia@numthis
        \global\celestia@numheretrue
        \ifcelestia@codeflush
          \global\celestia@numnesttrue
          \global\advance\celestia@lstid\@ne
          \setbox\z@\hbox{\ttfamily\tiny\celestia@codecomp 0}%
          \@tempcnta=\ifcsname celestia@lstd@\the\celestia@lstid\endcsname\csname celestia@lstd@\the\celestia@lstid\endcsname\else\@ne\fi\relax
          \global\celestia@numcolw=\@tempcnta\wd\z@
          \ifx\celestia@hairnow\@empty
            \lstset{numbers=left, numbersep=6pt, numberstyle=\celestia@nestnum}%
            \pgfmathsetlength\@tempdima{\celestia@numcolw+6pt-(\kvtcb@boxsep)-(\kvtcb@leftupper)}%
          \else
            \lstset{numbers=left, numbersep=10.9pt, numberstyle=\celestia@nestnum}%
            \pgfmathsetlength\@tempdima{\celestia@numcolw+10.9pt-(\kvtcb@boxsep)-(\kvtcb@leftupper)}%
          \fi
        \else
          \lstset{numbers=left, numbersep=6pt, numberstyle=\celestia@gutternum}%
          \ifcelestia@inbox
            \pgfmathsetlength\@tempdima{\celestia@gutter+6pt-(\kvtcb@boxsep)-(\kvtcb@leftupper)}%
          \else
            \@tempdima=\dimexpr\celestia@gutter+6pt\relax
          \fi
        \fi
        \advance\linewidth-\@tempdima
        \advance\@totalleftmargin\@tempdima
        \global\celestia@codelinewidth\linewidth
      \fi
    \fi
  }
  \lst@AddToHook{DeInit}{%
    \ifcelestia@numnest
      \global\celestia@numnestfalse
      \@tempcnta=\numexpr\c@lstnumber-\@ne\relax
      \immediate\write\@auxout{\string\celestia@lstdigits{\the\celestia@lstid}{\ifnum\@tempcnta<10 1\else\ifnum\@tempcnta<100 2\else 3\fi\fi}}%
    \fi
  }
  \lst@AddToHook{EOL}{%
    \ifcelestia@codefirst
      \global\celestia@codefirstfalse
      \global\celestia@codefirstwidth\lst@currlwidth
    \fi
  }
  \newcommand{\celestia@applycode}{%
    \celestia@applycodebox
    \lstset{numbers=none}%
    \ifcelestia@codebox\else
      \lstset{xleftmargin=0pt}%
    \fi
  }
  \AtEndPreamble{
    \lstset{
      basicstyle=\ttfamily\footnotesize\celestia@codecomp\color{main},
      keywordstyle=\color{accenttext}\bfseries,
      emphstyle=\color{methodcolor},
      emphstyle={[2]\color{remarkcolor}},
      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{latex}{%
      language={[LaTeX]TeX},
    }

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

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

  \lstdefinelanguage{celestia@raw}{}
  \newcommand{\celestia@lstlang}[1]{%
    \lowercase{\def\celestia@tmp{#1}}%
    \@ifundefined{lststy@\celestia@tmp$}{\lstset{language=#1}}{\lstset{style=#1}}}
  \AtBeginDocument{%
    \@ifundefined{code}{%
      \lstnewenvironment{code}[2][]{\celestia@yesnumtrue\celestia@lstlang{#2}\lstset{#1}}{}%
      \lstnewenvironment{code*}[2][]{\celestia@nonumtrue\celestia@lstlang{#2}\lstset{#1}}{}%
      \ifcelestia@codebox
        \BeforeBeginEnvironment{code}{\begin{lstbox}}%
        \AfterEndEnvironment{code}{\end{lstbox}}%
        \BeforeBeginEnvironment{code*}{\begin{lstbox}}%
        \AfterEndEnvironment{code*}{\end{lstbox}}%
      \fi
    }{}%
    \@ifundefined{results}{%
      \lstnewenvironment{results}{\celestia@nonumtrue\lstset{language=celestia@raw, numbers=none, aboveskip=0pt, belowskip=0pt, xleftmargin=0pt}}{}%
      \BeforeBeginEnvironment{results}{\celestia@resultsbefore\begin{celestia@resultsbox}}%
      \AfterEndEnvironment{results}{\end{celestia@resultsbox}}%
    }{}%
  }
  \ifcelestia@codebox
    \newtcolorbox{lstbox}[1][]{celestia@codestyle, celestia@codegutter, celestia@codelabel, code={\gdef\celestia@codelang{}\celestia@inboxtrue\celestia@codeflushfalse\let\celestia@hairnow\@empty\ifnum\c@tcblayer>\@ne\pgfkeysalso{opacityback=0}\fi\IfSubStr{,soft,minimal,hairline,tint,}{,\celestia@codestyle,}{\ifnum\c@tcblayer>\@ne\celestia@codeflushtrue\else\ifdefstring{\celestia@codestyle}{minimal}{\celestia@codeflushtrue}{}\fi}{}\ifcelestia@codeflush\ifdefstring{\celestia@codestyle}{tint}{}{\let\celestia@hairnow\celestia@codehair}\pgfkeysalso{boxsep=0pt, top=0pt, bottom=0pt, before skip=0.8em, after skip=0.8em}\ifdefstring{\celestia@codestyle}{hairline}{\pgfkeysalso{left=\dimexpr3pt+1mm\relax}}{\pgfkeysalso{left=0pt}}\ifdefstring{\celestia@codestyle}{minimal}{\pgfkeysalso{right=0pt}}{\pgfkeysalso{right=\dimexpr6pt+1mm\relax}}\fi}, #1}
    \BeforeBeginEnvironment{lstlisting}{\begin{lstbox}}
      \AfterEndEnvironment{lstlisting}{\end{lstbox}}
  \fi
}

\ifcelestia@nocodeframe
  \tcbset{celestia@codestyle/.append style={boxrule=0pt, colframe=codebackground}}
\fi

\ifcelestia@shownavigation
  \setbeamertemplate{navigation symbols}[default]
  \addtobeamertemplate{footline}{}{%
    \begin{tikzpicture}[remember picture, overlay]
      \node[anchor=south east, inner sep=0pt] at ([xshift=-1em, yshift=5ex]current page.south east)
        {\usebeamertemplate***{navigation symbols}};
    \end{tikzpicture}%
  }
\fi

\newcommand{\celestia@source}[1]{%
  \begin{tikzpicture}[remember picture, overlay]
    \node[anchor=south west, inner sep=0pt, font=\usebeamerfont{footline text}]
      at ([xshift=\beamer@leftmargin, yshift=4.5ex]current page.south west)
      {\usebeamercolor[fg]{footline text}#1};
  \end{tikzpicture}%
}

\define@key{beamerframe}{quote}[true]{%
  \celestia@framegroup
  \setkeys{beamerframe}{c}%
  \beamer@framebottomskip=0pt plus 1.5fill\relax
  \setkeys{beamerframe}{noframenumbering}%
  \setbeamercolor{background canvas}{bg=maintint}%
  \setbeamertemplate{frametitle}{}%
  \setbeamertemplate{framesubtitle}{}%
  \setbeamertemplate{footline}{}%
  \centering
  \usebeamerfont{frametitle}\mdseries\Large
  \celestia@endframekey
}

\newcommand{\celestia@imagepage}[2][]{%
  \begin{frame}[plain]
    \begin{tikzpicture}[remember picture, overlay]
      \clip (current page.south west) rectangle (current page.north east);
      \sbox\z@{\includegraphics[width=\paperwidth]{#2}}%
      \ifdim\ht\z@<\paperheight
        \node[inner sep=0pt] at (current page.center) {\includegraphics[height=\paperheight]{#2}};
      \else
        \node[inner sep=0pt] at (current page.center) {\usebox\z@};
      \fi
      \if\relax\detokenize{#1}\relax\else
        \node[anchor=south west, inner sep=5pt, fill=background, fill opacity=0.88, text opacity=1,
          font=\footnotesize, text=main]
          at ([xshift=\beamer@leftmargin, yshift=\beamer@leftmargin]current page.south west) {#1};
      \fi
    \end{tikzpicture}%
  \end{frame}
}

\newcommand{\celestia@keyfigure}[2]{%
  \begin{minipage}[t]{\linewidth}
    \raggedright
    {\usebeamerfont{frametitle}\LARGE\color{emphasis}#1\par}
    \vskip 0.2em
    {\small\color{main!75!background}#2\par}
  \end{minipage}%
}

\RequirePackage{colortbl}
\arrayrulecolor{main!35!background}
\newcommand{\celestia@tablehead}[1]{\textcolor{emphasis}{\bfseries #1}}
\AtBeginDocument{%
  \providecommand{\source}{\celestia@source}%
  \providecommand{\imagepage}{\celestia@imagepage}%
  \providecommand{\keyfigure}{\celestia@keyfigure}%
  \providecommand{\tablehead}{\celestia@tablehead}%
}

\newif\ifcelestia@set@colors
\newif\ifcelestia@set@block
\newif\ifcelestia@set@frametitle
\newif\ifcelestia@set@code
\newcommand{\celestia@ifin}[2]{%
  \edef\celestia@tmp{\noexpand\in@{,\detokenize{#2},}{,\detokenize{#1},}}%
  \celestia@tmp
  \ifin@\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}
\newcommand{\celestia@set@framewide}[1]{%
  \ifbeamer@inframe
    \PackageWarning{celestia}{Inside a frame, #1 does not reach the title,\MessageBreak
      the footline or the background of this frame:\MessageBreak
      use the frame option celestia={...} instead}%
  \fi
}
\newcommand{\celestia@set@loadonly}[1]{%
  \PackageWarning{celestia}{Option #1 can only be set in \string\usetheme}%
}
\newcommand{\celestia@set@unknown}[2]{%
  \PackageWarning{celestia}{Unknown value for #1: \detokenize{#2}}%
}
\newcommand{\celestia@set@choice}[3]{%
  \celestia@ifin{#3}{#2}{\@namedef{celestia@#1}{#2}}{\celestia@set@unknown{#1}{#2}}%
}
\newcommand{\celestia@set@bool}[2]{%
  \celestia@ifin{true,false}{#2}{\csname celestia@#1#2\endcsname}{\celestia@set@unknown{#1}{#2}}%
}
\newcommand{\celestia@set@command}[2]{%
  \ifcsname\detokenize{#2}\endcsname
    \@namedef{celestia@#1}{#2}%
  \else
    \celestia@set@unknown{#1}{#2}%
  \fi
}
\newcommand{\celestia@recolor}{%
  \celestia@applycolors
  \celestia@applycodecolors
  \celestia@applybackgrounds
  \usebeamercolor{alerted text}%
  \usebeamercolor{example text}%
  \usebeamercolor{structure}%
  \usebeamercolor[fg]{normal text}%
}
\newcommand{\celestia@runpalette}[1]{%
  \ifcsname celestia@palette@\detokenize{#1}\endcsname
    \def\celestia@palette{#1}%
    \csname celestia@palette@#1\endcsname
    \celestia@set@colorstrue
  \else
    \celestia@set@unknown{palette}{#1}%
  \fi
}
\newcommand{\celestia@runscheme}[1]{%
  \ifcsname celestia@scheme@\detokenize{#1}\endcsname
    \let\celestia@savedblock\celestia@block
    \def\celestia@emphasis{main}%
    \def\celestia@decoration{\celestia@emphasis}%
    \celestia@user@decoration@setfalse
    \def\celestia@frametitlesize{normalsize}%
    \def\celestia@titlealign{left}%
    \def\celestia@blockfill{auto}%
    \def\celestia@blockcorners{auto}%
    \@for\celestia@fam@loop:=\celestia@families\do{%
      \expandafter\def\csname celestia@\celestia@fam@loop block\endcsname{auto}}%
    \ifcelestia@allserif
      \def\celestia@headstyle{rmfamily}%
    \else
      \def\celestia@headstyle{sffamily}%
    \fi
    \csname celestia@scheme@#1\endcsname
    \IfSubStr{\celestia@block}{native}{%
      \ifcelestia@usenativeblocks\else
        \let\celestia@block\celestia@savedblock
        \PackageWarning{celestia}{Style #1 uses native blocks, which can only be\MessageBreak
          selected in \string\usetheme: the block style is kept}%
      \fi
    }{%
      \ifcelestia@usenativeblocks\let\celestia@block\celestia@savedblock\fi
    }%
    \csname celestia@palette@\celestia@palette\endcsname
    \celestia@set@colorstrue
    \celestia@set@blocktrue
    \celestia@set@frametitletrue
  \else
    \celestia@set@unknown{style}{#1}%
  \fi
}

\newcommand{\celestia@setkey}[2]{\@namedef{celestia@run@key@#1}##1{#2}}
\newcommand{\celestia@setdefault}[2]{\@namedef{celestia@run@default@#1}{#2}}
\newcommand{\celestia@run@call}[2]{\csname celestia@run@key@#2\endcsname{#1}}
\newcommand{\celestia@pre@do}[2]{%
  \celestia@ifin{style,palette,custompalette}{#1}{\@namedef{celestia@run@#1}{#2}}{}%
}
\newcommand{\celestia@run@do}[2]{%
  \ifcsname celestia@run@key@\detokenize{#1}\endcsname
    \ifx\kv@value\relax
      \ifcsname celestia@run@default@#1\endcsname
        \expandafter\expandafter\expandafter\celestia@run@call
          \expandafter\expandafter\expandafter{\csname celestia@run@default@#1\endcsname}{#1}%
      \else
        \PackageWarning{celestia}{No value given for #1}%
      \fi
    \else
      \csname celestia@run@key@#1\endcsname{#2}%
    \fi
  \else
    \PackageWarning{celestia}{Unknown key in \string\celestiaset: \detokenize{#1}}%
  \fi
}

\celestia@setkey{style}{\celestia@set@framewide{style}}
\celestia@setkey{palette}{\celestia@set@framewide{palette}}
\celestia@setkey{custompalette}{\celestia@set@framewide{custompalette}}
\@for\celestia@tmp:=main,accent,background,block,example,alert,remark,method\do{%
  \edef\celestia@tmpb{%
    \noexpand\celestia@setkey{\celestia@tmp color}{%
      \noexpand\@namedef{celestia@\celestia@tmp color}{##1}%
      \noexpand\celestia@override{\celestia@tmp}%
      \noexpand\celestia@set@colorstrue}}%
  \celestia@tmpb
}
\celestia@setkey{codebackgroundcolor}{%
  \def\celestia@codebackgroundcolor{#1}%
  \celestia@set@colorstrue
}
\celestia@setkey{emphasis}{%
  \celestia@set@choice{emphasis}{#1}{main,accent}%
  \celestia@set@colorstrue
}
\celestia@setkey{decoration}{%
  \celestia@ifin{main,accent}{#1}{%
    \def\celestia@decoration{#1}%
    \celestia@user@decoration@settrue
    \celestia@set@colorstrue
  }{%
    \celestia@set@unknown{decoration}{#1}%
  }%
}
\celestia@setkey{unicolor}{%
  \celestia@set@bool{unicolor}{#1}%
  \celestia@set@colorstrue
}
\celestia@setdefault{unicolor}{true}

\celestia@setkey{block}{%
  \ifcelestia@usenativeblocks
    \PackageWarning{celestia}{With native blocks, the block style can only\MessageBreak
      be set in \string\usetheme}%
  \else
    \celestia@ifin{native,native-shadow,native-default}{#1}{%
      \PackageWarning{celestia}{Native blocks can only be selected in \string\usetheme}%
    }{%
      \expandafter\celestia@ifin\expandafter{\celestia@valid@blocks}{#1}{%
        \def\celestia@block{#1}%
        \celestia@set@blocktrue
      }{%
        \celestia@set@unknown{block}{#1}%
      }%
    }%
  \fi
}
\newcommand{\celestia@set@family}[2]{%
  \ifcelestia@usenativeblocks
    \PackageWarning{celestia}{With native blocks, the block style can only\MessageBreak
      be set in \string\usetheme}%
  \else
    \@namedef{celestia@#1block}{#2}%
    \celestia@set@blocktrue
  \fi
}
\celestia@setkey{standardblock}{\celestia@set@family{standard}{#1}}
\celestia@setkey{theoremblock}{\celestia@set@family{theorem}{#1}}
\celestia@setkey{definitionblock}{\celestia@set@family{definition}{#1}}
\celestia@setkey{proofblock}{\celestia@set@family{proof}{#1}}
\celestia@setkey{exampleblock}{\celestia@set@family{example}{#1}}
\celestia@setkey{nativeexampleblock}{\celestia@set@family{nativeexample}{#1}}
\celestia@setkey{remarkblock}{\celestia@set@family{remark}{#1}}
\celestia@setkey{methodblock}{\celestia@set@family{method}{#1}}
\celestia@setkey{activityblock}{\celestia@set@family{activity}{#1}}
\celestia@setkey{exerciseblock}{\celestia@set@family{exercise}{#1}}
\celestia@setkey{alertblock}{\celestia@set@family{alert}{#1}}
\celestia@setkey{summaryblock}{\celestia@set@family{summary}{#1}}
\celestia@setkey{blockfill}{%
  \celestia@set@choice{blockfill}{#1}{auto,true,false}%
  \celestia@set@blocktrue
}
\celestia@setdefault{blockfill}{true}
\celestia@setkey{blockcorners}{%
  \celestia@set@choice{blockcorners}{#1}{auto,rounded,sharp}%
  \celestia@set@blocktrue
}

\celestia@setkey{frametitle}{%
  \celestia@set@framewide{frametitle}%
  \celestia@ifin{clean,elegant,plain,cosmic,line,subtle,plainrule,ruled,leftbar,gradient}{#1}{%
    \def\celestia@frametitle{#1}%
    \celestia@set@frametitletrue
  }{%
    \celestia@set@unknown{frametitle}{#1}%
  }%
}
\celestia@setkey{frametitlesize}{%
  \celestia@set@framewide{frametitlesize}%
  \celestia@set@command{frametitlesize}{#1}%
}
\celestia@setkey{frametitlepadding}{%
  \celestia@set@framewide{frametitlepadding}%
  \def\celestia@frametitlepadding{#1}%
}
\celestia@setkey{frametitlebottomskip}{%
  \celestia@set@framewide{frametitlebottomskip}%
  \def\celestia@frametitlebottomskip{#1}%
}
\celestia@setkey{footerstyle}{%
  \celestia@set@framewide{footerstyle}%
  \ifcsname celestia@fs@\detokenize{#1}\endcsname
    \def\celestia@footerstyle{#1}%
  \else
    \celestia@set@unknown{footerstyle}{#1}%
  \fi
}
\celestia@setkey{footertextsize}{%
  \celestia@set@framewide{footertextsize}%
  \celestia@set@command{footertextsize}{#1}%
}
\celestia@setkey{progressbar}{%
  \celestia@set@framewide{progressbar}%
  \celestia@set@bool{progressbar}{#1}%
}
\celestia@setdefault{progressbar}{true}

\@for\celestia@tmp:=titlesize,sectiontitlesize,subtitlesize,headstyle,headweight,titleweight,blocktitleweight\do{%
  \edef\celestia@tmpb{%
    \noexpand\celestia@setkey{\celestia@tmp}{%
      \noexpand\celestia@set@command{\celestia@tmp}{##1}}}%
  \celestia@tmpb
}
\celestia@setkey{headshape}{%
  \celestia@set@choice{headshape}{#1}{normal,sc,it}%
  \celestia@applyheadshape
}
\celestia@setkey{titlealign}{\celestia@set@choice{titlealign}{#1}{left,center,right}}
\celestia@setkey{titlebackground}{\def\celestia@titlebackground{#1}}
\celestia@setkey{motif}{\celestia@set@bool{motif}{#1}}
\celestia@setdefault{motif}{true}
\celestia@setkey{sectionnumber}{\celestia@set@bool{sectionnumber}{#1}}
\celestia@setdefault{sectionnumber}{true}
\celestia@setkey{sectiontoc}{\celestia@set@choice{sectiontoc}{#1}{false,true,list,dots}}
\celestia@setdefault{sectiontoc}{list}
\celestia@setkey{sectionpage}{%
  \celestia@set@bool{sectionpage}{#1}%
  \ifcelestia@sectionpage\celestia@installsectionpage\fi
}
\celestia@setdefault{sectionpage}{true}
\celestia@setkey{subsectionpage}{%
  \celestia@set@bool{subsectionpage}{#1}%
  \ifcelestia@subsectionpage\celestia@installsubsectionpage\fi
}
\celestia@setdefault{subsectionpage}{true}

\celestia@setkey{codelabel}{%
  \celestia@set@bool{codelabel}{#1}%
  \celestia@set@codetrue
}
\celestia@setdefault{codelabel}{true}
\celestia@setkey{codenumbers}{%
  \celestia@set@choice{codenumbers}{#1}{auto,true,false}%
  \celestia@sync@codenumbers
  \celestia@set@codetrue
}
\celestia@setdefault{codenumbers}{true}

\@for\celestia@tmp:=allserif,semibold,light,compacttoc,twocoltoc,codebox,nocodeframe,shownavigation,%
    boldurl,codestyle,codehandler,serifface,seriffaceoptions,sansface,sansfaceoptions,monoface,%
    monofaceoptions,mathface,mathfaceoptions,language,margin,shadedblockopacity,soberblockopacity,%
    softblockopacity,barblockopacity\do{%
  \edef\celestia@tmpb{%
    \noexpand\celestia@setkey{\celestia@tmp}{\noexpand\celestia@set@loadonly{\celestia@tmp}}%
    \noexpand\celestia@setdefault{\celestia@tmp}{}}%
  \celestia@tmpb
}

\newcommand{\celestiaset}[1]{%
  \let\celestia@saved@prefix\KV@prefix
  \celestia@set@colorsfalse
  \celestia@set@blockfalse
  \celestia@set@frametitlefalse
  \celestia@set@codefalse
  \let\celestia@run@style\relax
  \let\celestia@run@palette\relax
  \let\celestia@run@custompalette\relax
  \kv@parse{#1}{\celestia@pre@do}%
  \ifx\celestia@run@style\relax\else
    \expandafter\celestia@runscheme\expandafter{\celestia@run@style}%
  \fi
  \ifx\celestia@run@palette\relax\else
    \expandafter\celestia@runpalette\expandafter{\celestia@run@palette}%
  \fi
  \ifx\celestia@run@custompalette\relax\else
    \expandafter\celestia@parse@custompalette\expandafter{\celestia@run@custompalette}%
    \celestia@set@colorstrue
  \fi
  \kv@parse{#1}{\celestia@run@do}%
  \ifcelestia@set@colors\celestia@recolor\fi
  \ifcelestia@set@block\celestia@applyblock\fi
  \ifcelestia@set@frametitle\setbeamertemplate{frametitle}[\celestia@frametitle]\fi
  \ifcelestia@set@code\celestia@applycode\fi
  \ifcelestia@standout\celestia@standout@colors\fi
  \let\KV@prefix\celestia@saved@prefix
}
\define@key{beamerframe}{celestia}{%
  \celestia@framegroup
  \celestiaset{#1}%
  \celestia@endframekey
}

% 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>
