/* AW Code: layout of the code figure. Token colours come from the scoped theme CSS (inline). */
.aw-code {
  --aw-code-bg: #ffffff;
  --aw-code-fg: #24292e;
  --aw-code-font: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --aw-code-size: 0.875rem;
  --aw-code-line: 1.6;
  --aw-code-mark: rgba(255, 196, 0, 0.18);
  --aw-code-mark-bar: #e0a800;
  --aw-code-radius: 8px;
  display: block;
  margin: 1.5em 0;
  padding: 0;
  max-width: 100%;
  border-radius: var(--aw-code-radius);
  overflow: hidden;
  background: var(--aw-code-bg);
  color: var(--aw-code-fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(128, 128, 128, 0.18);
  font-family: var(--aw-code-font);
  font-size: var(--aw-code-size);
  line-height: var(--aw-code-line);
}
.aw-code__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-height: 2.4em;
  padding: 0.35em 0.6em 0.35em 0.9em;
  background: var(--aw-code-bg);
  color: var(--aw-code-fg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  user-select: none;
}
.aw-code__header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(128, 128, 128, 0.12);
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
  pointer-events: none;
}
.aw-code__header > * { position: relative; }
.aw-code__title {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--aw-code-font);
  font-weight: 600;
}
.aw-code__title::before {
  content: "";
  width: 0.9em;
  height: 1.05em;
  flex: none;
  border: 1.5px solid currentColor;
  border-radius: 2px 4px 2px 2px;
  opacity: 0.65;
}
.aw-code__lang {
  padding: 0.1em 0.55em;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.2);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  text-transform: none;
}
.aw-code__spacer { flex: 1; }
.aw-code__btn {
  font: inherit;
  padding: 0.2em 0.65em;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  line-height: 1.5;
  opacity: 0.85;
}
.aw-code__btn:hover,
.aw-code__btn:focus-visible { opacity: 1; background: rgba(128, 128, 128, 0.15); outline: 2px solid rgba(100, 149, 237, 0.8); outline-offset: 1px; }
.aw-code__btn[aria-pressed="true"] { background: rgba(128, 128, 128, 0.28); }
.aw-code__status { font-size: 0.72rem; opacity: 0.8; }
.aw-code__theme {
  font: inherit;
  max-width: 11em;
  padding: 0.15em 0.4em;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: 4px;
  background: transparent;
  color: inherit;
}
.aw-code__theme option { color: #111; background: #fff; }
.aw-code__body { position: relative; }
pre.aw-code__pre {
  margin: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: auto;
  white-space: pre;
  font: inherit;
  line-height: inherit;
  tab-size: 4;
  outline: none;
}
pre.aw-code__pre:focus-visible { box-shadow: inset 0 0 0 2px rgba(100, 149, 237, 0.8); }
.aw-code__code.hljs {
  display: block;
  padding: 0.8em 1em;
  background: transparent;
  color: inherit;
  font: inherit;
  white-space: pre;
  overflow: visible;
  min-width: max-content;
}
.aw-code__line {
  display: block;
  min-height: 1.6em;
  padding-left: 0;
  border-left: 3px solid transparent;
  margin-left: -1em;
  padding-left: calc(1em - 3px);
  padding-right: 1em;
  margin-right: -1em;
}
.aw-code__line.is-marked {
  background: var(--aw-code-mark);
  border-left-color: var(--aw-code-mark-bar);
}
/* Line numbers: CSS counters, so they never get copied. */
/* The number is positioned, not a flex item: a flex line drops the whitespace-only text between two
   highlighted tokens ("for h in test" lost the space before "test"). */
.aw-code--numbers .aw-code__line {
  counter-increment: aw-code-line;
  position: relative;
  padding-left: calc(1em - 3px + 4.2em);
}
.aw-code--numbers .aw-code__line::before {
  content: counter(aw-code-line);
  position: absolute;
  left: calc(1em - 3px);
  top: 0;
  bottom: 0;
  box-sizing: content-box;
  width: 2.6em;
  padding-right: 0.6em;
  border-right: 1px solid rgba(128, 128, 128, 0.3);
  text-align: right;
  color: inherit;
  opacity: 0.45;
  user-select: none;
}
.aw-code--numbers .aw-code__line > * { white-space: pre; }
/* Wrapping */
.aw-code--wrap pre.aw-code__pre,
.aw-code--wrap .aw-code__code.hljs { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.aw-code--wrap .aw-code--numbers .aw-code__line > *,
.aw-code--wrap.aw-code--numbers .aw-code__line > * { white-space: pre-wrap; }
/* Collapsed long blocks */
.aw-code--collapsed pre.aw-code__pre {
  max-height: calc(var(--aw-code-max-lines, 20) * 1.6em + 1.6em);
  overflow: hidden;
}
.aw-code--collapsed .aw-code__body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2.6em;
  height: 4em;
  background: linear-gradient(to bottom, transparent, var(--aw-code-bg));
  pointer-events: none;
}
.aw-code__expand {
  display: block;
  width: 100%;
  padding: 0.5em;
  border: 0;
  border-top: 1px solid rgba(128, 128, 128, 0.25);
  background: rgba(128, 128, 128, 0.1);
  color: inherit;
  font: inherit;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
}
.aw-code__expand:hover,
.aw-code__expand:focus-visible { background: rgba(128, 128, 128, 0.2); outline: none; }
.aw-code:not(.aw-code--collapsed) .aw-code__expand { display: none; }
/* Inline code */
code.aw-code-inline {
  padding: 0.1em 0.4em;
  border-radius: 4px;
  font-family: var(--aw-code-font);
  font-size: 0.9em;
  white-space: pre-wrap;
}
/* Small screens */
@media (max-width: 600px) {
  .aw-code { --aw-code-size: 0.8rem; border-radius: 6px; }
  .aw-code__title { max-width: 45%; }
  .aw-code--numbers .aw-code__line { padding-left: calc(1em - 3px + 3.2em); }
  .aw-code--numbers .aw-code__line::before { width: 2em; }
}
@media print {
  .aw-code { box-shadow: none; border: 1px solid #999; }
  .aw-code__btn, .aw-code__expand { display: none; }
  .aw-code--collapsed pre.aw-code__pre { max-height: none; }
}
