.theme-diagram {
  display: block;
  margin: 1.25rem auto;
  text-align: center;
  /* Default inline width. Set per diagram with a width attribute on the embed:
     <span class="theme-diagram" width="45%"> ... </span>
     width="" sets the ACTUAL size (any CSS width: %, px, ch, ...), so small
     diagrams scale up too; still capped at 100% of the column.
     Equivalent: style="--diagram-width: 45%" (cap-only, never upscales;
     takes precedence over width=""). */
  --diagram-width: 680px;
}

.theme-diagram img {
  display: block;
  margin-inline: auto;
  max-width: min(100%, var(--diagram-width));
  height: auto;
  cursor: zoom-in;
}

/* An explicit width="..." sets the actual size (small diagrams scale up too),
   not just a cap. */
.theme-diagram[width] img {
  width: var(--diagram-width);
}

/* Small struct layouts (narrow, few fields) */
.theme-diagram.diagram-sm {
  --diagram-width: 360px;
}

/* Large flowcharts / structure maps that stay unreadable below ~1000px */
.theme-diagram.diagram-lg {
  --diagram-width: 1000px;
}

.theme-diagram .diagram-dark {
  display: none;
}

html.coal .theme-diagram .diagram-light,
html.navy .theme-diagram .diagram-light,
html.ayu .theme-diagram .diagram-light {
  display: none;
}

html.coal .theme-diagram .diagram-dark,
html.navy .theme-diagram .diagram-dark,
html.ayu .theme-diagram .diagram-dark {
  display: block;
}

.diagram-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.82);
}

.diagram-lightbox.is-open {
  display: flex;
}

.diagram-lightbox img {
  max-width: min(96vw, 1600px);
  max-height: 92vh;
  background: transparent;
  cursor: zoom-out;
}

.diagram-lightbox.is-light img {
  background: #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  padding: 2.5rem;
  box-sizing: border-box;
}

.diagram-lightbox button {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.25rem;
  background: rgba(15, 23, 42, 0.9);
  color: white;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

/* Callouts */
.admonition {
  margin: 1rem 0;
  padding: 0.6rem 1rem;
  border-left: 4px solid;
  border-radius: 0 0.375rem 0.375rem 0;
}

.admonition-title {
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.admonition.note { border-color: #2f81f7; background: rgba(47, 129, 247, 0.10); }
.admonition.note .admonition-title { color: #2f81f7; }

.admonition.tip { border-color: #2da44e; background: rgba(45, 164, 78, 0.10); }
.admonition.tip .admonition-title { color: #2da44e; }

.admonition.warn { border-color: #d29922; background: rgba(210, 153, 34, 0.12); }
.admonition.warn .admonition-title { color: #9a6700; }

.admonition.danger { border-color: #cf222e; background: rgba(207, 34, 46, 0.10); }
.admonition.danger .admonition-title { color: #cf222e; }

html.coal .admonition.warn .admonition-title,
html.navy .admonition.warn .admonition-title,
html.ayu .admonition.warn .admonition-title { color: #e3b341; }
