body {
    font-size: 0.85rem;
    line-height: 1.28;
}

a,
a:hover,
a:focus {
    text-decoration: none;
}

#pst-header {
    display: none !important;
}

.sidebar-primary-item,
.navbar-brand.logo {
    padding-top: 0 !important;
}

/* Compact left navigation (Press docs/UI.md, Compact left navigation spacing):
   0.85rem text, line-height 1.2, same in the desktop sidebar and mobile drawer. */
nav.bd-links,
nav.bd-links li,
nav.bd-links li > a,
nav.bd-links p.caption,
nav.bd-links .caption-text {
    font-size: 0.85rem !important;
}

nav.bd-links p.caption {
    margin-top: 0.55rem !important;
    margin-bottom: 0.2rem !important;
    line-height: 1.2 !important;
}

nav.bd-links li > a {
    padding: 0.1rem 0.25rem !important;
    line-height: 1.2 !important;
}

nav.bd-links li {
    margin-top: 0 !important;
    margin-bottom: 0.1rem !important;
    line-height: 1.2 !important;
}

/* Section links stay hidden until the reader signs in to ThinkPress. Press
   enforces the gate on the server. */
html:not(.thinkpress-authenticated) nav.bd-links li.toctree-l2,
html:not(.thinkpress-authenticated) nav.bd-links .toctree-l2,
html:not(.thinkpress-authenticated) nav.bd-links ul ul,
html:not(.thinkpress-authenticated) .tp-gated-link {
    display: none !important;
}

.bd-sidebar-primary .sidebar-primary-items__end {
    margin-top: 0.75rem !important;
}

h1,
h2,
h3,
h4 {
    line-height: 1.25;
    margin-bottom: 0.3em;
    font-weight: 600;
}

/* Page title size: 1.87rem in every book, independent of body font size (Press docs/UI.md). */
h1 {
    font-size: 1.87rem !important;
}

h2 {
    margin: 1.5rem 0 0.75rem 0;
    font-size: 1.5rem !important;
}

h3 {
    margin: 1rem 0 0.5rem 0;
    font-size: 1.1rem !important;
}

h4 {
    margin-top: 0.75rem;
    font-size: 1.05rem !important;
}

table.dataframe,
table {
    border-collapse: collapse !important;
    width: auto !important;
    margin: 0 auto 1em auto !important;
}

.dataframe td,
.dataframe th,
table td,
table th {
    padding: 2px 6px !important;
    line-height: 1.2 !important;
}

