/* Guide pages (guide.html, GUIDE_PAGES in conf.py). Loaded after
   homepage.css: reuses the landing tokens (--mh-*) and components (mh-*).
   Every selector is scoped to body.mespy-guide. */
body.mespy-guide {
  --gd-measure: 72ch;
}
@media (prefers-reduced-motion: no-preference) {
  html:has(body.mespy-guide) { scroll-behavior: smooth; }
}
html:has(body.mespy-guide) { scroll-padding-top: 24px; }

/* Two columns: guide navigator and article. */
.mespy-guide .gd-layout { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 72px; padding-block: 64px 112px; }
.mespy-guide .gd-aside { position: sticky; top: 24px; align-self: start; max-height: calc(100vh - 48px); overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--mh-line) transparent; }
.mespy-guide .gd-main { min-width: 0; max-width: 860px; }

/* Level 2 — guide navigator. */
.mespy-guide .mx-guide-nav ol { list-style: none; margin: 0; padding: 0; }
/* Labels here and below: at least .875rem, sentence case, on every width. */
.mespy-guide .mx-guide-nav__title { margin: 0 0 18px; font: .875rem/1.6 var(--mh-mono); color: var(--mh-muted); }
.mespy-guide .mx-guide-nav__group + .mx-guide-nav__group { margin-top: 20px; }
.mespy-guide .mx-guide-nav__group-link { display: block; padding-block: 2px; font-size: .875rem; font-weight: var(--mespy-weight-semibold); color: var(--mh-ink); overflow-wrap: anywhere; }
.mespy-guide .mx-guide-nav__entries { margin-top: 8px !important; border-left: 1px solid var(--mh-line); }
.mespy-guide .mx-guide-nav__link { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: baseline; margin-left: -1px; padding: 5px 0 5px 13px; border-left: 1px solid transparent; font-size: .875rem; line-height: 1.45; color: var(--mh-muted); overflow-wrap: anywhere; transition: color .2s, border-color .2s; }
.mespy-guide .mx-guide-nav__link:not(:has(.mx-guide-nav__num)) { grid-template-columns: minmax(0, 1fr); }
.mespy-guide .mx-guide-nav__num { font: .875rem/1.45 var(--mh-mono); color: var(--mh-faint); }
.mespy-guide .mx-guide-nav a:hover { color: var(--mh-ink); }
.mespy-guide .mx-guide-nav__link:hover { border-left-color: var(--mh-line-strong); }
.mespy-guide .mx-guide-nav a[aria-current] { color: var(--mh-amber); }
.mespy-guide .mx-guide-nav__link[aria-current] { border-left-color: var(--mh-amber); }
.mespy-guide .mx-guide-nav__link[aria-current] .mx-guide-nav__num { color: var(--mh-amber); }
.mespy-guide .mx-guide-nav__group--active > .mx-guide-nav__group-link { color: var(--mh-amber); }
.mespy-guide .mx-guide-nav a:focus-visible { outline-offset: 2px; }

/* Pixel-art scene under the navigator ("station" in GUIDE_PAGES), drawn by
   guide-<station>-station.js, coloured by guide-<station>-station.css.
   As wide as the navigator column, so its right edge lines up with the links. */
.mespy-guide .gd-station { margin-top: 56px; line-height: 0; pointer-events: none; }
.mespy-guide .gd-station[hidden] { display: none; }
.mespy-guide .gd-station svg { display: block; width: 100%; height: auto; }
@media print, (forced-colors: active) {
  .mespy-guide .gd-station { display: none; }
}

/* Compact menu, shown only when the side column is hidden. */
.mespy-guide .mx-guide-menu { display: none; }

