/* KernelInk 1.0.3 — long-form reading and Markdown */
.markdown,
.nb-markdown {
  color: var(--text);
  font-size: clamp(0.98rem, 1.2vw, 1.04rem);
  line-height: 1.88;
  overflow-wrap: anywhere;
  word-break: normal;
}

#articleContent[data-reader-font-size="xs"] {
  font-size: clamp(0.86rem, 0.98vw, 0.92rem);
}

#articleContent[data-reader-font-size="sm"] {
  font-size: clamp(0.92rem, 1.08vw, 0.98rem);
}

#articleContent[data-reader-font-size="md"] {
  font-size: clamp(0.98rem, 1.2vw, 1.04rem);
}

#articleContent[data-reader-font-size="lg"] {
  font-size: clamp(1.06rem, 1.28vw, 1.13rem);
}

#articleContent[data-reader-font-size="xl"] {
  font-size: clamp(1.14rem, 1.38vw, 1.22rem);
}

.markdown > *:first-child,
.nb-markdown > *:first-child {
  margin-top: 0;
}

.markdown > *:last-child,
.nb-markdown > *:last-child {
  margin-bottom: 0;
}

.markdown :is(h1, h2, h3, h4, h5, h6),
.nb-markdown :is(h1, h2, h3, h4, h5, h6) {
  position: relative;
  margin: 1.8em 0 0.72em;
  color: var(--text);
  font-weight: 740;
  line-height: 1.35;
  letter-spacing: -0.025em;
  scroll-margin-top: 22px;
  text-wrap: balance;
}

.markdown h1,
.nb-markdown h1 {
  padding-bottom: 0.42em;
  border-bottom: 1px solid var(--line);
  font-size: clamp(1.65rem, 3.8vw, 2.2rem);
}

.markdown h2,
.nb-markdown h2 {
  padding-left: 0.72em;
  font-size: clamp(1.4rem, 3vw, 1.8rem);
}

.markdown h2::before,
.nb-markdown h2::before {
  position: absolute;
  top: 0.18em;
  bottom: 0.18em;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.34);
  content: "";
}

.markdown h3,
.nb-markdown h3 {
  font-size: clamp(1.18rem, 2.2vw, 1.42rem);
}

.markdown h4,
.nb-markdown h4 {
  font-size: 1.08rem;
}

.markdown h5,
.nb-markdown h5,
.markdown h6,
.nb-markdown h6 {
  color: var(--text-soft);
  font-size: 0.98rem;
}

.markdown p,
.nb-markdown p {
  margin: 1em 0;
  color: var(--text-soft);
}

.markdown strong,
.nb-markdown strong {
  color: var(--text);
  font-weight: 760;
}

.markdown em,
.nb-markdown em {
  color: color-mix(in srgb, var(--text-soft) 78%, var(--syntax-amber));
}

.markdown a,
.nb-markdown a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-color: rgba(var(--accent-rgb), 0.38);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.markdown a:hover,
.nb-markdown a:hover {
  text-decoration-color: var(--accent-strong);
}

.markdown :is(ul, ol),
.nb-markdown :is(ul, ol) {
  margin: 1em 0;
  padding-left: 1.55em;
  color: var(--text-soft);
}

.markdown ul,
.nb-markdown ul {
  list-style: square;
}

.markdown ol,
.nb-markdown ol {
  list-style: decimal;
}

.markdown li,
.nb-markdown li {
  padding-left: 0.16em;
}

.markdown li + li,
.nb-markdown li + li {
  margin-top: 0.38em;
}

.markdown li::marker,
.nb-markdown li::marker {
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 0.84em;
  font-variant-numeric: tabular-nums;
}

.markdown blockquote,
.nb-markdown blockquote {
  position: relative;
  margin: 1.35em 0;
  padding: 1em 1.2em 1em 1.25em;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: rgba(var(--accent-rgb), 0.04);
  color: var(--text-soft);
}

.markdown blockquote::before,
.nb-markdown blockquote::before {
  position: absolute;
  top: -0.18em;
  right: 0.25em;
  color: rgba(var(--accent-rgb), 0.1);
  content: "”";
  font-family: Georgia, serif;
  font-size: 4.5rem;
  line-height: 1;
}

