.mermaid svg > rect {
    fill: #F7F7F7 !important; /* force SVG background rect to light grey */
}

/* Mermaid blocks are rendered as <pre class="mermaid"> by sphinxcontrib-mermaid.
   Our global `pre { background-color: #1D3D59 !important; }` styling is intended for
   code blocks but also affects Mermaid, making dark edges hard to see.

   Keep Mermaid diagrams readable by forcing a light container background. */
pre.mermaid {
    background-color: #F7F7F7 !important;
    color: #13283A !important;
    border: 1px solid rgba(19, 40, 58, 0.15);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
}

body.theme-dark pre.mermaid {
    /* In dark mode, still keep diagrams on a light canvas for contrast. */
    background-color: #F7F7F7 !important;
    color: #13283A !important;
    border-color: rgba(255, 255, 255, 0.12);
}

/* Stick the footer to the bottom of the page */

html {
    position: relative;
    min-height: 100%;
}

body {
    margin: 0 0 120px;
}

footer {
    overflow: hidden;
    position: absolute;
    height: 120px;
    bottom: 0;
}

img.align-center {
    margin-left: auto;
    margin-right: auto;
    display: block;
}

/* Allow hiding the TOC tree without affecting global navigation */

.toc-hidden {
    display: none;
}

/* Main header & footer color */

body {
    background-color: #FFFFFF;
}

.bg-primary {
    background-color: #1D3D59 !important;
}

/* Main headings (light & dark) */

div.rst-content h1,
div.rst-content h2,
div.rst-content h3,
div.rst-content h4,
div.rst-content h5,
div.rst-content h6 {

    color: #D9815E;
    font-weight: normal;
    text-transform: uppercase;
}

/* Code - matches default link color */

code {
    color: #3B668C;
    font-weight: bolder;
}

/* Do not use bold for code links in the page nav menu */

nav code {
    font-weight: normal;
}

/* Pre-formatted code blocks are the same in dark and light mode */

pre {
    background-color: #1D3D59 !important;
    color: #EEEEEE;
}

pre > span.linenos {
    color: #BBBBBB;
    margin-right: 10px;
}

dt.sig {
    background-color: #A3C4D9;
}

dl dt.sig {
    margin: 1rem 0;
    padding: 1rem;
    box-shadow: 0 2px 4px 0 rgba(0,0,0,.2);
    border-radius: .25rem;
    overflow: hidden;
}


/* Main buttons (light & dark) */

.btn-primary:hover,
.btn-primary:focus, 
.btn-primary:focus-within,
.btn-primary:not(:disabled):not(.disabled):active, 
.btn-primary:not(:disabled):not(.disabled).active  {
    background-color: #1D3D59;
    border-color: #1D3D59 !important;
}

*:focus {
    outline: 2.5px solid #A3C4DA !important;
}

/* light mode - Links */

a,
a.reference,
.btn-link,
.nav-link {
    color: #A3C4D9;
    text-decoration-color: #D9815E;
}

a:focus, 
a.reference:focus-within,
a.reference:focus, 
a:focus-within,
.btn-link:focus, 
.btn-link:focus-within,
.nav-link:focus,
.nav-link:focus-within {
    color: #D9815E;
    text-decoration-color: #D9815E;
    border: none !important;
    outline: none !important;
}

a:hover,
a.reference:hover,
.btn-link:hover,
.nav-link:hover {
    color: #D9815E;
    text-decoration-color: #EFAD87;
    text-decoration-thickness: 2px;
}

a:not(:disabled):not(.disabled):active, 
a:not(:disabled):not(.disabled).active,
a.reference:not(:disabled):not(.disabled):active, 
a.reference:not(:disabled):not(.disabled).active,
.btn-link:not(:disabled):not(.disabled):active, 
.btn-link:not(:disabled):not(.disabled).active,
.nav-link:not(:disabled):not(.disabled):active, 
.nav-link:not(:disabled):not(.disabled).active  {
    color: #CF7744 !important;
    text-decoration-color: #D9815E;
    border: none !important;
    outline: none !important;
}

