.ann-chapter{--ch-bg:var(--nb-bg);--ch-fg:var(--nb-fg);--ch-muted:var(--muted);--ch-line:var(--line);--ch-code:var(--nb-panel);--ch-accent:var(--accent);background:transparent;color:var(--ch-fg);border:0;border-radius:0;padding:0;margin:24px 0;font-family:system-ui,sans-serif;line-height:1.8;min-width:0}
.ann-chapter *{box-sizing:border-box}.ann-chapter h2{font:700 clamp(28px,4vw,38px)/1.25 system-ui,sans-serif;max-width:24ch;margin:10px 0 22px}.ann-chapter h3{font:700 clamp(22px,3vw,28px)/1.35 system-ui,sans-serif;margin:0 0 20px}.ann-chapter h4{font-size:16px;line-height:1.4;margin:0 0 14px}
.ann-chapter p{margin:0 0 20px;font-size:17px}.ch-section{padding:36px 0;border-top:1px solid var(--ch-line);scroll-margin-top:90px}.ch-section>p,.ch-section>h3{max-width:76ch}
.ch-toc{padding:16px 0;border-block:1px solid var(--ch-line);margin:26px 0}.ch-toc ol{columns:2;padding-left:22px;margin:12px 0}.ch-toc li{break-inside:avoid;margin-bottom:8px;font-size:14px;line-height:1.5}.ann-chapter a{color:var(--ch-accent);text-underline-offset:3px}.ch-top{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.ch-top span{font-size:12px;letter-spacing:.1em;color:var(--ch-accent);font-weight:700}
.ann-chapter button,.ann-chapter select{min-height:44px;padding:8px 13px;border:1px solid var(--ch-line);border-radius:8px;background:var(--ch-code);color:var(--ch-fg);font:inherit;cursor:pointer}.ann-chapter :focus-visible{outline:2px solid var(--ch-accent);outline-offset:3px}
.ch-formula{background:var(--ch-code);border-left:3px solid var(--ch-accent);padding:20px;white-space:pre-wrap;overflow-wrap:anywhere;font:15px/1.9 ui-monospace,monospace;border-radius:6px;margin:22px 0}
.ch-code{background:var(--ch-code);border:1px solid var(--ch-line);border-radius:10px;overflow:hidden;margin:22px 0}.ch-code>div{font-size:12px;color:var(--ch-muted);padding:8px 16px;border-bottom:1px solid var(--ch-line)}.ch-code pre{padding:16px;margin:0;overflow:auto;max-width:100%;font:14px/1.8 ui-monospace,monospace;tab-size:4;white-space:pre}.ch-code code{font:inherit;color:inherit}
.ch-check{border-left:3px solid #aa7b22;padding:4px 18px;margin:24px 0}.ch-check p{font-size:16px;margin:10px 0}.ch-check summary{min-height:44px;cursor:pointer;color:var(--ch-accent)}
.ch-mini{padding:0;margin:24px 0;min-width:0;background:transparent}.ch-mini [data-chart]{border:1px solid var(--ch-line);border-radius:8px;background:var(--ch-code);padding:8px}.ch-mini svg{width:100%;height:auto;display:block}.ch-mini svg text{fill:var(--ch-fg);font:12px system-ui}.ch-mini svg .axis{stroke:var(--ch-muted);stroke-width:1;fill:none}.ch-mini svg .curve{stroke:var(--ch-accent);stroke-width:2.5;fill:none}.ch-mini svg .second{stroke:#c47c13;stroke-width:2;fill:none}.ch-mini p{font-size:13px;color:var(--ch-muted);line-height:1.6;margin:12px 0}.ch-controls{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:18px}.ch-controls label{font-size:14px;display:flex;gap:8px;align-items:center}.ch-controls input[type=range]{min-height:44px;accent-color:var(--ch-accent);max-width:100%;flex:1;min-width:90px}
.ch-plot-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}.ch-plot-grid figure{margin:0;min-width:0;padding:14px;border:1px solid var(--ch-line);border-radius:9px}.ch-plot-grid figcaption{font-size:14px;font-weight:700;line-height:1.5;margin-bottom:8px}.ch-scalar{max-width:580px}.ch-caption{color:var(--ch-muted);font-size:14px!important}.ch-live{font-variant-numeric:tabular-nums}.ch-table{overflow:auto}.ch-table table{border-collapse:collapse;min-width:320px;width:100%;font-size:14px}.ch-table th,.ch-table td{padding:10px;border-bottom:1px solid var(--ch-line);text-align:left}
@media(max-width:640px){.ch-toc ol{columns:1}.ch-plot-grid{grid-template-columns:minmax(0,1fr)}.ann-chapter p{font-size:16px}.ann-chapter{padding:0}.ch-formula{padding:14px;font-size:13px}.ch-section{padding:28px 0}.ch-controls label{flex-wrap:wrap}.ch-mini{padding:0}.ch-code pre{font-size:13px}}

/* Saved outputs remain readable even when the Python runtime is offline. */
.ann-chapter .ch-example-output { margin-block: 2rem; min-width: 0; }
.ann-chapter .ch-example-output pre { max-width: 100%; overflow: auto; padding: 1rem; font-size: .85rem; line-height: 1.7; background: var(--ch-code, #edf2f5); color: var(--ch-fg); border-radius: 10px; }
.ann-chapter .ch-recorded-grid { display: grid; gap: 1.5rem; min-width: 0; }
.ann-chapter .ch-recorded-figure { margin: 0; padding: .75rem; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 12px; min-width: 0; overflow-x: auto; }
.ann-chapter .ch-recorded-figure svg { display: block; width: 100%; min-width: 720px; height: auto; }
.ann-chapter .ch-recorded-figure .ch-controls { flex-wrap: wrap; margin-top: .5rem; }
.ann-chapter .ch-recorded-figure button { color: #153147; background: #fff; }
@media(min-width: 1400px) { .ann-chapter .ch-recorded-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }

/* Keep output text in view; reserve horizontal scrolling for plots/code. */
.ann-chapter .ch-example-output pre {
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  text-align:left;
  font-size:14px;
}
.ann-chapter .ch-recorded-figure { color:#153c35; color-scheme:light; }
.ann-chapter .ch-recorded-figure svg text { font-family:system-ui,sans-serif; }
.ann-chapter .ch-recorded-figure .ch-controls {
  position:sticky;
  left:0;
  max-width:100%;
}
.ann-chapter .ch-recorded-figure button {
  min-height:44px;
  font-size:14px;
  line-height:1.4;
  white-space:normal;
}