.markdown blockquote > :first-child,
.nb-markdown blockquote > :first-child {
  margin-top: 0;
}

.markdown blockquote > :last-child,
.nb-markdown blockquote > :last-child {
  margin-bottom: 0;
}

.markdown :not(pre) > code,
.nb-markdown :not(pre) > code {
  padding: 0.16em 0.4em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(var(--accent-rgb), 0.07);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 0.88em;
  word-break: break-word;
}

.markdown pre,
.nb-markdown pre {
  position: relative;
  margin: 1.45em 0;
  padding: 22px 20px;
  overflow: auto;
  border: 1px solid rgba(218, 255, 229, 0.11);
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(126, 231, 135, 0.025) 1px, transparent 1px),
    #07100c;
  background-size: 36px 100%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  color: #dce8e0;
  scrollbar-color: rgba(218, 255, 229, 0.16) transparent;
  tab-size: 2;
}

html[data-theme="light"] .markdown pre,
html[data-theme="light"] .nb-markdown pre {
  color-scheme: dark;
}

.markdown pre code,
.nb-markdown pre code {
  display: block;
  width: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.72;
  overflow-wrap: normal;
  word-break: normal;
  white-space: pre;
}

.markdown img,
.nb-markdown img {
  width: auto;
  max-width: 100%;
  margin: 1.45em auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-panel);
}

.markdown figure,
.nb-markdown figure {
  margin: 1.5em 0;
}

.markdown figure img,
.nb-markdown figure img {
  margin-bottom: 0;
}

.markdown figcaption,
.nb-markdown figcaption {
  margin-top: 0.68em;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: center;
}

.markdown table,
.nb-markdown table {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 1.45em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-spacing: 0;
  border-radius: 12px;
  color: var(--text-soft);
  font-size: 0.88rem;
  scrollbar-color: var(--line-strong) transparent;
}

.markdown :is(th, td),
.nb-markdown :is(th, td) {
  min-width: 120px;
  padding: 10px 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown tr:last-child td,
.nb-markdown tr:last-child td {
  border-bottom: 0;
}

.markdown :is(th, td):last-child,
.nb-markdown :is(th, td):last-child {
  border-right: 0;
}

.markdown th,
.nb-markdown th {
  background: rgba(var(--accent-rgb), 0.055);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 760;
}

.markdown tr:nth-child(even) td,
.nb-markdown tr:nth-child(even) td {
  background: var(--glass-soft);
}

/* Third-party code highlighters often render line numbers with an internal
   table/list. Keep prose table/list styling from splitting those columns. */
#articleContent :is(.code-toolbar, figure.highlight) {
  max-width: 100%;
}

#articleContent .code-toolbar {
  position: relative;
  margin: 1.45em 0;
}

#articleContent .code-toolbar > pre {
  margin: 0;
}

#articleContent figure.highlight {
  margin: 1.45em 0;
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid rgba(218, 255, 229, 0.11);
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(126, 231, 135, 0.025) 1px, transparent 1px),
    #07100c;
  background-size: 36px 100%;
  color: #dce8e0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) {
  display: table;
  width: 100%;
  max-width: none;
  margin: 0;
  overflow: visible;
  border: 0;
  border-collapse: collapse;
  border-spacing: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  table-layout: auto;
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) > thead {
  display: table-header-group;
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) > tbody {
  display: table-row-group;
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) > tfoot {
  display: table-footer-group;
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) tr {
  display: table-row;
  background: transparent;
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) :is(th, td) {
  display: table-cell;
  width: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  vertical-align: top;
}

#articleContent :is(
  table.hljs-ln,
  figure.highlight > table,
  .code-toolbar table,
  .line-numbers table,
  .prettyprint table,
  .linenums table
) tr:nth-child(even) td {
  background: transparent;
}

/* highlight.js line-numbers and Hexo-style figure.highlight tables. */
#articleContent :is(table.hljs-ln td.hljs-ln-numbers, figure.highlight td.gutter) {
  width: 3.25rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
  user-select: none;
}