.toc .toctree-expand {
    color: #A3C4D9 !important;
}

.toc .toctree-expand:hover {
    color: #D9815E !important;
}

.toc .current > a {
    color: #D9815E;
}

.toc .current > .toctree-expand {
    background-color: #F2F2F2;
}


/* Sphinx Design Elements */

.sd-card-header {
    background-color: #F8F8F8;
}

.sd-btn-outline-primary {
    color: #3B668C !important;
    border-color: #3B668C !important;
    font-weight: bolder;
}

.sd-btn-outline-primary:hover{
    color: #FFFFFF !important;
    background-color: #3B668C !important;
}


/* Dark mode - background */

body.theme-dark {
    background-color: #2A2A2A;
}

body.theme-dark hr, 
body.theme-dark .border, 
body.theme-dark .with-border, 
body.theme-dark .border-top, 
body.theme-dark .border-right, 
body.theme-dark .sidebar-container, 
body.theme-dark .border-bottom, 
body.theme-dark .border-left, 
body.theme-dark .search li {
    border-color: #3A3A3A !important;
}

body.theme-dark .bg-primary {
    background-color: #1D3D59 !important;
}

/* Dark mode - Search and light / dark buttons */

body.theme-dark .btn-light {
    background-color: #1D3D59;
    border-color: #3B668C;
    color: #CCCCCC;
}

body.theme-dark .btn-light:hover, 
body.theme-dark .btn-light:focus,
body.theme-dark .btn-light:focus-within, 
body.theme-dark .btn-light:not(:disabled):not(.disabled):active, 
body.theme-dark .btn-light:not(:disabled):not(.disabled).active {
    background-color: #3B668C;
    color: #CCCCCC;
}

body.theme-dark .form-control,
body.theme-dark .input-group-text,
body.theme-dark .input-group-text.bg-white {
    background-color: #1D3D59 !important;
    border-color: #3B668C;
    color: #CCCCCC;
}

/* Dark mode - Code */

body.theme-dark code {
    color: #A3C4D9;
}

/* Dark mode - Tables */

.table-dark, 
body.theme-dark table.docutils:not(.field-list) {
    color: #EAEAEA;
    background-color: #1D3D59;
}

.table .thead-dark th,
table.docutils:not(.field-list) .thead-dark th,
body.theme-dark table.docutils:not(.field-list) thead th {
    color: #EAEAEA;
    background-color: #2A577D;
    border-color: #3B668C;
}

.table-dark th, 
body.theme-dark table.docutils:not(.field-list) th, 
.table-dark td, body.theme-dark table.docutils:not(.field-list) td, 
.table-dark thead th {
    border-color: #3B668C;
}

/* Dark mode - Links */

body.theme-dark a,
body.theme-dark a.reference,
body.theme-dark .btn-link,
body.theme-dark .nav-link {
    color: #A3C4D9;
    text-decoration-color: #D9815E;
}

body.theme-dark a:focus, 
body.theme-dark a:focus-within,
body.theme-dark a.reference:focus, 
body.theme-dark a.reference:focus-within,
body.theme-dark .btn-link:focus, 
body.theme-dark .btn-link:focus-within,
body.theme-dark .nav-link:focus, 
body.theme-dark .nav-link:focus-within  {
    color: #D9815E !important;
    text-decoration-color: #D9815E;
    text-decoration-thickness: 2px;
    border: none !important;
    outline: none !important;
}

body.theme-dark a:hover,
body.theme-dark a.reference:hover,
body.theme-dark .btn-link:hover,
body.theme-dark .nav-link:hover {
    color: #D9815E;
    text-decoration-color: #cf6b44;
    text-decoration-thickness: 2px;
    border: none !important;
    outline: none !important;
}

