/* Nebula 3.7.0 — 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;
}

.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: calc(var(--header-h) + 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;
  }
}

/* ---------- Built-in selectable syntax themes ---------- */
.nb-body[data-code-theme="nebula"] {
  --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;
  }
}