#articleContent :is(table.hljs-ln td.hljs-ln-code, figure.highlight td.code) {
  width: auto;
  min-width: 0;
}

#articleContent .hljs-ln-numbers .hljs-ln-line,
#articleContent figure.highlight .gutter pre {
  padding-right: 0.85rem;
  border-right: 1px solid rgba(218, 255, 229, 0.1);
}

#articleContent .hljs-ln-code .hljs-ln-line,
#articleContent figure.highlight .code pre {
  padding-left: 0.85rem;
}

#articleContent figure.highlight :is(.gutter, .code) pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  overflow: visible;
}

/* Prism: restore the absolutely positioned row-number rail. */
#articleContent pre.line-numbers {
  position: relative;
  padding-left: 4.4rem;
  counter-reset: linenumber;
}

#articleContent pre.line-numbers > code {
  position: relative;
}

#articleContent pre.line-numbers .line-numbers-rows {
  position: absolute;
  top: 0;
  left: -4.4rem;
  width: 3.45rem;
  border-right: 1px solid rgba(218, 255, 229, 0.1);
  color: var(--text-dim);
  font-size: 100%;
  letter-spacing: -1px;
  line-height: inherit;
  pointer-events: none;
  user-select: none;
}

#articleContent pre.line-numbers .line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
}

#articleContent pre.line-numbers .line-numbers-rows > span::before {
  display: block;
  padding-right: 0.8rem;
  content: counter(linenumber);
  text-align: right;
}

/* Google Code Prettify: keep its generated ordered list as one code grid. */
#articleContent pre.prettyprint > :is(ol, ul).linenums,
#articleContent pre > :is(ol, ul).linenums {
  margin: 0;
  padding: 0 0 0 3.4rem;
  background: transparent;
  color: inherit;
  list-style: decimal outside;
}

#articleContent pre.prettyprint > :is(ol, ul).linenums > li,
#articleContent pre > :is(ol, ul).linenums > li {
  display: list-item;
  margin: 0;
  padding: 0 0 0 0.65rem;
  background: transparent;
  color: inherit;
  line-height: inherit;
}

/* A highlighter may expose its gutter as a separate pre. The theme copy
   control belongs to the code pane, never to that number-only gutter. */
#articleContent figure.highlight .gutter .nb-copy-code,
#articleContent .hljs-ln-numbers .nb-copy-code {
  display: none;
}

.markdown hr,
.nb-markdown hr {
  height: 1px;
  margin: 2.25em 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.markdown details,
.nb-markdown details {
  margin: 1.2em 0;
  padding: 0.9em 1em;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--glass-soft);
}

.markdown summary,
.nb-markdown summary {
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.markdown iframe,
.nb-markdown iframe,
.markdown video,
.nb-markdown video {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.markdown mark,
.nb-markdown mark {
  padding-inline: 0.15em;
  border-radius: 3px;
  background: rgba(255, 203, 107, 0.22);
  color: var(--text);
}

.markdown kbd,
.nb-markdown kbd {
  vertical-align: 0.05em;
}

@media (max-width: 520px) {
  .markdown,
  .nb-markdown {
    font-size: 0.96rem;
    line-height: 1.82;
  }

  .markdown pre,
  .nb-markdown pre {
    margin-inline: -7px;
    padding: 18px 15px;
    border-radius: 11px;
  }

  .markdown pre code,
  .nb-markdown pre code {
    font-size: 0.78rem;
  }
}

/* ---------- Reader typography controls ---------- */
[data-reader-font-tools] {
  display: inline-flex;
  min-width: 0;
  flex: 0 0 auto;
  align-items: center;
  margin-left: 2px;
  padding-left: 7px;
  gap: 2px;
  border-left: 1px solid var(--line);
}

[data-reader-font-tools] button {
  display: inline-grid;
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  outline-offset: 1px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 760;
  line-height: 1;
  cursor: pointer;
  transition: background-color 130ms var(--ease-ui), color 130ms var(--ease-ui), opacity 130ms var(--ease-ui);
}

[data-reader-font-reset] {
  font-size: 0.68rem;
}

[data-reader-font-tools] button:hover,
[data-reader-font-tools] button:focus-visible {
  outline: 1px solid var(--line-accent);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent-strong);
}

[data-reader-font-tools] button[aria-pressed="true"] {
  color: var(--syntax-blue);
}

[data-reader-font-tools] button:disabled {
  outline: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.34;
}

/* ---------- Article image inspector ---------- */
#articleContent img.nb-article-previewable {
  cursor: zoom-in;
  transition: border-color 150ms var(--ease-ui), box-shadow 150ms var(--ease-ui), filter 150ms var(--ease-ui);
}