body.theme-dark a:not(:disabled):not(.disabled):active, 
body.theme-dark a:not(:disabled):not(.disabled).active,
body.theme-dark a.reference:not(:disabled):not(.disabled):active, 
body.theme-dark a.reference:not(:disabled):not(.disabled).active,
body.theme-dark .btn-link:not(:disabled):not(.disabled):active, 
body.theme-dark .btn-link:not(:disabled):not(.disabled).active,
body.theme-dark .nav-link:not(:disabled):not(.disabled):active, 
body.theme-dark .nav-link:not(:disabled):not(.disabled).active   {
    color: #EFAD87;
    text-decoration-color: #cf6b44;
    border: none;
}

body.theme-dark .toc .toctree-expand {
    color: #A3C4D9 !important;
    background-color: #3A3A3A;
}

body.theme-dark .toc .toctree-expand:hover {
    color: #D9815E !important;
}

body.theme-dark .toc .current > a {
    color: #D9815E;
}

body.theme-dark dt.sig {
    background-color: #1D3D59;
}

/* Dark Mode - Sphinx Design Elements */

body.theme-dark .sd-card-header {
    background-color: #343434;
}

body.theme-dark .sd-card-body {
    background-color: #2E2E2E;
}

body.theme-dark .sd-card-footer {
    background-color: #2E2E2E;
}

body.theme-dark .sd-btn-outline-primary {
    color: #A3C4D9 !important;
    border-color: #A3C4D9 !important;
}

body.theme-dark .sd-btn-outline-primary:hover{
    color: #A3C4D9 !important;
    background-color: #A3C4D9 !important;
}

:root {
    --ammm-navy: #1D3D59;
    --ammm-orange: #D9815E;
    --ammm-orange-dark: #CF7744;
    --ammm-light-blue: #A3C4D9;
    --ammm-ink: #13283A;
    --ammm-sand: #FBF7F2;
    --ammm-sand-2: #FFF4EC;
}

.btn-primary {
    background-color: var(--ammm-orange) !important;
    border-color: var(--ammm-orange) !important;
    color: #FFFFFF !important;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:focus-within,
.btn-primary:not(:disabled):not(.disabled):active,
.btn-primary:not(:disabled):not(.disabled).active {
    background-color: var(--ammm-orange-dark) !important;
    border-color: var(--ammm-orange-dark) !important;
    color: #FFFFFF !important;
}

div.rst-content .admonition,
div.rst-content .note,
div.rst-content .warning,
div.rst-content .tip,
div.rst-content .important,
div.rst-content .caution,
div.rst-content .attention,
div.rst-content .danger,
div.rst-content .error {
    border-left: 6px solid var(--ammm-orange) !important;
    background: var(--ammm-sand) !important;
    border-radius: 8px;
}

div.rst-content .admonition .admonition-title,
div.rst-content .note .admonition-title,
div.rst-content .warning .admonition-title,
div.rst-content .tip .admonition-title,
div.rst-content .important .admonition-title,
div.rst-content .caution .admonition-title,
div.rst-content .attention .admonition-title,
div.rst-content .danger .admonition-title,
div.rst-content .error .admonition-title {
    background: var(--ammm-orange) !important;
    color: #FFFFFF !important;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

div.rst-content .admonition a,
div.rst-content .note a,
div.rst-content .warning a,
div.rst-content .tip a {
    color: var(--ammm-navy) !important;
    text-decoration-color: var(--ammm-orange) !important;
}

body.theme-dark div.rst-content .admonition,
body.theme-dark div.rst-content .note,
body.theme-dark div.rst-content .warning,
body.theme-dark div.rst-content .tip,
body.theme-dark div.rst-content .important,
body.theme-dark div.rst-content .caution,
body.theme-dark div.rst-content .attention,
body.theme-dark div.rst-content .danger,
body.theme-dark div.rst-content .error {
    background: #2E2E2E !important;
    border-left-color: var(--ammm-orange) !important;
}

body.theme-dark div.rst-content .admonition .admonition-title,
body.theme-dark div.rst-content .note .admonition-title,
body.theme-dark div.rst-content .warning .admonition-title,
body.theme-dark div.rst-content .tip .admonition-title,
body.theme-dark div.rst-content .important .admonition-title,
body.theme-dark div.rst-content .caution .admonition-title,
body.theme-dark div.rst-content .attention .admonition-title,
body.theme-dark div.rst-content .danger .admonition-title,
body.theme-dark div.rst-content .error .admonition-title {
    background: var(--ammm-orange-dark) !important;
}

.ammm-sidebar-menu {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.ammm-sidebar-menu .caption {
    margin: 0 0 0.35rem 0;
    font-size: 0.85rem;
    color: var(--ammm-ink);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ammm-sidebar-menu ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.ammm-sidebar-menu li {
    margin: 0.15rem 0;
}

.ammm-sidebar-menu a {
    display: block;
    padding: 0.18rem 0.4rem;
    border-radius: 6px;
    color: var(--ammm-ink) !important;
    text-decoration: none;
}

.ammm-sidebar-menu a:hover {
    background: var(--ammm-sand-2);
    color: var(--ammm-orange-dark) !important;
}

body.theme-dark .ammm-sidebar-menu a {
    color: #EAEAEA !important;
}

body.theme-dark .ammm-sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--ammm-orange) !important;
}

.ammm-hero {
    margin: 0.5rem 0 2rem 0;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--ammm-navy) 0%, var(--ammm-ink) 70%);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
}