table td p,
table th p,
table.dataframe th,
table.dataframe td {
    font-size: 0.85rem !important;
    color: var(--pst-color-text-base, #333) !important;
}

table td code,
table th code {
    font-size: 0.8rem !important;
}

div.cell_output table td,
div.cell_output table th,
div.cell_output table td p,
div.cell_output table th p,
div.cell_output table.dataframe td,
div.cell_output table.dataframe th,
.jp-OutputArea table td,
.jp-OutputArea table th,
.jp-OutputArea table td p,
.jp-OutputArea table th p,
.jp-OutputArea table.dataframe td,
.jp-OutputArea table.dataframe th {
    font-size: 0.8rem !important;
}

table thead tr,
table.dataframe thead tr {
    color: var(--pst-color-text-muted, #555) !important;
    font-weight: 500 !important;
    background-color: var(--pst-color-surface, #f9f9f9) !important;
    border-bottom: 2px solid var(--pst-color-border, #eee) !important;
}

table.dataframe thead th,
table thead th {
    color: var(--pst-color-text-base, #222) !important;
    font-weight: 500 !important;
    background-color: var(--pst-color-surface, #f9f9f9) !important;
}

table.dataframe tbody th,
table tbody th {
    color: var(--pst-color-text-base, #222) !important;
    font-weight: 500 !important;
    border-bottom: 1px solid var(--pst-color-border, #eee) !important;
}

table.dataframe tbody tr,
table tbody tr {
    font-weight: 400 !important;
}

table.dataframe tbody tr:hover,
table.dataframe tbody tr th:hover,
table tbody tr:hover {
    background-color: var(--table-row-hover, #ebf7ee) !important;
}

.bordered-figure img {
    border: 1px solid var(--pst-color-border, #c9ced6);
    border-radius: 4px;
    padding: 6px;
    background: #fff;
}

.video-copyright-note {
    margin-top: -0.25rem;
    color: var(--pst-color-text-muted, #5b6676);
    font-size: 0.82rem;
    line-height: 1.25;
}

.chapter-mindmap {
    --mindmap-root: #2687d9;
    --mindmap-surface: #f6f8fb;
    --mindmap-connector: #cbd5e1;
    --mindmap-border: #d7e0ea;
    --mindmap-pill-bg: #fff;
    --mindmap-pill-border: #26384a;
    --mindmap-pill-text: #1f2937;
    --mindmap-gap: clamp(1rem, 3vw, 2rem);
    margin: 1.1rem 0 1.3rem 0;
    padding: clamp(1rem, 2.5vw, 1.6rem);
    overflow-x: auto;
    border: 1px solid var(--mindmap-border);
    border-radius: 8px;
    background: var(--mindmap-surface);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    align-items: center;
    column-gap: var(--mindmap-gap);
    min-width: 680px;
}

.branch-a {
    --branch-color: #f4c15d;
}

.branch-b {
    --branch-color: #f25467;
}

.branch-c {
    --branch-color: #28a37d;
}

.branch-d {
    --branch-color: #d86aaa;
}

.mindmap-root,
.mindmap-branch-topic,
.mindmap-leaves li {
    position: relative;
    z-index: 2;
    border: 2px solid var(--mindmap-pill-border);
    border-radius: 6px;
    background: var(--mindmap-pill-bg);
    color: var(--mindmap-pill-text);
    line-height: 1.2;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.mindmap-root {
    min-width: 11rem;
    padding: 0.9rem 1.1rem;
    border-color: #1769b3;
    background: linear-gradient(180deg, #37a1f2 0%, var(--mindmap-root) 100%);
    color: #fff;
    font-size: 1.35rem;
    font-weight: 750;
    text-align: center;
}

.mindmap-root::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    width: var(--mindmap-gap);
    border-top: 2px solid var(--mindmap-connector);
    transform: translateY(-50%);
}

.chapter-mindmap.mindmap-hybrid {
    position: relative;
    display: block;
    min-width: 0;
    overflow: hidden;
    padding: clamp(1rem, 2vw, 1.35rem);
}

.mindmap-hybrid-layout {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(10.5rem, 13.5rem) minmax(0, 1fr);
    align-items: center;
    column-gap: clamp(1.5rem, 4vw, 2.5rem);
    min-height: 18rem;
}

.mindmap-connectors {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.mindmap-connectors path {
    fill: none;
    stroke: var(--mindmap-connector);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mindmap-hybrid .mindmap-root::after,
.mindmap-hybrid .mindmap-branches::before,
.mindmap-hybrid .mindmap-branch::before,
.mindmap-hybrid .mindmap-branch-topic::after,
.mindmap-hybrid .mindmap-leaves::before,
.mindmap-hybrid .mindmap-leaves li::before {
    display: none;
}

.mindmap-hybrid .mindmap-root {
    justify-self: center;
    min-width: min(100%, 13.5rem);
    padding: 0.75rem 0.9rem;
    font-size: 1.08rem;
}

.mindmap-hybrid .mindmap-branches {
    gap: 0.65rem;
    padding-left: 0;
}

.mindmap-hybrid .mindmap-branch {
    grid-template-columns: minmax(7.75rem, 9.5rem) minmax(8.25rem, 1fr);
    column-gap: 1.1rem;
}

.mindmap-hybrid .mindmap-branch-topic {
    min-width: 0;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
}

.mindmap-hybrid .mindmap-leaves li {
    width: 100%;
    min-width: 0;
    padding: 0.38rem 0.65rem;
    font-size: 0.82rem;
}

.chapter-mindmap.mindmap-concept {
    /* Spacing scale: sibling < generation < core, so groups read before branches. */
    --mindmap-sibling-gap: 0.72rem;
    --mindmap-generation-gap: 0.9rem;
    --mindmap-core-gap-x: 0.9rem;
    --mindmap-core-gap-y: 1.55rem;
    --mindmap-pill-font-size: 12px;
    width: min(100%, 720px);
    margin: 0.65rem auto 1.25rem;
    overflow: hidden;
    padding: 1.2rem;
}

.mindmap-concept .mindmap-hybrid-layout {
    width: min(100%, 680px);
    min-height: 230px;
    display: grid;
    /* Minimum tracks leave slack: 2 leaves + 2 topics + root + 4 gaps < layout width. */
    grid-template-columns: minmax(6.25rem, 1fr) minmax(6.6rem, auto) minmax(10.25rem, 12rem) minmax(6.6rem, auto) minmax(6.25rem, 1fr);
    grid-template-rows: minmax(6.4rem, auto) auto minmax(4.2rem, auto);
    column-gap: var(--mindmap-core-gap-x);
    row-gap: var(--mindmap-core-gap-y);
}

.mindmap-concept .mindmap-root {
    grid-column: 3;
    grid-row: 2;
    min-width: 10.25rem;
    max-width: 11.75rem;
    border-width: 1px;
    padding: 0.5rem 0.7rem;
    font-size: var(--mindmap-pill-font-size);
}

.mindmap-concept .mindmap-branches {
    display: contents;
}

.mindmap-concept .mindmap-branch {
    display: flex;
    gap: var(--mindmap-generation-gap);
    align-items: center;
    width: min(100%, 19.25rem);
}

.mindmap-concept .mindmap-branch-topic {
    width: fit-content;
    min-width: 6.6rem;
    max-width: 9.75rem;
    border-width: 1px;
    padding: 0.36rem 0.52rem;
    font-size: var(--mindmap-pill-font-size);
    line-height: 1.15;
}

.mindmap-concept .mindmap-leaves {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: center;
    gap: var(--mindmap-sibling-gap);
    width: 100%;
    font-size: var(--mindmap-pill-font-size);
}

.mindmap-concept .mindmap-leaves li {
    width: fit-content;
    min-width: 0;
    border-width: 1px;
    padding: 0.26rem 0.42rem;
    font-size: var(--mindmap-pill-font-size);
    line-height: 1.15;
    max-width: 8.75rem;
    white-space: normal;
    text-align: center;
}

.mindmap-concept .mindmap-cluster-a .mindmap-leaves {
    grid-column: 1;
    grid-row: 1;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    width: auto;
}

.mindmap-concept .mindmap-cluster-b .mindmap-leaves {
    grid-column: 2;
    grid-row: 1;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: center;
    width: auto;
}

.mindmap-concept .mindmap-cluster-a .mindmap-branch-topic {
    grid-column: 2;
    grid-row: 1;
}

.mindmap-concept .mindmap-cluster-b .mindmap-branch-topic {
    grid-column: 1;
    grid-row: 1;
}

.mindmap-concept .mindmap-cluster-a {
    grid-column: 1 / 3;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-self: end;
    align-items: center;
    justify-self: end;
    width: 100%;
    margin-bottom: 0;
}

.mindmap-concept .mindmap-cluster-b {
    grid-column: 4 / 6;
    grid-row: 1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-self: end;
    align-items: center;
    justify-self: start;
    width: 100%;
    margin-bottom: 0;
}

.mindmap-concept .mindmap-cluster-c {
    grid-column: 2 / 5;
    grid-row: 3;
    align-self: start;
    flex-direction: column;
    justify-self: center;
    width: min(100%, 19.25rem);
    margin-top: -0.25rem;
}

.mindmap-concept .mindmap-cluster-d {
    grid-column: 4 / 6;
    grid-row: 3;
    align-self: start;
    flex-direction: column;
    justify-self: start;
    width: min(100%, 19.25rem);
    margin-top: -0.25rem;
}

.mindmap-concept .mindmap-hybrid-layout:has(.mindmap-cluster-d) .mindmap-cluster-c {
    grid-column: 1 / 3;
    justify-self: end;
    width: min(100%, 19.25rem);
}

.mindmap-branches {
    position: relative;
    display: grid;
    gap: 0.75rem;
    padding-left: 1.25rem;
}

.mindmap-branches::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1.65rem;
    bottom: 1.65rem;
    border-left: 2px solid var(--mindmap-connector);
}

.mindmap-branch {
    --branch-color: #64748b;
    position: relative;
    display: grid;
    grid-template-columns: minmax(9rem, 12.5rem) minmax(12rem, 1fr);
    align-items: center;
    column-gap: 1.5rem;
}

.mindmap-branch::before {
    content: "";
    position: absolute;
    left: -1.25rem;
    top: 50%;
    width: 1.25rem;
    border-top: 2px solid var(--mindmap-connector);
    transform: translateY(-50%);
}

.mindmap-branch-topic {
    position: relative;
    z-index: 1;
    padding: 0.65rem 0.9rem;
    border-color: var(--branch-color);
    color: #fff;
    background: var(--branch-color);
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
}

.mindmap-branch-topic::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    width: 1.5rem;
    border-top: 2px solid var(--mindmap-connector);
    transform: translateY(-50%);
}

.mindmap-leaves {
    position: relative;
    display: grid;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mindmap-leaves::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1rem;
    bottom: 1rem;
    border-left: 2px solid var(--mindmap-connector);
}

.mindmap-leaves li {
    position: relative;
    z-index: 1;
    width: fit-content;
    min-width: 8.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.mindmap-leaves li::before {
    content: "";
    position: absolute;
    right: 100%;
    top: 50%;
    width: 1.5rem;
    border-top: 2px solid var(--mindmap-connector);
    transform: translateY(-50%);
}

@media (max-width: 760px) {
    .chapter-mindmap {
        --mindmap-gap: 1rem;
        min-width: 600px;
        padding: 0.9rem;
    }

    .mindmap-root {
        min-width: 9.5rem;
        font-size: 1.05rem;
    }

    .mindmap-branch {
        grid-template-columns: minmax(8rem, 10rem) minmax(10rem, 1fr);
        column-gap: 1rem;
    }

    .mindmap-branch-topic::after,
    .mindmap-leaves li::before {
        width: 1rem;
    }

    .mindmap-leaves li {
        min-width: 7.5rem;
        font-size: 0.82rem;
    }

    .mindmap-hybrid-layout {
        width: min(100%, 640px);
        grid-template-columns: minmax(9rem, 11rem) minmax(0, 1fr);
        min-height: 16rem;
    }

    .mindmap-hybrid .mindmap-branch {
        grid-template-columns: minmax(6.75rem, 8rem) minmax(7.5rem, 1fr);
        column-gap: 0.85rem;
    }

    .mindmap-hybrid .mindmap-root {
        font-size: 0.95rem;
    }

    .mindmap-hybrid .mindmap-branch-topic,
    .mindmap-hybrid .mindmap-leaves li {
        font-size: 0.78rem;
    }

    .mindmap-concept .mindmap-hybrid-layout {
        width: min(100%, 580px);
        min-height: 310px;
        grid-template-columns: minmax(5.25rem, 1fr) auto minmax(8.75rem, 10rem) auto minmax(5.25rem, 1fr);
        grid-template-rows: minmax(5.35rem, 1fr) auto minmax(4.9rem, 0.8fr);
        gap: 0.45rem 0.75rem;
    }

    .mindmap-concept .mindmap-root {
        min-width: 8.75rem;
        max-width: 10rem;
        font-size: var(--mindmap-pill-font-size);
    }

    .mindmap-concept .mindmap-branch {
        width: min(100%, 11.5rem);
        gap: 0.65rem;
    }

    .mindmap-concept .mindmap-branch-topic {
        min-width: 6.3rem;
        padding: 0.32rem 0.44rem;
        font-size: var(--mindmap-pill-font-size);
    }

    .mindmap-concept .mindmap-leaves {
        gap: 0.3rem;
    }

    .mindmap-concept .mindmap-leaves li {
        padding: 0.24rem 0.36rem;
        font-size: var(--mindmap-pill-font-size);
    }

    .mindmap-concept .mindmap-cluster-a,
    .mindmap-concept .mindmap-cluster-b {
        width: min(100%, 15rem);
    }

    .mindmap-concept .mindmap-cluster-d {
        width: min(100%, 11.5rem);
    }

    .mindmap-concept .mindmap-hybrid-layout:has(.mindmap-cluster-d) .mindmap-cluster-c {
        width: min(100%, 11.5rem);
    }

}

/* PyData can render the book root (the cover) as a separate home row above the first part;
   the logo already links to the cover, so hide the duplicate. */
.bd-sidebar-primary nav.bd-links .bd-sidenav__home-link {
    display: none !important;
}

/* Previous/Next size: label and page title both 0.85rem in every book, independent of the
   book's body font size (Press docs/UI.md, Previous/Next size). */
.prev-next-area a p.prev-next-subtitle,
.prev-next-area a p.prev-next-title {
    font-size: 0.85rem;
}

/* Body text size: 0.85rem in every book; paragraphs and list items inherit it (Press docs/UI.md). */
p,
li {
    font-size: inherit !important;
}

/* Title page catalog card (Press docs/UI.md, Title Page Catalog Card). The card is an
   object on the page, so it keeps its own cream stock and dark ink in dark mode; only
   the punched hole follows the page background. */
.tp-catalog-card {
    --card-line: 1.75rem;
    background-color: #fbf6e6;
    background-image:
        linear-gradient(to bottom, transparent calc(2.6rem - 1px), #d9534f calc(2.6rem - 1px), #d9534f 2.6rem, transparent 2.6rem),
        repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--card-line) - 1px), #c9d8ea calc(var(--card-line) - 1px), #c9d8ea var(--card-line));
    background-position: 0 0, 0 2.6rem;
    border: 1px solid #e4dcc2;
    border-radius: 4px;
    box-shadow: 0 6px 18px rgba(40, 32, 12, 0.14), 0 1px 2px rgba(40, 32, 12, 0.12);
    color: #2b2a26;
    display: grid;
    font-family: "Courier New", Courier, "Liberation Mono", monospace;
    font-size: 0.85rem; /* body text size (Press docs/UI.md) */
    gap: 0 1.25rem;
    grid-template-columns: 5.5rem 1fr;
    line-height: var(--card-line);
    margin: 2rem auto 2.5rem;
    max-width: 38rem;
    padding: 2.65rem 1.5rem 3rem 1.25rem;
    position: relative;
}

.tp-catalog-card p {
    margin: 0;
}

.tp-catalog-card a {
    color: #1d4f9a;
}

.tp-catalog-card__call {
    line-height: var(--card-line);
    white-space: nowrap;
}

.tp-catalog-card__author {
    font-weight: 700;
}

.tp-catalog-card__line {
    text-indent: 0;
}

.tp-catalog-card__tracings {
    margin-top: var(--card-line) !important;
}

.tp-catalog-card__hole {
    background: var(--pst-color-background, #ffffff);
    border: 1px solid #d8cfb3;
    border-radius: 50%;
    bottom: 0.9rem;
    box-shadow: inset 0 1px 2px rgba(40, 32, 12, 0.25);
    height: 1.1rem;
    left: 50%;
    position: absolute;
    transform: translateX(-50%);
    width: 1.1rem;
}

@media (max-width: 560px) {
    .tp-catalog-card {
        grid-template-columns: 1fr;
        padding: 2.65rem 1rem 3rem;
    }

    .tp-catalog-card__call br {
        display: none;
    }

    .tp-catalog-card__call {
        white-space: normal;
        word-spacing: 0.4rem;
    }
}

/* Dark mode: the book theme sets data-theme="dark" on the root element. Theme variables
   carry tables, notes and figures; the concept map and table hover need their own values. */
html[data-theme="dark"] {
    --table-row-hover: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .chapter-mindmap {
    --mindmap-surface: #1c232e;
    --mindmap-border: #364152;
    --mindmap-connector: #4a5568;
    --mindmap-pill-bg: #29313d;
    --mindmap-pill-border: #8794a8;
    --mindmap-pill-text: #e5e9f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .bordered-figure img {
    border-color: var(--pst-color-border);
}

/* Phones: the radial concept map needs about 580px, so stack it as an outline instead:
   root on top, then each topic with its concepts beneath. The connector layer is hidden. */
@media (max-width: 560px) {
    .chapter-mindmap.mindmap-concept {
        overflow: visible;
        padding: 1rem;
    }

    .mindmap-concept .mindmap-connectors {
        display: none;
    }

    .mindmap-concept .mindmap-hybrid-layout {
        width: 100%;
        min-height: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.9rem;
    }

    .mindmap-concept .mindmap-root {
        order: -1;
        align-self: center;
        max-width: 100%;
    }

    .mindmap-concept .mindmap-branches {
        display: flex;
        flex-direction: column;
        gap: 0.9rem;
    }

    .mindmap-concept .mindmap-hybrid-layout .mindmap-branch {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        margin: 0;
        gap: 0.5rem;
        padding-left: 0.9rem;
        border-left: 3px solid var(--branch-color);
    }

    .mindmap-concept .mindmap-branch .mindmap-leaves {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        width: 100%;
    }
}
