/* One shared code reader for lessons, method pages, and complete reading pages. */
.cv-code.cv-code {
  --cv-bg: #fcfbff;
  --cv-gutter: #f7f5fa;
  --cv-ink: #37313f;
  --cv-muted: #756d80;
  --cv-line: #e9e5ee;
  --cv-accent: #7251c5;
  --cv-ease: cubic-bezier(.22, 1, .36, 1);
  display: block;
  position: relative;
  min-width: 0;
  max-width: 100%;
  margin: 22px 0;
  scroll-margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--cv-line);
  border-radius: 12px;
  color: var(--cv-ink);
  background: var(--cv-bg);
  box-shadow: 0 2px 7px rgb(38 28 57 / 2%);
  text-align: left;
  isolation: isolate;
}
.cv-code.cv-code *,
.cv-code.cv-code *::before,
.cv-code.cv-code *::after { box-sizing: border-box; }

.cv-code .cv-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  min-height: 46px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--cv-line);
  color: var(--cv-muted);
  background: #f5f2fa;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-size: 12px;
  line-height: 1.4;
}
.cv-code .cv-caption {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
  margin: 0;
}
.cv-code .cv-language {
  flex: 0 0 auto;
  color: #66439a;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .025em;
}
.cv-code .cv-title {
  min-width: 0;
  max-width: 100%;
  color: #4f425e;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}
.cv-code .cv-count {
  flex: 0 0 auto;
  color: var(--cv-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.cv-code .cv-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.cv-code.cv-code .cv-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  min-width: 45px;
  min-height: 32px;
  margin: 0;
  padding: 5px 9px;
  border: 0;
  border-radius: 7px;
  color: #756186;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 180ms var(--cv-ease), color 180ms var(--cv-ease), box-shadow 180ms var(--cv-ease);
}
.cv-code.cv-code .cv-action:hover { color: #563483; background: #e9e2f5; box-shadow: none; transform: none; }
.cv-code.cv-code .cv-action:active { background: #e0d7f0; }
.cv-code.cv-code .cv-action[aria-pressed="true"] { color: #613b99; background: #e7dff3; }
.cv-code.cv-code .cv-action[data-state="copied"] { color: #176e55; background: #e3f3ea; }
.cv-code.cv-code .cv-action[data-state="retry"] { color: #935414; background: #fff0e3; }
.cv-code.cv-code .cv-action:focus-visible,
.cv-code.cv-code .cv-viewport:focus-visible { outline: 2px solid #9171c9; outline-offset: -3px; }
.cv-code .cv-action svg { width: 14px; height: 14px; flex: 0 0 auto; }

.cv-code.cv-code .cv-viewport {
  position: relative;
  min-width: 0;
  max-width: 100%;
  max-height: var(--cv-max-height, 560px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c8bed7 transparent;
  background: var(--cv-bg);
}
.cv-code .cv-viewport::-webkit-scrollbar { width: 8px; height: 8px; }
.cv-code .cv-viewport::-webkit-scrollbar-thumb { border: 2px solid var(--cv-bg); border-radius: 8px; background: #c8bed7; }
.cv-code .cv-viewport::-webkit-scrollbar-corner { background: var(--cv-bg); }

/* Keep sizing and colour independent of the surrounding Markdown renderer. */
.cv-code.cv-code .cv-viewport > pre.cv-pre {
  display: block;
  width: 100%;
  min-width: max-content;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 12px 0 14px;
  overflow: visible;
  border: 0;
  border-radius: 0;
  color: var(--cv-ink);
  background: transparent;
  box-shadow: none;
  font-family: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", "PingFang SC", monospace;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: 0;
  text-align: left;
  text-shadow: none;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  tab-size: 2;
}
.cv-code.cv-code .cv-viewport > pre.cv-pre > code.cv-source {
  display: block;
  width: 100%;
  min-width: max-content;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--cv-ink);
  background: transparent;
  font: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}
.cv-code.cv-code .cv-line {
  display: grid;
  grid-template-columns: 3.6em minmax(0, 1fr);
  align-items: start;
  min-height: 1.8em;
  padding: 0;
  border: 0;
  font: inherit;
  line-height: inherit;
  white-space: inherit;
  background: transparent;
  transition: background 180ms var(--cv-ease);
}
.cv-code.cv-code .cv-line:hover { background: #f2eef8; }
.cv-code.cv-code .cv-line-number {
  position: sticky;
  left: 0;
  z-index: 1;
  display: block;
  min-height: 1.8em;
  padding: 0 10px 0 8px;
  border: 0;
  border-right: 1px solid #ece7f1;
  color: #756b82;
  background: var(--cv-gutter);
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: calc(13px * 1.8);
  text-align: right;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}
.cv-code.cv-code .cv-line-content {
  display: block;
  min-width: 0;
  min-height: 1.8em;
  padding: 0 20px 0 14px;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  line-height: inherit;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
}
.cv-code .cv-line-content ::selection,
.cv-code .cv-line-content::selection { color: #30263f; background: #e4d7fb; }
.cv-code.cv-code .cv-line:is([data-highlighted="true"], .is-highlighted) { background: #efe7ff; }
.cv-code.cv-code .cv-line:is([data-highlighted="true"], .is-highlighted) .cv-line-number { color: #7251a3; background: #e7ddf6; }

.cv-code.cv-code:is([data-wrapped="true"], .is-wrapped) .cv-viewport > pre.cv-pre,
.cv-code.cv-code:is([data-wrapped="true"], .is-wrapped) .cv-viewport > pre.cv-pre > code.cv-source { min-width: 0; max-width: 100%; white-space: pre-wrap; }
.cv-code.cv-code:is([data-wrapped="true"], .is-wrapped) .cv-line-content {
  padding-inline-start: calc(14px + var(--cv-indent, 0ch));
  text-indent: calc(-1 * var(--cv-indent, 0ch));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* A quiet light palette keeps comments and syntax distinct at normal text sizes. */
.cv-code.cv-code .cv-source :is(.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .kw) { color: #7540a8; font-weight: 550; }
.cv-code.cv-code .cv-source :is(.hljs-built_in, .hljs-type, .hljs-title, .hljs-section, .dt, .fu) { color: #2c5ba4; }
.cv-code.cv-code .cv-source :is(.hljs-title.class_, .hljs-title.class_.inherited__, .hljs-name) { color: #765396; }
.cv-code.cv-code .cv-source :is(.hljs-string, .hljs-regexp, .hljs-addition, .st, .ss, .vs) { color: #216b54; }
.cv-code.cv-code .cv-source :is(.hljs-number, .hljs-literal, .hljs-symbol, .dv, .bn, .fl, .cn) { color: #9a541e; }
.cv-code.cv-code .cv-source :is(.hljs-comment, .hljs-quote, .co, .cv) { color: #636b65; font-style: italic; }
.cv-code.cv-code .cv-source :is(.hljs-meta, .hljs-meta .hljs-keyword, .pp, .im) { color: #8a4d74; }
.cv-code.cv-code .cv-source :is(.hljs-attr, .hljs-attribute, .hljs-params, .at) { color: #525471; }
.cv-code.cv-code .cv-source :is(.hljs-variable, .va) { color: #724268; }
.cv-code.cv-code .cv-source :is(.hljs-operator, .op) { color: #65556f; }
.cv-code.cv-code .cv-source :is(.hljs-punctuation, .bu) { color: #71667a; }
.cv-code.cv-code .cv-source :is(.hljs-deletion, .er) { color: #a34145; }
.cv-code.cv-code .cv-source .hljs-emphasis { font-style: italic; }
.cv-code.cv-code .cv-source .hljs-strong { font-weight: 650; }
.cv-code.cv-code .cv-source :is(.hljs-subst, .hljs-template-variable) { color: var(--cv-ink); }

/* Remove the old nested frames only after the shared code component is present. */
.cr-reader :is(.cr-code-section, .cr-code-file, .cr-source-file, .cr-code-block):has(.cv-code) {
  min-width: 0;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.cr-reader .cr-code-section:has(.cv-code) > summary { padding: 12px 32px 12px 0; color: #52445f; }
.cr-reader .cr-code-section:has(.cv-code) .cr-code-intro { margin: 0 0 16px; padding: 0; }
.cr-reader :is(.cr-code-file, .cr-source-file):has(.cv-code) { margin: 0 0 18px; }
.cr-reader :is(.cr-code-file, .cr-source-file):has(.cv-code) > summary { padding: 9px 32px 9px 0; color: #665277; }
.cr-reader .cr-code-content:has(.cv-code) { min-width: 0; max-width: 100%; padding: 0; }
.cr-reader .cr-code-content > .cv-code:first-child { margin-top: 0; }
.cr-reader .cr-code-content > .cv-code:last-child { margin-bottom: 0; }
div.sourceCode:has(> .cv-code) { max-width: 100%; padding: 0; border: 0; background: transparent; box-shadow: none; }

@media (max-width: 700px) {
  .cv-code.cv-code { margin: 18px 0; border-radius: 10px; scroll-margin-top: 112px; }
  .cv-code.cv-code .cv-viewport { max-height: var(--cv-max-height, min(360px, 42dvh)); }
  .cv-code .cv-toolbar { flex-wrap: wrap; gap: 3px 9px; padding: 7px 8px 7px 11px; }
  .cv-code .cv-caption { flex: 1 1 150px; gap: 5px 8px; }
  .cv-code .cv-actions { margin-left: auto; }
  .cv-code.cv-code .cv-action { min-width: 44px; min-height: 44px; padding: 8px 9px; }
  .cv-code.cv-code .cv-line { grid-template-columns: 3.1em minmax(0, 1fr); }
  .cv-code.cv-code .cv-line-number { padding-right: 8px; padding-left: 4px; }
  .cv-code.cv-code .cv-line-content { padding-left: 10px; padding-right: 14px; }
  .cv-code.cv-code:is([data-wrapped="true"], .is-wrapped) .cv-line-content { padding-inline-start: calc(10px + var(--cv-indent, 0ch)); }
}
@media (prefers-reduced-motion: reduce) {
  .cv-code .cv-action,
  .cv-code .cv-line { transition-duration: .01ms; }
}
@media print {
  details:has(.cv-code) { display: block; }
  details:has(.cv-code)::details-content { content-visibility: visible; }
  details:has(.cv-code) > :not(summary) { display: block !important; }
  .cv-code.cv-code { overflow: visible; break-inside: auto; border-color: #ddd; box-shadow: none; }
  .cv-code .cv-actions { display: none; }
  .cv-code.cv-code .cv-viewport { max-height: none; overflow: visible; }
  .cv-code.cv-code .cv-viewport > pre.cv-pre,
  .cv-code.cv-code .cv-viewport > pre.cv-pre > code.cv-source { min-width: 0; max-width: 100%; white-space: pre-wrap; break-inside: auto; }
  .cv-code.cv-code .cv-line { break-inside: avoid; }
  .cv-code.cv-code .cv-line-number { position: static; }
  .cv-code.cv-code .cv-line-content { white-space: pre-wrap; overflow-wrap: anywhere; padding-inline-start: calc(14px + var(--cv-indent, 0ch)); text-indent: calc(-1 * var(--cv-indent, 0ch)); }
}
