/* 新爱算 · 超级博客：正文扩展语法基础样式（:where 零优先级，主题可直接覆盖） */
:where(.xb-code) { position: relative; margin: 1em 0; }
:where(.xb-code-title) { padding: .45em .9em; font: 600 .85em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(127,127,127,.14); border-radius: 6px 6px 0 0; }
:where(.xb-code > pre) { margin: 0; padding: .9em 1em; overflow: auto; font-size: .9em; line-height: 1.6; tab-size: 4; background: rgba(127,127,127,.08); border-radius: 6px; }
:where(.xb-code-title + pre) { border-top-left-radius: 0; border-top-right-radius: 0; }
:where(.xb-code pre > code) { padding: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; background: none; }
:where(.xb-code .hljs) { padding: 0; background: none; }
:where(.xb-code .xb-line) { display: block; min-height: 1.6em; }
:where(.xb-code .xb-line-hl) { background: rgba(255, 196, 0, .2); box-shadow: -1em 0 0 rgba(255, 196, 0, .2), 1em 0 0 rgba(255, 196, 0, .2); }
:where(.xb-code pre[data-line-numbers] .xb-line)::before { content: attr(data-line); display: inline-block; width: 2.4em; margin-right: 1em; color: rgba(127,127,127,.85); text-align: right; user-select: none; }
:where(.xb-code-copy) { position: absolute; top: .35em; right: .35em; padding: .15em .6em; font-size: .75em; color: inherit; cursor: pointer; background: rgba(255,255,255,.75); border: 1px solid rgba(127,127,127,.35); border-radius: 4px; opacity: 0; transition: opacity .15s; }
:where(.xb-code:hover .xb-code-copy, .xb-code-copy:focus-visible) { opacity: 1; }
@media (hover: none) { :where(.xb-code-copy) { opacity: 1; } }
:where(.markdown-alert) { --xb-alert: #0969da; margin: 1em 0; padding: .6em 1em; background: rgba(127,127,127,.06); border-left: 4px solid var(--xb-alert); border-radius: 0 6px 6px 0; }
:where(.markdown-alert > :last-child) { margin-bottom: 0; }
:where(.markdown-alert-title) { margin: 0 0 .3em; font-weight: 600; color: var(--xb-alert); }
:where(.markdown-alert-tip) { --xb-alert: #1a7f37; }
:where(.markdown-alert-important) { --xb-alert: #8250df; }
:where(.markdown-alert-warning) { --xb-alert: #9a6700; }
:where(.markdown-alert-caution) { --xb-alert: #cf222e; }
:where(.xb-details) { margin: 1em 0; padding: .5em 1em; border: 1px solid rgba(127,127,127,.3); border-radius: 6px; }
:where(.xb-details > summary) { font-weight: 600; cursor: pointer; }
:where(.xb-container) { margin: 1em 0; padding: .6em 1em; background: rgba(127,127,127,.08); border-radius: 6px; }
:where(.xb-toc) { margin: 1em 0; padding: .6em 1em; font-size: .95em; border: 1px solid rgba(127,127,127,.25); border-radius: 6px; }
:where(.xb-toc ol) { margin: 0; padding-left: 1.4em; }
:where(.xb-link-card) { display: flex; flex-direction: column; gap: .2em; padding: .7em 1em; color: inherit; text-decoration: none; border: 1px solid rgba(127,127,127,.3); border-radius: 8px; }
:where(.xb-link-card:hover) { border-color: rgba(127,127,127,.6); }
:where(.xb-link-card-title) { font-weight: 600; overflow-wrap: anywhere; }
:where(.xb-link-card-host) { font-size: .85em; opacity: .7; }
/* 表情图片始终与文字同行：主题常把正文图片设为块级居中，这里用 img.xb-emoji（0,1,1，晚于主题样式加载）保证行内显示 */
img.xb-emoji { display: inline-block; width: auto; height: 1.4em; max-width: none; margin: 0 .05em; vertical-align: -.3em; border-radius: 0; }
:where(.math) { overflow-x: auto; overflow-y: hidden; }
:where(div.math) { margin: 1em 0; text-align: center; }
:where(pre.mermaid) { overflow-x: auto; text-align: center; background: none; }
:where(.contains-task-list) { padding-left: 1.4em; list-style: none; }
:where(.task-list-item-checkbox) { margin: 0 .45em 0 -1.4em; vertical-align: middle; }
:where([data-xb-embed]) { margin: 1em 0; }
/* 图片说明、图集、音频卡片、视频、附件卡片。组件内部的布局用两个类名（0,2,0）：主题常见的 .content figure / figcaption / a
   样式不会把卡片与图集挤乱，主题仍可用更具体的选择器改写；颜色只用半透明灰与 currentColor，浅色、深色模式通用。 */
:where(.xb-figure) { margin: 1.5em 0; text-align: center; }
:where(.xb-figure img, .xb-figure video) { max-width: 100%; height: auto; margin-inline: auto; }
:where(.xb-figure > figcaption, .xb-video > figcaption, .xb-gallery-caption) { margin-top: .6em; font-size: .875em; line-height: 1.6; text-align: center; opacity: .78; }
:where(.xb-gallery) { --xb-gallery-cols: 3; --xb-gallery-gap: 8px; --xb-gallery-ratio: 1; margin: 1.5em 0; }
:where(.xb-gallery[data-cols="2"]) { --xb-gallery-cols: 2; }
:where(.xb-gallery[data-cols="4"]) { --xb-gallery-cols: 4; }
:where(.xb-gallery[data-cols="5"]) { --xb-gallery-cols: 5; }
:where(.xb-gallery[data-cols="6"]) { --xb-gallery-cols: 6; }
:where(.xb-gallery-items) { display: grid; grid-template-columns: repeat(var(--xb-gallery-cols), minmax(0, 1fr)); gap: var(--xb-gallery-gap); align-items: start; }
.xb-gallery-items > .xb-gallery-item { min-width: 0; margin: 0; padding: 0; }
.xb-gallery-items .xb-gallery-item img { display: block; width: 100%; max-width: 100%; height: auto; margin: 0; aspect-ratio: var(--xb-gallery-ratio); object-fit: cover; border-radius: 6px; }
.xb-gallery-items .xb-gallery-item picture { display: block; }
:where(.xb-gallery-item > figcaption) { margin-top: .35em; font-size: .8em; line-height: 1.5; text-align: center; opacity: .78; overflow-wrap: anywhere; }
.xb-gallery-masonry > .xb-gallery-items { display: block; column-count: var(--xb-gallery-cols); column-gap: var(--xb-gallery-gap); }
.xb-gallery-masonry > .xb-gallery-items > .xb-gallery-item { display: block; margin: 0 0 var(--xb-gallery-gap); break-inside: avoid; -webkit-column-break-inside: avoid; }
.xb-gallery-masonry .xb-gallery-items .xb-gallery-item img { aspect-ratio: auto; object-fit: initial; }
@media (max-width: 640px) {
  :where(.xb-gallery[data-cols="4"], .xb-gallery[data-cols="5"], .xb-gallery[data-cols="6"]) { --xb-gallery-cols: 3; }
  :where(.xb-gallery-masonry) { --xb-gallery-cols: 2; }
}
@media (max-width: 420px) {
  :where(.xb-gallery) { --xb-gallery-cols: 2; --xb-gallery-gap: 6px; }
}
.xb-audio { display: grid; grid-template-columns: 88px minmax(0, 1fr); grid-template-areas: "cover info" "cover player"; align-items: center; gap: 6px 16px; margin: 1.5em 0; padding: 12px; border: 1px solid rgba(127,127,127,.28); border-radius: 12px; background: rgba(127,127,127,.06); }
.xb-audio.has-tools { grid-template-columns: 88px minmax(0, 1fr) auto; grid-template-areas: "cover info tools" "cover player player"; }
.xb-audio > .xb-audio-cover { grid-area: cover; display: block; width: 88px; height: 88px; max-width: none; margin: 0; object-fit: cover; border-radius: 8px; }
.xb-audio > .xb-audio-cover-empty { display: grid; place-items: center; background: rgba(127,127,127,.18); }
.xb-audio > .xb-audio-cover-empty::before { content: "♪"; font-size: 40px; line-height: 1; opacity: .55; }
.xb-audio > .xb-audio-info { grid-area: info; display: flex; flex-direction: column; gap: 2px; min-width: 0; margin: 0; text-align: start; font-size: 1em; opacity: 1; }
:where(.xb-audio-title) { font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
:where(.xb-audio-meta) { font-size: .85em; opacity: .7; font-variant-numeric: tabular-nums; }
.xb-audio > .xb-audio-player { grid-area: player; display: block; width: 100%; min-width: 0; height: 40px; margin: 0; }
.xb-audio > .xb-media-tools { grid-area: tools; align-self: start; }
@media (max-width: 480px) {
  .xb-audio { grid-template-columns: 56px minmax(0, 1fr); grid-template-areas: "cover info" "player player"; padding: 10px; }
  .xb-audio.has-tools { grid-template-columns: 56px minmax(0, 1fr) auto; grid-template-areas: "cover info tools" "player player player"; }
  .xb-audio > .xb-audio-cover { width: 56px; height: 56px; }
  .xb-audio > .xb-audio-cover-empty::before { font-size: 26px; }
}
:where(.xb-video) { margin: 1.5em 0; }
:where(.xb-video video) { display: block; width: 100%; max-width: 100%; height: auto; margin: 0 auto; background: #000; border-radius: 8px; }
.xb-attachment { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; max-width: 640px; margin: 1.2em 0; }
.xb-attachment > .xb-attachment-link { display: flex; flex: 1 1 260px; align-items: center; gap: 12px; min-width: 0; padding: 10px 14px; color: inherit; text-decoration: none; border: 1px solid rgba(127,127,127,.3); border-radius: 10px; background: rgba(127,127,127,.04); }
.xb-attachment > .xb-attachment-link:hover { border-color: rgba(127,127,127,.6); background: rgba(127,127,127,.08); }
.xb-attachment > .xb-attachment-link:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.xb-attachment .xb-attachment-icon { --xb-file: #6b7280; display: grid; flex: none; place-items: end center; width: 38px; height: 46px; padding-bottom: 7px; box-sizing: border-box; color: #fff; font: 700 10px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .02em; border-radius: 4px 12px 4px 4px; background: linear-gradient(225deg, rgba(255,255,255,.55) 0 8px, transparent 8px), var(--xb-file); }
.xb-attachment .xb-attachment-icon[data-kind="pdf"] { --xb-file: #c5221f; }
.xb-attachment .xb-attachment-icon[data-kind="archive"] { --xb-file: #9a5b00; }
.xb-attachment .xb-attachment-icon[data-kind="doc"] { --xb-file: #1d5fd1; }
.xb-attachment .xb-attachment-icon[data-kind="sheet"] { --xb-file: #137333; }
.xb-attachment .xb-attachment-icon[data-kind="slide"] { --xb-file: #b4460f; }
.xb-attachment .xb-attachment-icon[data-kind="text"] { --xb-file: #4b5563; }
.xb-attachment .xb-attachment-body { display: flex; flex: 1; flex-direction: column; gap: 2px; min-width: 0; }
.xb-attachment .xb-attachment-name { font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.xb-attachment .xb-attachment-meta { font-size: .82em; opacity: .7; font-variant-numeric: tabular-nums; }
.xb-attachment .xb-attachment-action { flex: none; padding: 4px 12px; font-size: .85em; line-height: 1.5; white-space: nowrap; border: 1px solid rgba(127,127,127,.45); border-radius: 999px; }
.xb-attachment > .xb-pdf-preview { flex: 1 0 100%; }
@media (max-width: 420px) {
  .xb-attachment .xb-attachment-action { display: none; }
}
@media print {
  .xb-audio > .xb-audio-player { display: none; }
  .xb-gallery-item, .xb-audio, .xb-attachment { break-inside: avoid; }
}
@media (prefers-color-scheme: dark) {
  :where(.xb-code-copy) { background: rgba(0,0,0,.45); }
  :where(.markdown-alert) { --xb-alert: #4493f8; }
  :where(.markdown-alert-tip) { --xb-alert: #3fb950; }
  :where(.markdown-alert-important) { --xb-alert: #ab7df8; }
  :where(.markdown-alert-warning) { --xb-alert: #d29922; }
  :where(.markdown-alert-caution) { --xb-alert: #f85149; }
}