/* ------------------------------------------------------------ article */
/* Shows Python identifiers (mespy.fit_utils.LinearFitResult) exactly as written. */
.mespy-guide .gd-eyebrow { margin-bottom: 22px; font-size: .875rem; text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
.mespy-guide .gd-article { color: var(--mh-ink); font-size: 1rem; line-height: var(--mespy-leading-text); }
.mespy-guide .gd-article > section > p,
.mespy-guide .gd-article section section > p,
.mespy-guide .gd-article section > ul,
.mespy-guide .gd-article section > ol { max-width: var(--gd-measure); }
.mespy-guide .gd-article p { margin: 0 0 18px; }
.mespy-guide .gd-article strong { color: var(--mh-ink); font-weight: var(--mespy-weight-bold); }
.mespy-guide .gd-article a { color: var(--mh-ink); text-decoration: underline; text-decoration-color: var(--mh-amber-line); text-decoration-thickness: 1px; text-underline-offset: 4px; transition: color .2s, text-decoration-color .2s; }
.mespy-guide .gd-article a:hover { color: var(--mh-amber); text-decoration-color: var(--mh-amber); }
.mespy-guide .gd-article code.literal { font: .88em/1.5 var(--mh-mono); color: var(--mh-blue); background: none; border: 0; padding: 0; }
.mespy-guide .gd-article a code.literal { color: inherit; }
/* In running text, a long identifier breaks rather than spilling out of a
   narrow screen (Sphinx keeps each word of inline code on one line). Table
   cells keep whole identifiers; their columns are sized for them. */
.mespy-guide .gd-article :is(section > p, li, dd) code.literal { overflow-wrap: break-word; }
.mespy-guide .gd-article :is(section > p, li, dd) code.literal span.pre { white-space: normal; }
.mespy-guide .gd-article .math { color: var(--mh-ink); }
.mespy-guide .gd-article div.math { margin: 8px 0 24px; overflow-x: auto; overflow-y: hidden; }

/* Headings: the landing scale, one step smaller. */
.mespy-guide .gd-article h1 { overflow-wrap: anywhere; font-size: clamp(2.3rem, 3.4vw, 3.1rem); text-wrap: balance; margin-bottom: 26px; }
.mespy-guide .gd-article h1 + p { font-size: clamp(1.05rem, 1.4vw, 1.2rem); color: var(--mh-ink); margin-bottom: 14px; }
.mespy-guide .gd-article h2 { font-size: clamp(2rem, 3.2vw, 2.75rem); margin-bottom: 28px; }
.mespy-guide .gd-article h3 { font-size: clamp(1.45rem, 2vw, 1.85rem); margin: 0 0 18px; }
.mespy-guide .gd-article h4 { margin: 40px 0 12px; font: var(--mespy-weight-semibold) 1.15rem/var(--mespy-leading-heading) var(--mespy-font-heading); color: var(--mh-ink); }

/* Parts (H2): a rule above each, like the landing sections. */
.mespy-guide .mx-guide > section { margin-top: 96px; padding-top: 56px; border-top: 1px solid var(--mh-line); }
.mespy-guide .mx-guide > section > section { margin-top: 64px; }

/* Examples (numbered H3, numbers from mark_guide_doctree, shared with the navigator). */
.mespy-guide .gd-article .mx-guide-example { margin-top: 88px; padding-top: 48px; border-top: 1px solid var(--mh-line); }
.mespy-guide .gd-article .mx-guide-num { display: block; margin-bottom: 14px; font: var(--mespy-weight-semibold) .875rem/1.6 var(--mh-mono); letter-spacing: 0; color: var(--mh-amber); }

/* Lists: the landing's small square markers. */
.mespy-guide .gd-article ul { list-style: none; margin: 0 0 22px; padding: 0; }
.mespy-guide .gd-article ul > li { position: relative; padding-left: 22px; }
.mespy-guide .gd-article ul > li::before { content: ""; position: absolute; left: 2px; top: .72em; width: 5px; height: 5px; background: var(--mh-amber); opacity: .75; }
.mespy-guide .gd-article section > ol { margin: 0 0 22px; padding-left: 22px; }
.mespy-guide .gd-article section > ol > li::marker { font: .875rem var(--mh-mono); color: var(--mh-amber); }
.mespy-guide .gd-article li + li { margin-top: 10px; }
.mespy-guide .gd-article li > p { margin: 0; }

/* Code + output: the Get started terminal panel, code above, output below.
   Labels are real text added by label_guide_blocks (conf.py): a notebook
   output's "Risultato", or the kind of a div.mx-block (CSV, Shell, a file
   name...). Python code has no label. */
.mespy-guide .gd-article div.cell,
.mespy-guide .gd-article .mx-block,
.mespy-guide .gd-article section > div[class*="highlight-"] { margin: 30px 0 34px; border: 1px solid var(--mh-line); border-radius: 8px; background: var(--mh-panel); overflow: hidden; }
.mespy-guide .gd-article div.cell > div.cell_input { border: 0; border-radius: 0; background: transparent; }
.mespy-guide .gd-article .mx-block__label { margin: 0; padding: 12px 24px; border-bottom: 1px solid var(--mh-line); font: .875rem/1.6 var(--mh-mono); color: var(--mh-muted); overflow-wrap: anywhere; }
.mespy-guide .gd-article .cell_output > .mx-block__label { padding-block: 16px 0; border: 0; }
.mespy-guide .gd-article .mx-block > div[class*="highlight-"] { margin: 0; }
/* A row, not PyData's column: the copy button sits beside the code. */
.mespy-guide .gd-article div.highlight { position: relative; display: flex; flex-direction: row; align-items: flex-start; background: transparent; }
.mespy-guide .gd-article div.highlight pre { flex: 1 1 auto; min-width: 0; margin: 0; padding: 22px 12px 22px 24px; border: 0; border-radius: 0; background: transparent; color: var(--mh-ink); font: .86rem/1.8 var(--mh-mono); tab-size: 4; box-shadow: none; overflow-x: auto; }
.mespy-guide .gd-article .cell_output { margin: 0; padding: 0; border-top: 1px solid var(--mh-line); background: var(--mh-bg); }
.mespy-guide .gd-article .cell_output > * { margin: 0; }
.mespy-guide .gd-article .cell_output figure { margin: 0; padding: 14px 24px 18px; }
.mespy-guide .gd-article .cell_output figure:focus-visible { outline: 2px solid var(--mh-amber); outline-offset: -3px; }
.mespy-guide .gd-article .cell_output figure + .output,
.mespy-guide .gd-article .cell_output .output + figure { border-top: 1px solid var(--mh-line); }
.mespy-guide .gd-article .cell_output img { display: block; width: auto; max-width: 100%; height: auto; margin: 0 auto; padding: 8px; background: white; border-radius: 4px; }
/* Plots without a caption are a bare <img>, not a <figure>: same gutters. */
.mespy-guide .gd-article .cell_output > img { max-width: calc(100% - 48px); margin: 14px auto 18px; }
.mespy-guide .gd-article .cell_output figcaption { margin-top: 14px; text-align: left; }
.mespy-guide .gd-article .cell_output figcaption p { margin: 0; font: .875rem/1.7 var(--mespy-font-text); color: var(--mh-muted); }
.mespy-guide .gd-article .cell_output figcaption code.literal { font-size: 1em; }
.mespy-guide .gd-article .cell_output .output.stream,
.mespy-guide .gd-article .cell_output .output.text_plain { margin: 0; padding: 10px 24px 18px; border: 0; background: transparent; }
.mespy-guide .gd-article .cell_output .output pre { margin: 0; padding: 0; border: 0; background: transparent; font: .82rem/1.7 var(--mh-mono); color: var(--mh-blue); }

/* Syntax colours of the landing editor (mh-syntax-*), mapped to Pygments. */
.mespy-guide .gd-article .highlight pre * { color: var(--mh-ink); background: none; font-style: normal; font-weight: var(--mespy-weight-regular); }
.mespy-guide .gd-article .highlight pre :is(.k, .kn, .kc, .kd, .kr, .ow, .o) { color: var(--mh-syntax-keyword); }
.mespy-guide .gd-article .highlight pre :is(.nf, .na, .nb, .bp, .fm) { color: var(--mh-syntax-function); }
.mespy-guide .gd-article .highlight pre :is(.s, .s1, .s2, .sa, .sb, .sc, .sd, .se, .sh, .si, .sx, .dl) { color: var(--mh-syntax-string); }
.mespy-guide .gd-article .highlight pre :is(.m, .mi, .mf, .mh, .mo) { color: var(--mh-syntax-number); }
.mespy-guide .gd-article .highlight pre :is(.c, .c1, .cm, .ch) { color: var(--mh-syntax-comment); }

/* sphinx-copybutton, styled like the landing's copy button. It copies the
   <pre> only, and sits in its own column beside it (div.highlight is a flex
   row), so it never covers code, even on long or scrolled lines. Relative,
   not static: its tooltip is positioned against it. */
.mespy-guide .gd-article button.copybtn { position: relative; inset: auto; flex: none; margin: 12px 14px 0 0; width: auto; height: auto; padding: 5px 8px; border: 1px solid var(--mh-control-line); border-radius: 4px; background: var(--mh-panel); color: var(--mh-muted); transition: opacity .2s, color .2s, border-color .2s; }
.mespy-guide .gd-article button.copybtn:hover { color: var(--mh-amber); border-color: var(--mh-amber); }
.mespy-guide .gd-article button.copybtn:focus-visible { outline-offset: 2px; }
/* In an output, the button reaches into the padding around the text, so a
   one-line output keeps its height. */
.mespy-guide .gd-article .cell_output .output div.highlight > button.copybtn { margin: -7px 0 -7px 12px; }

/* Tables: a panel with mono headers, like the Get started protocol. */
.mespy-guide .gd-article .pst-scrollable-table-container { margin: 6px 0 36px; border: 1px solid var(--mh-line); border-radius: 5px; background: var(--mh-panel); overflow-x: auto; }
.mespy-guide .gd-article table.table { --bs-table-bg: transparent; --bs-table-accent-bg: transparent; --bs-table-border-color: var(--mh-line); width: 100%; margin: 0; border: 0; color: var(--mh-ink); font-size: 1rem; line-height: 1.6; }
.mespy-guide .gd-article table.table:has(thead th:nth-child(3):last-child) { table-layout: fixed; }
.mespy-guide .gd-article table.table:has(thead th:nth-child(3):last-child) th:nth-child(1) { width: 11rem; }
.mespy-guide .gd-article table.table:has(thead th:nth-child(3):last-child) th:nth-child(2) { width: 9.5rem; }
.mespy-guide .gd-article table.table tr,
.mespy-guide .gd-article table.table tbody tr:nth-child(n) { background: transparent; border: 0; }
.mespy-guide .gd-article table.table th,
.mespy-guide .gd-article table.table td { padding: 13px 22px 13px 0; border: 0; box-shadow: none; background: transparent; color: inherit; vertical-align: top; }
.mespy-guide .gd-article table.table :is(th, td):first-child { padding-left: 22px; }
.mespy-guide .gd-article table.table tbody tr + tr td { border-top: 1px solid var(--mh-line); }
.mespy-guide .gd-article table.table thead th { padding-block: 14px; border-bottom: 1px solid var(--mh-line); background: var(--mh-bg); font: .875rem/1.5 var(--mh-mono); color: var(--mh-muted); }
.mespy-guide .gd-article table.table :is(th, td) p { margin: 0; }
.mespy-guide .gd-article table.table td:first-child code.literal { color: var(--mh-ink); font-weight: var(--mespy-weight-semibold); }
.mespy-guide .gd-article table.table td:nth-child(2) { overflow-wrap: anywhere; }
.mespy-guide .gd-article p:has(> strong:only-child):has(+ .pst-scrollable-table-container) { margin: 36px 0 12px; font: .875rem/1.6 var(--mh-mono); }
.mespy-guide .gd-article p:has(> strong:only-child):has(+ .pst-scrollable-table-container) strong { color: var(--mh-amber); font-weight: var(--mespy-weight-regular); }

/* Key takeaway: the Get started hint, as a quiet panel. */
.mespy-guide .gd-article .admonition.mx-takeaway { max-width: var(--gd-measure); margin: 36px 0 0; padding: 18px 22px 20px; border: 1px solid var(--mh-line); border-left: 2px solid var(--mh-amber); border-radius: 0 5px 5px 0; background: var(--mh-panel); box-shadow: none !important; color: var(--mh-ink); }
.mespy-guide .gd-article .admonition.mx-takeaway > * { margin-inline: 0; }
.mespy-guide .gd-article .admonition.mx-takeaway > .admonition-title { margin: 0 0 8px; padding: 0; background: transparent; font: .875rem/1.6 var(--mh-mono); color: var(--mh-amber); }
.mespy-guide .gd-article .admonition.mx-takeaway > .admonition-title::before,
.mespy-guide .gd-article .admonition.mx-takeaway > .admonition-title::after { display: none; }
.mespy-guide .gd-article .admonition.mx-takeaway > p:last-child { margin-bottom: 0; }

/* Saved files: an editor/Colab file sidebar, rendered by a hidden notebook
   cell from the files the page actually wrote (basic-workflow.ipynb). */
.mespy-guide .gd-article div.cell:has(.mx-files) { border: 0; background: transparent; overflow: visible; }
.mespy-guide .gd-article .cell_output:has(.mx-files) { border: 0; background: transparent; }
.mespy-guide .gd-article .cell_output:has(.mx-files) > .mx-block__label { display: none; }
.mespy-guide .mx-files { width: min(380px, 100%); border: 1px solid var(--mh-line); border-radius: 8px; background: var(--mh-panel); font: .875rem/1.6 var(--mh-mono); color: var(--mh-ink); overflow: hidden; }
.mespy-guide .mx-files__bar { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 0 16px; border-bottom: 1px solid var(--mh-line); background: var(--mh-bg); color: var(--mh-muted); font-size: .875rem; }
.mespy-guide .gd-article .mx-files ul { margin: 0; padding: 0; list-style: none; }
.mespy-guide .gd-article .mx-files ul.mx-files__tree { padding-block: 10px 12px; }
.mespy-guide .gd-article .mx-files li { margin: 0; padding: 0; }
.mespy-guide .gd-article .mx-files li::before { content: none; }
.mespy-guide .mx-files__dir { display: flex; align-items: center; gap: 8px; padding: 5px 16px; }
.mespy-guide .mx-files__chev { width: 10px; color: var(--mh-muted); font-size: .85rem; line-height: 1; }
.mespy-guide .mx-files__folder { width: 13px; height: 10px; border: 1px solid var(--mh-muted); border-radius: 1px; box-shadow: inset 0 2px 0 var(--mh-muted); }
.mespy-guide .gd-article .mx-files li.mx-files__file { display: grid; grid-template-columns: 4rem minmax(0, 1fr) auto 6px; align-items: center; gap: 12px; padding: 5px 16px 5px 40px; background: var(--mh-amber-tint); }
.mespy-guide .mx-files__type { justify-self: start; padding: 0 4px; border: 1px solid var(--mh-amber-line); border-radius: 2px; font-size: .875rem; line-height: 1.6; color: var(--mh-amber); }
.mespy-guide .mx-files__type--toml { border-color: var(--mh-blue-line); color: var(--mh-blue); }
.mespy-guide .mx-files__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mespy-guide .mx-files__size { color: var(--mh-muted); font-size: .875rem; }
.mespy-guide .mx-files__new { width: 6px; height: 6px; background: var(--mh-amber); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1150px) {
  .mespy-guide .gd-layout { grid-template-columns: 210px minmax(0, 1fr); gap: 48px; }
}
@media (max-width: 959.98px) {
  .mespy-guide .gd-layout { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
  .mespy-guide .gd-aside { display: none; }
  html:has(body.mespy-guide) { scroll-padding-top: 88px; }
  .mespy-guide .mx-guide-menu { display: block; position: sticky; top: 0; z-index: 20; margin: 0 -36px 44px; padding: 12px 36px; background: var(--mh-bg); border-bottom: 1px solid var(--mh-line); }
  .mespy-guide .mx-guide-menu__summary { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 8px 14px; border: 1px solid var(--mh-control-line); border-radius: 3px; cursor: pointer; list-style: none; }
  .mespy-guide .mx-guide-menu__summary::-webkit-details-marker { display: none; }
  .mespy-guide .mx-guide-menu__summary:hover { border-color: var(--mh-amber); }
  .mespy-guide .mx-guide-menu__label { flex: none; font: .875rem/1.6 var(--mh-mono); color: var(--mh-muted); }
  .mespy-guide .mx-guide-menu__current { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .875rem; font-weight: var(--mespy-weight-semibold); color: var(--mh-ink); }
  .mespy-guide .mx-guide-menu__chevron { flex: none; width: 7px; height: 7px; margin: 0 4px 3px 0; border-right: 1px solid var(--mh-muted); border-bottom: 1px solid var(--mh-muted); transform: rotate(45deg); transition: transform .2s; }
  .mespy-guide .mx-guide-menu[open] .mx-guide-menu__chevron { transform: translateY(3px) rotate(-135deg); }
  .mespy-guide .mx-guide-menu__panel { position: absolute; inset: calc(100% - 4px) 36px auto; max-height: min(70vh, 540px); overflow-y: auto; padding: 22px 22px 24px; border: 1px solid var(--mh-line); border-radius: 5px; background: var(--mh-panel); box-shadow: 0 18px 40px var(--mh-shadow); }
}
@media (max-width: 600px) {
  .mespy-guide .mx-guide-menu { margin-inline: -20px; padding-inline: 20px; }
  .mespy-guide .mx-guide-menu__panel { inset-inline: 20px; }
  .mespy-guide .gd-layout { padding-bottom: 80px; }
  .mespy-guide .mx-guide > section { margin-top: 72px; padding-top: 44px; }
  .mespy-guide .gd-article .mx-guide-example { margin-top: 64px; padding-top: 40px; }
  .mespy-guide .gd-article div.highlight pre { padding: 18px 8px 18px 16px; font-size: .76rem; }
  .mespy-guide .gd-article button.copybtn { margin: 10px 10px 0 0; }
  .mespy-guide .gd-article .mx-block__label,
  .mespy-guide .gd-article .cell_output .output.stream,
  .mespy-guide .gd-article .cell_output .output.text_plain { padding-inline: 16px; }
  /* Wide figures scroll sideways instead of shrinking below legibility. */
  .mespy-guide .gd-article .cell_output figure { padding: 12px 16px 16px; overflow-x: auto; }
  .mespy-guide .gd-article .cell_output > img { max-width: calc(100% - 32px); margin: 12px auto 16px; }
  .mespy-guide .gd-article .cell_output figure img { width: 34rem; max-width: none; }
  .mespy-guide .gd-article .cell_output figure.mx-plot-wide img { width: 46rem; }
  .mespy-guide .gd-article .cell_output figcaption { position: sticky; left: 0; max-width: calc(100vw - 72px); }
  .mespy-guide .gd-article table.table:has(thead th:nth-child(3):last-child) th:nth-child(1) { width: 8.5rem; }
  .mespy-guide .gd-article table.table:has(thead th:nth-child(3):last-child) th:nth-child(2) { width: 6.5rem; }
  .mespy-guide .gd-article table.table :is(th, td):first-child { padding-left: 14px; }
  .mespy-guide .gd-article table.table th,
  .mespy-guide .gd-article table.table td { padding-right: 14px; }
}
/* Too narrow for the menu label and the current section on one line: the
   label goes above, the chevron stays at the right of both. */
@media (max-width: 480px) {
  .mespy-guide .mx-guide-menu__summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; row-gap: 0; }
  .mespy-guide .mx-guide-menu__chevron { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}
@media print {
  .mespy-guide .gd-aside, .mespy-guide .mx-guide-menu { display: none !important; }
  .mespy-guide .gd-layout { display: block; padding: 0; }
}
