/* A non-modal study pane; only the transcript scrolls within the right column. */
:root { --notebook-ai-width: clamp(20rem, 36vw, 27rem); }
.notebook-ai-launch { position: fixed; right: 1.2rem; bottom: 1.2rem; z-index: 12; border: 0; border-radius: 2rem; padding: .7rem 1.1rem; background: var(--md-primary-fg-color, #333); color: white; box-shadow: 0 2px 12px #0004; cursor: pointer; font: inherit; }
.notebook-ai[hidden], .notebook-ai [hidden], .notebook-ai-launch[hidden] { display: none !important; }
body.notebook-ai-open { padding-right: var(--notebook-ai-width); }
.notebook-ai-open .md-header { right: var(--notebook-ai-width); }
.notebook-ai-open .md-grid { max-width: 100%; }
.notebook-ai-open .md-top { right: calc(var(--notebook-ai-width) + 1rem); }
.notebook-ai { position: fixed; top: 0; right: 0; bottom: 0; z-index: 11; width: var(--notebook-ai-width); height: 100dvh; display: flex; flex-direction: column; gap: .5rem; padding: .8rem; border-left: 1px solid var(--md-default-fg-color--lightest, #bbb); color: var(--md-default-fg-color, #222); background: var(--md-default-bg-color, white); font: inherit; box-shadow: -2px 0 12px #0001; }
.notebook-ai-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-shrink: 0; }
.notebook-ai-heading h2 { margin: 0; font-size: 1rem; }
.notebook-ai-heading > div { display: flex; gap: .3rem; }
.notebook-ai p, .notebook-ai details { font-size: .7rem; line-height: 1.65; margin: .25rem 0; }
.notebook-ai-summary { overflow-wrap: anywhere; color: var(--md-default-fg-color--light, #666); flex-shrink: 0; }
.notebook-ai [data-settings-view] { overflow-y: auto; min-height: 0; }
.notebook-ai form { display: grid; gap: .6rem; }
.notebook-ai label { display: grid; gap: .25rem; font-size: .75rem; }
.notebook-ai input, .notebook-ai select, .notebook-ai textarea { width: 100%; min-width: 0; padding: .45rem; border: 1px solid #8888; border-radius: .25rem; font: inherit; color: inherit; background: var(--md-default-bg-color, white); }
.notebook-ai textarea { resize: vertical; min-height: 3rem; max-height: 25dvh; }
.notebook-ai button { padding: .35rem .5rem; border: 1px solid #8888; border-radius: .3rem; cursor: pointer; font: inherit; font-size: .7rem; color: inherit; background: transparent; }
.notebook-ai button:hover { background: var(--md-code-bg-color, #eee); }
.notebook-ai button:focus-visible, .notebook-ai-launch:focus-visible { outline: 2px solid var(--md-accent-fg-color, #1565c0); outline-offset: 2px; }
.notebook-ai button:disabled { opacity: .5; cursor: wait; }
.notebook-ai .notebook-ai-consent { display: flex; align-items: flex-start; gap: .5rem; }
.notebook-ai-consent input { width: auto; margin-top: .25rem; }
.notebook-ai-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.notebook-ai [data-submit], .notebook-ai [data-save] { background: var(--md-primary-fg-color, #333); color: var(--md-primary-bg-color, white); }
.notebook-ai-chat { display: flex; flex: 1; flex-direction: column; min-height: 0; gap: .5rem; }
.notebook-ai-messages { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
.notebook-ai-message { padding: .7rem .3rem; border-bottom: 1px solid var(--md-default-fg-color--lightest, #ddd); }
.notebook-ai-role { display: block; font-size: .7rem; margin-bottom: .3rem; }
.notebook-ai-question { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .8rem; line-height: 1.7; }
.notebook-ai-user { background: var(--md-code-bg-color, #eee); border-radius: .4rem; padding: .6rem; }
.notebook-ai-failed { opacity: .65; }
.notebook-ai-chat > form, .notebook-ai-chat > [data-status] { flex-shrink: 0; }
.notebook-ai-open .md-sidebar--secondary { display: none; }
@media (min-width: 1220px) {
  .notebook-ai-open .md-sidebar--primary, .notebook-ai-open .md-sidebar--primary .md-sidebar__inner { width: 10rem; }
}
@media (max-width: 900px) {
  /* Stack on phones: keep the upper half available for browsing notes. */
  body.notebook-ai-open { padding-right: 0; padding-bottom: 51dvh; }
  .notebook-ai-open .md-header { right: 0; }
  .notebook-ai-open .md-top { right: 1rem; bottom: 52dvh; }
  .notebook-ai { top: auto; width: 100%; height: 50dvh; border-left: 0; border-top: 1px solid #8888; padding: .5rem; }
  .notebook-ai textarea { max-height: 12dvh; }
  .notebook-ai-heading h2 { font-size: .85rem; }
}
.notebook-ai-answer { white-space: normal; overflow-wrap: anywhere; line-height: 1.8; font-size: .85rem; }
.notebook-ai-answer p { font-size: inherit; margin: .7em 0; }
.notebook-ai-answer :is(h1, h2, h3, h4, h5, h6) { margin: 1em 0 .5em; line-height: 1.4; font-weight: 700; }
.notebook-ai-answer :is(h1, h2) { font-size: 1.25em; }
.notebook-ai-answer :is(h3, h4, h5, h6) { font-size: 1.1em; }
.notebook-ai-answer :is(ul, ol) { padding-left: 1.5em; margin: .6em 0; }
.notebook-ai-answer blockquote { margin: .7em 0; padding-left: .8em; border-left: 3px solid #8888; }
.notebook-ai-answer code { padding: .1em .3em; border-radius: .2em; background: var(--md-code-bg-color, #eee); font-family: monospace; }
.notebook-ai-answer pre { overflow-x: auto; padding: .7em; background: var(--md-code-bg-color, #eee); border-radius: .25em; }
.notebook-ai-answer pre code { padding: 0; white-space: pre; overflow-wrap: normal; }
.notebook-ai-answer table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: .8em 0; }
.notebook-ai-answer :is(th, td) { padding: .4em .6em; border: 1px solid #8888; }
.notebook-ai-answer th { background: var(--md-code-bg-color, #eee); }
.notebook-ai-answer .katex { font-size: 1.1em; }
.notebook-ai-answer .katex-display { overflow-x: auto; overflow-y: hidden; padding: .25em 0; }
.notebook-ai a { color: var(--md-typeset-a-color, #1565c0); text-decoration: underline; }
.notebook-ai-sources { font-size: .8rem; line-height: 1.8; }
