/* Spec 06: 仅补 main.css 缺失的 tag-plugin 样式（tabs/timeline/gallery/button/checkbox 已在 main.css） */

.md-text .mermaid {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  margin: var(--gap-p) 0;
}

.md-text .mermaid span,
.md-text .mermaid text {
  font-family: inherit;
}

.md-text .mermaid .edgeLabel {
  padding: 4px;
  background-color: var(--background) !important;
}

.md-text .mermaid rect.basic.label-container {
  stroke: var(--block-border) !important;
  fill: var(--block) !important;
}

/* Mermaid 暗色适配 - 块1：系统暗色偏好（prefers-color-scheme）且未手动设为浅色 */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .md-text .mermaid {
    fill: #ccc !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .error-icon {
    fill: #a44141 !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .error-text {
    fill: #ddd !important;
    stroke: #ddd !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .marker {
    fill: lightgrey !important;
    stroke: lightgrey !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .marker.cross {
    stroke: lightgrey !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .label {
    color: #ccc !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .cluster-label text {
    fill: #F9FFFE !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .cluster-label span {
    color: #F9FFFE !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .label text,
  :root:not([data-theme="light"]) .md-text .mermaid span {
    fill: #ccc !important;
    color: #ccc !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .node rect,
  :root:not([data-theme="light"]) .md-text .mermaid .node circle,
  :root:not([data-theme="light"]) .md-text .mermaid .node ellipse,
  :root:not([data-theme="light"]) .md-text .mermaid .node polygon,
  :root:not([data-theme="light"]) .md-text .mermaid .node path {
    fill: #1f2020 !important;
    stroke: #81B1DB !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .arrowheadPath {
    fill: lightgrey !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .edgePath .path {
    stroke: lightgrey !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .flowchart-link {
    stroke: lightgrey !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .edgeLabel {
    background-color: hsl(0, 0%, 34.4117647059%) !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .edgeLabel rect {
    background-color: hsl(0, 0%, 34.4117647059%) !important;
    fill: hsl(0, 0%, 34.4117647059%) !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .cluster rect {
    fill: hsl(180, 1.5873015873%, 28.3529411765%) !important;
    stroke: rgba(255, 255, 255, 0.25) !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .cluster text {
    fill: #F9FFFE !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .cluster span {
    color: #F9FFFE !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid div.mermaidTooltip {
    background: hsl(20, 1.5873015873%, 12.3529411765%) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
  }
  :root:not([data-theme="light"]) .md-text .mermaid .flowchartTitleText {
    fill: #ccc;
  }
}

/* Mermaid 暗色适配 - 块2：手动切换为暗色模式（覆盖系统浅色偏好） */
:root[data-theme="dark"] .md-text .mermaid {
  fill: #ccc !important;
}
:root[data-theme="dark"] .md-text .mermaid .error-icon {
  fill: #a44141 !important;
}
:root[data-theme="dark"] .md-text .mermaid .error-text {
  fill: #ddd !important;
  stroke: #ddd !important;
}
:root[data-theme="dark"] .md-text .mermaid .marker {
  fill: lightgrey !important;
  stroke: lightgrey !important;
}
:root[data-theme="dark"] .md-text .mermaid .marker.cross {
  stroke: lightgrey !important;
}
:root[data-theme="dark"] .md-text .mermaid .label {
  color: #ccc !important;
}
:root[data-theme="dark"] .md-text .mermaid .cluster-label text {
  fill: #F9FFFE !important;
}
:root[data-theme="dark"] .md-text .mermaid .cluster-label span {
  color: #F9FFFE !important;
}
:root[data-theme="dark"] .md-text .mermaid .label text,
:root[data-theme="dark"] .md-text .mermaid span {
  fill: #ccc !important;
  color: #ccc !important;
}
:root[data-theme="dark"] .md-text .mermaid .node rect,
:root[data-theme="dark"] .md-text .mermaid .node circle,
:root[data-theme="dark"] .md-text .mermaid .node ellipse,
:root[data-theme="dark"] .md-text .mermaid .node polygon,
:root[data-theme="dark"] .md-text .mermaid .node path {
  fill: #1f2020 !important;
  stroke: #81B1DB !important;
}
:root[data-theme="dark"] .md-text .mermaid .arrowheadPath {
  fill: lightgrey !important;
}
:root[data-theme="dark"] .md-text .mermaid .edgePath .path {
  stroke: lightgrey !important;
}
:root[data-theme="dark"] .md-text .mermaid .flowchart-link {
  stroke: lightgrey !important;
}
:root[data-theme="dark"] .md-text .mermaid .edgeLabel {
  background-color: hsl(0, 0%, 34.4117647059%) !important;
}
:root[data-theme="dark"] .md-text .mermaid .edgeLabel rect {
  background-color: hsl(0, 0%, 34.4117647059%) !important;
  fill: hsl(0, 0%, 34.4117647059%) !important;
}
:root[data-theme="dark"] .md-text .mermaid .cluster rect {
  fill: hsl(180, 1.5873015873%, 28.3529411765%) !important;
  stroke: rgba(255, 255, 255, 0.25) !important;
}
:root[data-theme="dark"] .md-text .mermaid .cluster text {
  fill: #F9FFFE !important;
}
:root[data-theme="dark"] .md-text .mermaid .cluster span {
  color: #F9FFFE !important;
}
:root[data-theme="dark"] .md-text .mermaid div.mermaidTooltip {
  background: hsl(20, 1.5873015873%, 12.3529411765%) !important;
  border: 1px solid rgba(255, 255, 255, 0.25) !important;
}
:root[data-theme="dark"] .md-text .mermaid .flowchartTitleText {
  fill: #ccc;
}

/* ---------- Spec 21: ghrepo/ghuser 卡片（.tag-plugin.ghcard 基础在 main.css，此处补内部结构） ---------- */
.tag-plugin.ghcard .ghrepo-card,
.tag-plugin.ghcard .ghuser-card {
  display: block;
  padding: 1rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--block-border);
  transition: box-shadow 0.2s ease-out, transform 0.2s ease-out;
  line-height: 1.5;
  min-width: 240px;
  max-width: 400px;
}
.tag-plugin.ghcard a.ghcard:hover .ghrepo-card,
.tag-plugin.ghcard a.ghcard:hover .ghuser-card {
  box-shadow: 0 12px 20px -4px rgba(0,0,0,0.15);
  transform: translate3d(0, -2px, 0);
}
.tag-plugin.ghcard .repo-header,
.tag-plugin.ghcard .user-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tag-plugin.ghcard .repo-avatar {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  margin: 0;
}
.tag-plugin.ghcard .user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0;
}
.tag-plugin.ghcard .repo-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-p1);
}
.tag-plugin.ghcard .user-info {
  display: flex;
  flex-direction: column;
}
.tag-plugin.ghcard .user-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-p1);
}
.tag-plugin.ghcard .user-login {
  font-size: 0.8125rem;
  color: var(--text-p3);
}
.tag-plugin.ghcard .repo-desc,
.tag-plugin.ghcard .user-bio {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-p2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tag-plugin.ghcard .repo-stats,
.tag-plugin.ghcard .user-stats {
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-p3);
}
.tag-plugin.ghcard .repo-lang {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tag-plugin.ghcard .lang-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ---------- Spec 20: swiper 轮播（对齐 _plugins/swiper.styl） ---------- */
:root {
  --swiper-theme-color: var(--theme) !important;
}
.swiper {
  width: 100%;
  border-radius: 4px;
  --gap-p: 2rem;
}
.swiper:not(.swiper-initialized) {
  display: none;
}
div.swiper-slide {
  text-align: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  align-self: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
  width: 50%;
}
div.swiper-slide img {
  border-radius: 4px;
}
.swiper[width='max'] .swiper-slide {
  width: 100%;
}
.swiper[width='min'] .swiper-slide {
  width: 25%;
}
.swiper[effect='cards'] .swiper-slide {
  max-width: 75%;
}
.swiper-button-prev,
.swiper-button-next {
  padding: 1rem 0.25rem;
  margin-top: -2rem !important;
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease-out;
  --swiper-theme-color: var(--text) !important;
}
.swiper-button-prev:after,
.swiper-button-next:after {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  color: var(--swiper-theme-color);
}
.swiper-button-prev:hover,
.swiper-button-next:hover {
  background: white !important;
  --swiper-theme-color: var(--accent) !important;
}
.swiper-button-prev:after {
  transform: translateX(-1px);
}
.swiper-button-next:after {
  transform: translateX(1px);
}

/* ---------- Spec 20: rating 评分（对齐 tag-plugins/rating.styl） ---------- */
.tag-plugin.ds-rating {
  text-align: center;
}
.tag-plugin.ds-rating .header {
  margin: .5rem;
  font-weight: 500;
  color: var(--text);
}
.tag-plugin.ds-rating .body {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tag-plugin.ds-rating .body button {
  color: var(--theme);
  font-size: 1rem;
  padding: 0;
  border-radius: 4px;
  display: flex;
  opacity: 0.2;
  transition: all 0.2s ease-out;
}
.tag-plugin.ds-rating .body button svg {
  font-size: 1.5em;
  margin: 4px;
}
.tag-plugin.ds-rating .body button img {
  margin: 4px;
}
.tag-plugin.ds-rating .body button:hover,
.tag-plugin.ds-rating .body button.hover,
.tag-plugin.ds-rating .body button.preview {
  opacity: 1;
}
.tag-plugin.ds-rating .body span {
  line-height: 1;
  font-size: 1em;
  margin: 4px;
}
.tag-plugin.ds-rating .footer {
  margin: .5rem;
  color: var(--text-p3);
  font-weight: 500;
  font-size: 0.75rem;
}
.tag-plugin.ds-rating.rated {
  pointer-events: none;
}

/* ---------- Spec 20: swiper 轮播（对齐 _plugins/swiper.styl） ---------- */
:root {
  --swiper-theme-color: var(--theme) !important;
}
.swiper {
  width: 100%;
  border-radius: 4px;
  --gap-p: 2rem;
}
.swiper:not(.swiper-initialized) {
  display: none;
}
div.swiper-slide {
  text-align: center;
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  align-self: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
  width: 50%;
}
div.swiper-slide img {
  border-radius: 4px;
}
.swiper[width='max'] .swiper-slide {
  width: 100%;
}
.swiper[width='min'] .swiper-slide {
  width: 25%;
}
.swiper[effect='cards'] .swiper-slide {
  max-width: 75%;
}
.swiper-button-prev,
.swiper-button-next {
  padding: 1rem 0.25rem;
  margin-top: -2rem !important;
  border-radius: 40px;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.2s ease-out;
  --swiper-theme-color: var(--text) !important;
}
.swiper-button-prev:after,
.swiper-button-next:after {
  font-size: 1.2rem !important;
  font-weight: 700 !important;
  color: var(--swiper-theme-color);
}
.swiper-button-prev:hover,
.swiper-button-next:hover {
  background: white !important;
  --swiper-theme-color: var(--accent) !important;
}
.swiper-button-prev:after {
  transform: translateX(-1px);
}
.swiper-button-next:after {
  transform: translateX(1px);
}

/* ---------- Spec 20: rating 评分（对齐 tag-plugins/rating.styl） ---------- */
.tag-plugin.ds-rating {
  text-align: center;
}
.tag-plugin.ds-rating .header {
  margin: .5rem;
  font-weight: 500;
  color: var(--text);
}
.tag-plugin.ds-rating .body {
  display: flex;
  align-items: center;
  justify-content: center;
}
.tag-plugin.ds-rating .body button {
  color: var(--theme);
  font-size: 1rem;
  padding: 0;
  border-radius: 4px;
  display: flex;
  opacity: 0.2;
  transition: all 0.2s ease-out;
}
.tag-plugin.ds-rating .body button svg {
  font-size: 1.5em;
  margin: 4px;
}
.tag-plugin.ds-rating .body button img {
  margin: 4px;
}
.tag-plugin.ds-rating .body button:hover,
.tag-plugin.ds-rating .body button.hover,
.tag-plugin.ds-rating .body button.preview {
  opacity: 1;
}
.tag-plugin.ds-rating .body span {
  line-height: 1;
  font-size: 1em;
  margin: 4px;
}
.tag-plugin.ds-rating .footer {
  margin: .5rem;
  color: var(--text-p3);
  font-weight: 500;
  font-size: 0.75rem;
}
.tag-plugin.ds-rating.rated {
  pointer-events: none;
}