.ammm-hero__inner,
.ammm-hero-inner {
    padding: 1.5rem 1.5rem 1.25rem 1.5rem;
}

.ammm-hero__inner,
.ammm-hero__inner p,
.ammm-hero__inner li,
.ammm-hero__inner a,
.ammm-hero-inner,
.ammm-hero-inner p,
.ammm-hero-inner li,
.ammm-hero-inner a,
.ammm-hero-inner .rubric {
    color: rgba(255, 255, 255, 0.94) !important;
}

.ammm-hero__inner h2,
.ammm-hero-inner h2,
.ammm-hero-inner .rubric {
    color: #FFFFFF !important;
    text-transform: none !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
}

.ammm-hero__inner p,
.ammm-hero-inner p {
    color: rgba(255, 255, 255, 0.92);
}

.ammm-hero__badges,
.ammm-hero-badges {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.95rem;
}

.ammm-hero__badges strong,
.ammm-hero-badges strong {
    color: #FFFFFF;
}

/* Sphinx-Design button palette (used on the index hero) */
.sd-btn-primary {
    background: var(--ammm-orange) !important;
    border-color: var(--ammm-orange) !important;
    color: #FFFFFF !important;
}

.sd-btn-primary:hover,
.sd-btn-primary:focus {
    background: var(--ammm-orange-dark) !important;
    border-color: var(--ammm-orange-dark) !important;
    color: #FFFFFF !important;
}

.sd-btn-secondary {
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.55) !important;
    color: #FFFFFF !important;
}

.ammm-hero .sd-btn-secondary,
.ammm-hero .sd-btn-secondary:visited,
.ammm-hero .sd-btn-secondary span,
.ammm-hero .sd-btn-secondary .sd-text-wrap {
    color: #FFFFFF !important;
}

.sd-btn-secondary:hover,
.sd-btn-secondary:focus {
    background: rgba(255, 255, 255, 0.10) !important;
    border-color: rgba(255, 255, 255, 0.75) !important;
    color: #FFFFFF !important;
}

body.theme-dark .ammm-sidebar-menu {
    border-top-color: rgba(255, 255, 255, 0.12);
}

body.theme-dark .ammm-sidebar-menu .caption {
    color: #CCCCCC;
}

.toc.page-toc ul ul ul {
    display: none;
}
