/* 图库使用整幅画布，移动端保留站点导航抽屉。 */
body:has(.diagram-gallery) .md-main { background: #f6f7f4; }
body:has(.diagram-gallery) .md-main__inner {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
}
body:has(.diagram-gallery) .md-content__inner {
  max-width: none;
  margin: 0;
  padding: 1.6rem clamp(.85rem, 3vw, 2rem) 2.5rem;
}
body:has(.diagram-gallery) .md-content__inner::before { display: none; }
.diagram-gallery {
  --ink: #18362f;
  --accent: #226757;
  --line: #d8e0da;
  color: var(--ink);
}
.dg-cover {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 9.3rem;
  display: flex;
  align-items: center;
  padding: clamp(1.3rem, 3.6vw, 2.3rem);
  border-radius: .85rem;
  color: #fff;
  background: linear-gradient(112deg, #133a32 10%, #204c40 62%, #30634e);
}
.dg-cover::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 0 35%;
  background-image: linear-gradient(#e1f9dc15 1px, transparent 1px),
                    linear-gradient(90deg, #e1f9dc15 1px, transparent 1px);
  background-size: 1.05rem 1.05rem;
  mask-image: linear-gradient(to right, transparent, black 80%);
}
.dg-intro { position: relative; z-index: 1; }
.dg-collection {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .12em;
  color: #cfe8d6;
}
.dg-collection::before {
  content: "";
  width: 1.1rem;
  height: 2px;
  background: #a1caae;
}
.dg-cover h1 {
  margin: .4rem 0 .5rem;
  font-size: clamp(1.55rem, 3.4vw, 2.35rem);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -.035em;
  color: white;
}
.dg-cover .headerlink { display: none; }
.dg-cover p { margin: 0; color: #d8e8dc; font-size: .72rem; }
.dg-blueprint {
  position: absolute;
  right: 8%;
  top: 50%;
  width: 9rem;
  height: 4.4rem;
  transform: translateY(-50%);
  color: #c8e6cb94;
  display: flex;
  justify-content: space-between;
  align-items: end;
}
.dg-blueprint i, .dg-blueprint span {
  position: relative;
  width: 2.15rem;
  height: 1.05rem;
  border: 1px solid currentColor;
  border-radius: .18rem;
  background: #bddac91c;
}
.dg-blueprint i { position: absolute; left: 50%; top: 0; transform: translateX(-50%); }
.dg-blueprint::before {
  content: "";
  position: absolute;
  top: 2.15rem;
  bottom: 1rem;
  inset-inline: 1.07rem;
  border: 1px solid currentColor;
  border-bottom: 0;
}
.dg-blueprint::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 1.05rem;
  bottom: 1.05rem;
  border-left: 1px solid currentColor;
}
.dg-categories {
  display: flex;
  gap: clamp(.65rem, 3vw, 2rem);
  margin: .55rem 0 1.3rem;
  border-bottom: 1px solid var(--line);
}
.dg-categories a {
  padding: .7rem .06rem .55rem;
  border-bottom: 2px solid transparent;
  font-size: .73rem;
  line-height: 1.4;
  color: #4e6059;
}
.dg-categories a:is(:hover, [aria-current]) { color: var(--accent); border-color: currentColor; }
.dg-categories a[aria-current] { font-weight: 700; }
.dg-heading, .dg-details, .dg-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.dg-heading { justify-content: start; margin-bottom: .65rem; }
.dg-heading h2 { margin: 0; font-size: 1.05rem; letter-spacing: -.025em; }
.dg-total, .dg-status { color: #576a61; font-size: .68rem; }
.dg-total { font-variant-numeric: tabular-nums; }
.dg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: .85rem;
}
.dg-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: .55rem;
  box-shadow: 0 2px 6px #18362f06;
}
.dg-preview, .dg-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  container-type: size;
}
.dg-preview {
  width: 100%;
  aspect-ratio: 5 / 6;
  cursor: zoom-in;
  background-color: #edf1ed;
  background-image: radial-gradient(#c3cec5 0.75px, transparent 1px);
  background-size: .46rem .46rem;
}
.dg-preview img {
  width: auto;
  height: auto;
  max-width: 96cqw;
  max-height: 96cqh;
  box-shadow: 0 2px 9px #223e3429;
}
.dg-preview img.dg-rotated { max-width: 96cqh; max-height: 96cqw; }
.dg-rotated { transform: rotate(-90deg); }
.dg-expand {
  position: absolute;
  right: .45rem;
  bottom: .45rem;
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fffffff2;
  color: var(--accent);
  opacity: 0;
}
.dg-expand svg, .dg-close svg { width: .9rem; fill: currentColor; }
.dg-preview:is(:hover, :focus-visible) .dg-expand { opacity: 1; }
.dg-details { padding: .65rem; flex-wrap: wrap; }
.dg-details h3 { margin: 0; font-size: .76rem; font-weight: 650; letter-spacing: 0; }
.dg-format {
  position: absolute;
  z-index: 1;
  top: .5rem;
  right: .5rem;
  padding: .12rem .48rem;
  border: 1px solid #c5d7ed;
  border-radius: .3rem;
  background: #f2f7ff;
  color: #235687;
  font-size: .65rem;
  font-weight: 650;
  line-height: 1.5;
  pointer-events: none;
}
.dg-format[data-format="Visio"] { color: #534183; border-color: #d4c9ea; background: #f4f1fa; }
.dg-download { margin: 0 0 0 auto; }
.dg-download button {
  display: inline-flex;
  align-items: center;
  gap: .22rem;
  padding: .3rem .5rem;
  border-radius: .3rem;
  background: #eaf3ee;
  color: #235c48;
  font-size: .68rem;
  white-space: nowrap;
  cursor: pointer;
}
.dg-download button:hover { background: #d9eade; }
.dg-download svg { width: .83rem; fill: currentColor; }
.dg-footer { display: grid; justify-items: center; gap: .55rem; margin: 1.3rem 0 0; }
.dg-heading h2 { scroll-margin-top: 5.8rem; }
.dg-pages {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
}
.dg-pages[hidden], .dg-retry[hidden] { display: none; }
.dg-pages button, .dg-retry {
  min-width: 1.8rem;
  min-height: 1.8rem;
  padding: .22rem .45rem;
  border: 1px solid var(--line);
  border-radius: .36rem;
  color: var(--ink);
  background: white;
  font-size: .72rem;
  cursor: pointer;
}
.dg-pages button:enabled:hover, .dg-retry:hover { border-color: var(--accent); }
.dg-pages button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: white; }
.dg-pages button:disabled { opacity: .45; cursor: default; }
.dg-pages span { color: #576a61; }
@media (max-width: 32rem) {
  .dg-pages { gap: .12rem; }
  .dg-pages button { min-width: 1.35rem; padding-inline: .18rem; }
}
.diagram-gallery :is(button, a):focus-visible { outline: 3px solid #438d79; outline-offset: -3px; }
.dg-dialog {
  margin: auto;
  width: min(51rem, 94vw);
  max-height: 95dvh;
  padding: 0;
  border: 0;
  border-radius: .65rem;
  background: white;
  color: var(--ink);
  box-shadow: 0 1rem 4rem #07181055;
}
.dg-dialog::backdrop { background: #12241fc9; }
body:has(.dg-dialog[open]) { overflow: hidden; }
.dg-dialog header { padding: .5rem .9rem; }
.dg-close { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; cursor: pointer; }
.dg-stage {
  display: block;
  height: min(76dvh, 47rem);
  background: #e9eeea;
}
.dg-sheet { position: relative; width: 100%; height: 100%; }
.dg-stage img {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  max-width: 98cqw;
  max-height: 98cqh;
}
.dg-stage img.dg-rotated { transform: translate(-50%, -50%) rotate(-90deg); max-width: 98cqh; max-height: 98cqw; }
@media (max-width: 38rem) {
  .dg-blueprint { display: none; }
  .dg-cover::before { inset-inline-start: 0; }
  .dg-categories { justify-content: space-between; gap: .15rem; }
  .dg-categories a { font-size: .69rem; }
  .dg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .dg-details { gap: .35rem; }
}

@media (max-width: 32rem) {
  .dg-grid { grid-template-columns: 1fr; }
  .dg-preview { aspect-ratio: 4 / 5; }
}

/* 让站点导航融入图库的配色。 */
body:has(.diagram-gallery) :is(.md-header, .md-tabs) {
  background: #183d34;
}
body:has(.diagram-gallery) .md-header {
  box-shadow: 0 1px 0 #ffffff17;
}