#articleContent .nb-article-preview-trigger {
  outline: 0;
}

#articleContent a.nb-article-preview-trigger {
  text-decoration: none;
}

#articleContent .nb-article-preview-trigger:hover img.nb-article-previewable,
#articleContent img.nb-article-preview-trigger:hover,
#articleContent .nb-article-preview-trigger:focus-visible img.nb-article-previewable,
#articleContent img.nb-article-preview-trigger:focus-visible {
  border-color: var(--line-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.09), var(--shadow-panel);
  filter: brightness(1.035);
}

#articleContent .nb-article-preview-trigger:focus-visible,
#articleContent img.nb-article-preview-trigger:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 4px;
}

.nb-article-viewer {
  position: fixed;
  z-index: 1180;
  inset: 0;
  display: grid;
  padding: 18px;
  visibility: hidden;
  place-items: center;
  opacity: 0;
  transition: opacity 160ms var(--ease-ui), visibility 160ms var(--ease-ui);
}

.nb-article-viewer[hidden] {
  display: none;
}

.nb-article-viewer[aria-hidden="false"] {
  visibility: visible;
}

.nb-article-viewer.is-open {
  visibility: visible;
  opacity: 1;
}

.nb-article-viewer-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 35%, rgba(var(--accent-rgb), 0.055), transparent 34%),
    rgba(2, 7, 5, 0.94);
  cursor: zoom-out;
}

.nb-article-viewer-panel {
  position: relative;
  display: grid;
  width: min(1180px, 100%);
  height: min(88vh, 900px);
  height: min(88dvh, 900px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  background: var(--editor-code);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.5), var(--shadow-inner);
}

.nb-article-viewer-head,
.nb-article-viewer-foot {
  position: relative;
  z-index: 3;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  background: var(--editor-bar);
  font-family: var(--font-mono);
}

.nb-article-viewer-head {
  min-height: 46px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
}

.nb-article-viewer-head::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--accent-strong);
  border-radius: 1px;
  background: rgba(var(--accent-rgb), 0.16);
  content: "";
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.22);
}

.nb-article-viewer-head-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.nb-article-viewer-protocol {
  color: var(--text-dim);
  font-size: 0.46rem;
  letter-spacing: 0.07em;
  line-height: 1.1;
  text-transform: uppercase;
}

.nb-article-viewer-head h2 {
  margin: 0;
  overflow: hidden;
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 760;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-article-viewer-counter {
  margin-left: auto;
  color: var(--syntax-blue);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.nb-article-viewer button {
  border: 1px solid transparent;
  border-radius: 4px;
  outline-offset: 1px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 130ms var(--ease-ui), background-color 130ms var(--ease-ui), color 130ms var(--ease-ui), opacity 130ms var(--ease-ui);
}

.nb-article-viewer button:hover,
.nb-article-viewer button:focus-visible {
  border-color: var(--line-accent);
  outline: 1px solid var(--line-accent);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent-strong);
}

.nb-article-viewer button:disabled {
  border-color: transparent;
  outline: 0;
  background: transparent;
  cursor: not-allowed;
  opacity: 0.28;
}

.nb-article-viewer-close {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
}

.nb-article-viewer-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: 50px minmax(0, 1fr) 50px;
  align-items: stretch;
  overflow: hidden;
  background:
    linear-gradient(rgba(var(--accent-rgb), 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.018) 1px, transparent 1px),
    #040806;
  background-size: 34px 34px;
}

.nb-article-viewer-nav {
  position: relative;
  z-index: 4;
  width: 38px;
  min-height: 64px;
  align-self: center;
  justify-self: center;
  background: rgba(7, 14, 11, 0.84) !important;
  font-size: 1rem;
}

.nb-article-viewer-viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
}

.nb-article-viewer-viewport.is-pannable {
  cursor: grab;
}

.nb-article-viewer-viewport.is-dragging {
  cursor: grabbing;
}

.nb-article-viewer-media {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  transform-origin: center;
  will-change: transform;
  transition: transform 150ms var(--ease-ui);
}

.nb-article-viewer-viewport.is-dragging .nb-article-viewer-media {
  transition: none;
}

.nb-article-viewer-image {
  display: block;
  width: auto;
  max-width: calc(100% - 18px);
  height: auto;
  max-height: calc(100% - 18px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  object-fit: contain;
  opacity: 1;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.38);
  transition: opacity 120ms var(--ease-ui);
  -webkit-user-drag: none;
}

.nb-article-viewer-image.is-loading {
  opacity: 0.28;
}

.nb-article-viewer.has-error .nb-article-viewer-viewport::after {
  position: absolute;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(4, 8, 6, 0.7);
  color: var(--danger);
  content: "IMAGE_LOAD_ERROR";
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.nb-article-viewer-foot {
  min-height: 54px;
  justify-content: space-between;
  padding: 7px 10px 7px 14px;
  border-top: 1px solid var(--line);
}

.nb-article-viewer-meta {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.nb-article-viewer-caption {
  margin: 0;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 0.61rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-article-viewer-state {
  color: var(--text-dim);
  font-size: 0.49rem;
  font-variant-numeric: tabular-nums;
}

.nb-article-viewer-controls {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 3px;
}

.nb-article-viewer-controls button {
  display: grid;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 760;
}

.nb-article-viewer-controls .nb-article-viewer-reset {
  min-width: 44px;
  color: var(--syntax-blue);
  font-size: 0.55rem;
}

@media (max-width: 720px) {
  [data-reader-font-tools] button {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .nb-article-viewer {
    padding:
      max(6px, env(safe-area-inset-top))
      max(6px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
  }

  .nb-article-viewer-panel {
    height: calc(100vh - 12px);
    height: calc(100dvh - 12px);
    max-height: calc(100vh - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 7px;
  }

  .nb-article-viewer-head {
    min-height: 44px;
    padding-left: 10px;
    gap: 8px;
  }

  .nb-article-viewer-protocol {
    display: none;
  }

  .nb-article-viewer-stage {
    grid-template-columns: minmax(0, 1fr);
  }

  .nb-article-viewer-viewport {
    grid-column: 1;
    grid-row: 1;
  }

  .nb-article-viewer-nav {
    position: absolute;
    z-index: 5;
    top: 50%;
    width: 42px;
    height: 58px;
    min-height: 58px;
    transform: translateY(-50%);
  }

  .nb-article-viewer-prev {
    left: 5px;
  }

  .nb-article-viewer-next {
    right: 5px;
  }

  .nb-article-viewer-image {
    max-width: calc(100% - 12px);
    max-height: calc(100% - 12px);
  }

  .nb-article-viewer-foot {
    align-items: stretch;
    flex-direction: column;
    padding: 7px 9px;
    gap: 6px;
  }

  .nb-article-viewer-meta {
    min-height: 27px;
  }

  .nb-article-viewer-controls {
    width: 100%;
    justify-content: flex-end;
  }

  .nb-article-viewer-controls button {
    min-width: 42px;
    height: 42px;
  }
}

@media (max-width: 420px) {
  [data-reader-font-tools] {
    padding-left: 3px;
    gap: 0;
  }

  [data-reader-font-tools] button {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  .nb-article-viewer-counter {
    font-size: 0.53rem;
  }

  .nb-article-viewer-controls {
    justify-content: space-between;
  }

  .nb-article-viewer-controls button {
    min-width: 40px;
    height: 40px;
    padding-inline: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #articleContent img.nb-article-previewable,
  .nb-article-viewer,
  .nb-article-viewer button,
  .nb-article-viewer-media,
  .nb-article-viewer-image,
  [data-reader-font-tools] button {
    transition: none;
  }
}

@media (forced-colors: active) {
  [data-reader-font-tools] button,
  .nb-article-viewer-panel,
  .nb-article-viewer button,
  .nb-article-viewer-image {
    border: 1px solid CanvasText;
  }

  .nb-article-viewer-backdrop {
    background: Canvas;
  }
}

/* ---------- Built-in selectable syntax themes ---------- */
.nb-body[data-code-theme="kernelink"] {
  --article-code-bg: #07100c;
  --article-code-grid: rgba(126, 231, 135, 0.035);
  --article-code-border: rgba(126, 231, 135, 0.17);
  --article-code-text: #dce8e0;
  --article-code-comment: #72817d;
  --article-code-string: #a5d6ff;
  --article-code-keyword: #ff8e88;
  --article-code-number: #f2cc60;
  --article-code-function: #d8b4fe;
  --article-code-variable: #82aaff;
  --article-code-property: #7ee787;
  --article-code-operator: #ffad66;
  --article-code-tag: #7ee787;
  --article-code-constant: #ffa657;
  --article-code-builtin: #76e3ea;
  --article-code-type: #82aaff;
}

.nb-body[data-code-theme="midnight"] {
  --article-code-bg: #080d18;
  --article-code-grid: rgba(96, 165, 250, 0.04);
  --article-code-border: rgba(96, 165, 250, 0.2);
  --article-code-text: #d6e3f4;
  --article-code-comment: #66758b;
  --article-code-string: #9dd7c5;
  --article-code-keyword: #ff8fa3;
  --article-code-number: #f6c177;
  --article-code-function: #c4b5fd;
  --article-code-variable: #93c5fd;
  --article-code-property: #67e8f9;
  --article-code-operator: #fca5a5;
  --article-code-tag: #60a5fa;
  --article-code-constant: #fbbf24;
  --article-code-builtin: #5eead4;
  --article-code-type: #7dd3fc;
}

.nb-body[data-code-theme="nord"] {
  --article-code-bg: #202731;
  --article-code-grid: rgba(136, 192, 208, 0.045);
  --article-code-border: rgba(136, 192, 208, 0.23);
  --article-code-text: #d8dee9;
  --article-code-comment: #7d899b;
  --article-code-string: #a3be8c;
  --article-code-keyword: #bf8fbd;
  --article-code-number: #d08770;
  --article-code-function: #88c0d0;
  --article-code-variable: #81a1c1;
  --article-code-property: #8fbcbb;
  --article-code-operator: #e5e9f0;
  --article-code-tag: #81a1c1;
  --article-code-constant: #ebcb8b;
  --article-code-builtin: #8fbcbb;
  --article-code-type: #88c0d0;
}

.nb-body[data-code-theme="ember"] {
  --article-code-bg: #15110e;
  --article-code-grid: rgba(251, 146, 60, 0.04);
  --article-code-border: rgba(251, 146, 60, 0.2);
  --article-code-text: #f1e6dc;
  --article-code-comment: #87766a;
  --article-code-string: #d9d38c;
  --article-code-keyword: #ff8d7d;
  --article-code-number: #f6bd60;
  --article-code-function: #f4a261;
  --article-code-variable: #e9c46a;
  --article-code-property: #8fc7a1;
  --article-code-operator: #ef8354;
  --article-code-tag: #e76f51;
  --article-code-constant: #f6bd60;
  --article-code-builtin: #83c5be;
  --article-code-type: #f4a261;
}

.nb-body[data-code-theme="matrix"] {
  --article-code-bg: #020a05;
  --article-code-grid: rgba(62, 255, 112, 0.055);
  --article-code-border: rgba(62, 255, 112, 0.22);
  --article-code-text: #c9f6d4;
  --article-code-comment: #52715b;
  --article-code-string: #8ef0a8;
  --article-code-keyword: #3eff70;
  --article-code-number: #c6f68d;
  --article-code-function: #79e6a0;
  --article-code-variable: #a7f3c1;
  --article-code-property: #61d989;
  --article-code-operator: #b7f7c7;
  --article-code-tag: #3eff70;
  --article-code-constant: #d7ff91;
  --article-code-builtin: #6ee7b7;
  --article-code-type: #86efac;
}

.nb-body[data-code-theme="paper"] {
  --article-code-bg: #f7f8f6;
  --article-code-grid: rgba(43, 92, 65, 0.045);
  --article-code-border: rgba(43, 92, 65, 0.2);
  --article-code-text: #25312b;
  --article-code-comment: #7a8580;
  --article-code-string: #1f7a4c;
  --article-code-keyword: #b4234d;
  --article-code-number: #986801;
  --article-code-function: #245da8;
  --article-code-variable: #315f8c;
  --article-code-property: #1d6d50;
  --article-code-operator: #81531a;
  --article-code-tag: #176b48;
  --article-code-constant: #9a5b13;
  --article-code-builtin: #087b83;
  --article-code-type: #3f5f9b;
}

.nb-body[data-code-theme] :is(.markdown, .nb-markdown) pre,
.nb-body[data-code-theme] #articleContent figure.highlight {
  border-color: var(--article-code-border);
  background:
    linear-gradient(90deg, var(--article-code-grid) 1px, transparent 1px),
    var(--article-code-bg);
  background-size: 36px 100%;
  color: var(--article-code-text);
  color-scheme: dark;
}

.nb-body[data-code-theme="paper"] :is(.markdown, .nb-markdown) pre,
.nb-body[data-code-theme="paper"] #articleContent figure.highlight {
  color-scheme: light;
}

#articleContent pre.nb-syntax-highlighted {
  padding-top: 43px;
}

#articleContent pre.nb-syntax-highlighted::before {
  position: absolute;
  z-index: 1;
  top: 11px;
  left: 15px;
  padding: 3px 6px;
  border: 1px solid var(--article-code-border);
  border-radius: 4px;
  background: rgba(127, 127, 127, 0.06);
  color: var(--article-code-comment);
  content: attr(data-language-label);
  font-family: var(--font-mono);
  font-size: 0.54rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

#articleContent :is(.nb-syn-comment, .hljs-comment, .hljs-quote, .token.comment, .token.prolog, .token.doctype, .token.cdata, .comment) { color: var(--article-code-comment); font-style: italic; }
#articleContent :is(.nb-syn-string, .hljs-string, .hljs-regexp, .token.string, .token.char, .token.regex, .string) { color: var(--article-code-string); }
#articleContent :is(.nb-syn-keyword, .hljs-keyword, .hljs-selector-tag, .token.keyword, .keyword) { color: var(--article-code-keyword); font-weight: 700; }
#articleContent :is(.nb-syn-number, .hljs-number, .token.number, .number) { color: var(--article-code-number); }
#articleContent :is(.nb-syn-function, .hljs-title.function_, .hljs-function .hljs-title, .token.function, .function) { color: var(--article-code-function); }
#articleContent :is(.nb-syn-variable, .hljs-variable, .hljs-template-variable, .token.variable, .variable) { color: var(--article-code-variable); }
#articleContent :is(.nb-syn-property, .hljs-attr, .hljs-attribute, .token.property, .attr) { color: var(--article-code-property); }
#articleContent :is(.nb-syn-operator, .hljs-operator, .token.operator, .operator) { color: var(--article-code-operator); }
#articleContent :is(.nb-syn-tag, .hljs-tag, .hljs-name, .token.tag, .tag) { color: var(--article-code-tag); }
#articleContent :is(.nb-syn-constant, .hljs-literal, .hljs-symbol, .token.boolean, .token.constant, .literal) { color: var(--article-code-constant); }
#articleContent :is(.nb-syn-builtin, .hljs-built_in, .token.builtin, .built_in) { color: var(--article-code-builtin); }
#articleContent :is(.nb-syn-type, .hljs-type, .hljs-class .hljs-title, .token.class-name, .type) { color: var(--article-code-type); }

@media (max-width: 520px) {
  #articleContent pre.nb-syntax-highlighted {
    padding-top: 40px;
  }
}
