/* DevTools Markdown
 * Scoped styling for rendered markdown blocks under `.md-body`.
 * Keep it global, but avoid impacting non-markdown content.
 */

:root {
  --md-inline-code-bg: rgba(15, 23, 42, 0.06);
  --md-inline-code-border: rgba(15, 23, 42, 0.1);
  --md-pre-border: rgba(15, 23, 42, 0.12);
  --md-pre-bg: rgba(248, 250, 252, 0.95);
  --md-shell-border: rgba(15, 23, 42, 0.12);
  --md-shell-bg: rgba(248, 250, 252, 0.95);
  --md-shell-header-border: rgba(15, 23, 42, 0.12);
  --md-shell-header-bg: rgba(241, 245, 249, 0.9);
  --md-shell-pill-border: rgba(15, 23, 42, 0.16);
  --md-shell-pill-bg: rgba(255, 255, 255, 0.9);
  --md-shell-pill-text: rgba(15, 23, 42, 0.78);
  --md-shell-btn-border: rgba(15, 23, 42, 0.18);
  --md-shell-btn-bg: rgba(255, 255, 255, 0.9);
  --md-shell-btn-text: rgba(15, 23, 42, 0.75);
  --md-mermaid-label: rgba(15, 23, 42, 0.72);
  --md-mermaid-raw-border: rgba(15, 23, 42, 0.12);
  --md-mermaid-raw-bg: rgba(241, 245, 249, 0.68);
  --md-image-border: rgba(15, 23, 42, 0.12);
  --md-image-bg: rgba(255, 255, 255, 0.75);
  --md-hljs-fg: #0f172a;
  --md-hljs-muted: #64748b;
  --md-hljs-keyword: #1d4ed8;
  --md-hljs-string: #15803d;
  --md-hljs-number: #b45309;
  --md-hljs-title: #0f766e;
  --md-hljs-builtin: #be123c;
  --md-hljs-variable: #0f766e;
}

.dark-style {
  --md-inline-code-bg: rgba(30, 41, 59, 0.58);
  --md-inline-code-border: rgba(148, 163, 184, 0.32);
  --md-pre-border: rgba(148, 163, 184, 0.2);
  --md-pre-bg: rgba(2, 8, 23, 0.62);
  --md-shell-border: rgba(148, 163, 184, 0.2);
  --md-shell-bg: rgba(2, 8, 23, 0.62);
  --md-shell-header-border: rgba(148, 163, 184, 0.24);
  --md-shell-header-bg: rgba(15, 23, 42, 0.72);
  --md-shell-pill-border: rgba(148, 163, 184, 0.24);
  --md-shell-pill-bg: rgba(30, 41, 59, 0.82);
  --md-shell-pill-text: rgba(226, 232, 240, 0.88);
  --md-shell-btn-border: rgba(148, 163, 184, 0.24);
  --md-shell-btn-bg: rgba(30, 41, 59, 0.82);
  --md-shell-btn-text: rgba(226, 232, 240, 0.88);
  --md-mermaid-label: rgba(226, 232, 240, 0.82);
  --md-mermaid-raw-border: rgba(148, 163, 184, 0.22);
  --md-mermaid-raw-bg: rgba(15, 23, 42, 0.5);
  --md-image-border: rgba(148, 163, 184, 0.18);
  --md-image-bg: rgba(2, 8, 23, 0.35);
  --md-hljs-fg: #e2e8f0;
  --md-hljs-muted: rgba(226, 232, 240, 0.62);
  --md-hljs-keyword: color-mix(in srgb, var(--matrix-color-b, #38bdf8) 72%, #a78bfa);
  --md-hljs-string: color-mix(in srgb, var(--matrix-color-a, #22c55e) 76%, #86efac);
  --md-hljs-number: #fbbf24;
  --md-hljs-title: color-mix(in srgb, var(--matrix-color-b, #38bdf8) 84%, #e2e8f0);
  --md-hljs-builtin: #fb7185;
  --md-hljs-variable: #93c5fd;
}

.md-body :where(code, pre, samp, kbd) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.md-body :where(code) {
  font-size: 0.92em;
}

.md-body {
  color: inherit;
  line-height: 1.58;
}

.md-body :where(h1, h2, h3, h4, h5, h6) {
  margin: 1.5rem 0 0.75rem 0;
  line-height: 1.2;
}

.md-body :where(h1:first-child, h2:first-child, h3:first-child, h4:first-child) {
  margin-top: 0;
}

.md-body :where(p, ul, ol, blockquote, pre, table) {
  margin: 0 0 1rem 0;
}

.md-body :where(ul, ol) {
  padding-inline-start: 1.25rem;
}

.md-body :where(li) {
  margin: 0.25rem 0;
}

.md-body :where(a) {
  color: var(--matrix-color-b, var(--bs-primary));
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.md-body :where(a:hover, a:focus) {
  text-decoration-thickness: 3px;
}

.md-body :where(code):not(pre code) {
  background: var(--md-inline-code-bg);
  border: 1px solid var(--md-inline-code-border);
  border-radius: 8px;
  padding: 0.08em 0.35em;
}

.md-body :where(blockquote) {
  padding: 0.85rem 1rem;
  border-left: 4px solid color-mix(in srgb, var(--matrix-color-b, #38bdf8) 60%, rgba(15, 23, 42, 0.16));
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.04);
}

.dark-style .md-body :where(blockquote) {
  background: rgba(148, 163, 184, 0.08);
}

.md-body :where(blockquote > :last-child) {
  margin-bottom: 0;
}

.md-body :where(hr) {
  border: 0;
  border-top: 1px solid rgba(15, 23, 42, 0.14);
  margin: 1.5rem 0;
}

.dark-style .md-body :where(hr) {
  border-top-color: rgba(148, 163, 184, 0.20);
}

.md-body :where(table) {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  overflow: hidden;
}

.dark-style .md-body :where(table) {
  border-color: rgba(148, 163, 184, 0.14);
}

.md-body :where(th, td) {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.10);
  vertical-align: top;
}

.dark-style .md-body :where(th, td) {
  border-bottom-color: rgba(148, 163, 184, 0.12);
}

.md-body :where(th) {
  text-align: left;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.04);
}

.dark-style .md-body :where(th) {
  background: rgba(2, 8, 23, 0.30);
}

.md-body :where(tbody tr:nth-child(2n)) {
  background: rgba(15, 23, 42, 0.02);
}

.dark-style .md-body :where(tbody tr:nth-child(2n)) {
  background: rgba(148, 163, 184, 0.05);
}

:is(.md-body, .docs-content) .md-code-shell {
  margin: 0 0 1rem 0;
  border: 1px solid var(--md-shell-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--md-shell-bg);
}

:is(.md-body, .docs-content) .md-code-shell > .md-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.24rem 0.48rem;
  border-bottom: 1px solid var(--md-shell-header-border);
  background: var(--md-shell-header-bg);
}

:is(.md-body, .docs-content) .md-code-lang {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--md-shell-pill-border);
  background: var(--md-shell-pill-bg);
  color: var(--md-shell-pill-text);
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.025em;
  padding: 0.16rem 0.38rem;
  text-transform: lowercase;
}

:is(.md-body, .docs-content) .md-copy-btn {
  border: 1px solid var(--md-shell-btn-border);
  background: var(--md-shell-btn-bg);
  color: var(--md-shell-btn-text);
  border-radius: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.2rem 0.42rem;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

:is(.md-body, .docs-content) .md-copy-btn:hover,
:is(.md-body, .docs-content) .md-copy-btn:focus {
  background: var(--matrix-color-b, var(--bs-primary));
  border-color: var(--matrix-color-b, var(--bs-primary));
  color: #ffffff;
}

:is(.md-body, .docs-content) .md-copy-btn.is-copied {
  background: color-mix(in srgb, var(--matrix-color-a, #22c55e) 55%, #16a34a);
  border-color: color-mix(in srgb, var(--matrix-color-a, #22c55e) 55%, #16a34a);
  color: #ffffff;
}

:is(.md-body, .docs-content) .md-code-shell > pre {
  margin: 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.md-body :where(pre) {
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--md-pre-border);
  background: var(--md-pre-bg);
  overflow: auto;
}

:is(.md-body, .docs-content) .md-mermaid-shell {
  margin: 0 0 1rem 0;
  border: 1px solid var(--md-shell-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--md-shell-bg);
}

:is(.md-body, .docs-content) .md-mermaid-toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.24rem 0.48rem;
  border-bottom: 1px solid var(--md-shell-header-border);
  background: var(--md-shell-header-bg);
}

:is(.md-body, .docs-content) .md-mermaid-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--md-mermaid-label);
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1;
  flex: 0 0 auto;
}

:is(.md-body, .docs-content) .md-mermaid-controls {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(112px, 1fr) auto auto auto;
  gap: 0.34rem;
  width: 100%;
  min-width: 0;
}

:is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-zoom-slider="true"] {
  grid-column: 1;
}

:is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-reset="true"] {
  grid-column: 2;
}

:is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-raw="true"] {
  grid-column: 3;
}

:is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-zoom-state="true"] {
  grid-column: 4;
}

:is(.md-body, .docs-content) .md-mermaid-zoom-slider {
  width: 100%;
  height: 1.15rem;
  min-width: 0;
  accent-color: var(--matrix-color-b, var(--bs-primary));
}

:is(.md-body, .docs-content) .md-mermaid-btn {
  border: 1px solid var(--md-shell-btn-border);
  background: var(--md-shell-btn-bg);
  color: var(--md-shell-btn-text);
  border-radius: 8px;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.26rem 0.5rem;
  min-width: 2.1rem;
  white-space: nowrap;
  cursor: pointer;
}

:is(.md-body, .docs-content) .md-mermaid-btn:hover,
:is(.md-body, .docs-content) .md-mermaid-btn:focus {
  background: var(--matrix-color-b, var(--bs-primary));
  border-color: var(--matrix-color-b, var(--bs-primary));
  color: #ffffff;
}

:is(.md-body, .docs-content) .md-mermaid-zoom-state {
  font-size: 0.66rem;
  font-weight: 700;
  min-width: 3.5rem;
  text-align: center;
  color: var(--md-mermaid-label);
}

:is(.md-body, .docs-content) .md-mermaid-viewport {
  margin: 0;
  padding: 10px;
  overflow: auto;
  max-height: min(72vh, 780px);
}

:is(.md-body, .docs-content) .md-mermaid-viewport > :where(pre.mermaid, div.mermaid) {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

:is(.md-body, .docs-content) .md-mermaid-viewport svg {
  display: block;
  max-width: none;
}

@media (max-width: 640px) {
  :is(.md-body, .docs-content) .md-mermaid-toolbar {
    align-items: stretch;
    gap: 0.45rem;
  }

  :is(.md-body, .docs-content) .md-mermaid-label {
    display: none;
  }

  :is(.md-body, .docs-content) .md-mermaid-controls {
    grid-template-columns: minmax(86px, 1fr) auto;
    grid-template-areas:
      'slider zoom'
      'reset raw';
    row-gap: 0.4rem;
  }

  :is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-zoom-slider="true"] {
    grid-area: slider;
  }

  :is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-zoom-state="true"] {
    grid-area: zoom;
    justify-self: end;
  }

  :is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-reset="true"] {
    grid-area: reset;
    justify-self: start;
  }

  :is(.md-body, .docs-content) .md-mermaid-controls [data-md-mermaid-raw="true"] {
    grid-area: raw;
    justify-self: end;
  }

  :is(.md-body, .docs-content) .md-mermaid-zoom-state {
    min-width: 2.8rem;
  }
}

:is(.md-body, .docs-content) .md-mermaid-raw {
  border-top: 1px solid var(--md-mermaid-raw-border);
  background: var(--md-mermaid-raw-bg);
}

:is(.md-body, .docs-content) .md-mermaid-raw > pre {
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  max-height: 260px;
  overflow: auto;
}

/* highlight.js theme files often set a light background; keep ours controlled by `pre` above. */
:is(.md-body, .docs-content) :where(.hljs) {
  background: transparent !important;
  color: var(--md-hljs-fg) !important;
}

:is(.md-body, .docs-content) :where(pre code.hljs) {
  padding: 0 !important;
}

/* Keep syntax token colors readable in both light and dark themes. */
:is(.md-body, .docs-content) :where(.hljs-comment, .hljs-quote) {
  color: var(--md-hljs-muted) !important;
  font-style: italic;
}

:is(.md-body, .docs-content) :where(.hljs-doctag, .hljs-keyword, .hljs-formula, .hljs-selector-id, .hljs-selector-class) {
  color: var(--md-hljs-keyword) !important;
}

:is(.md-body, .docs-content) :where(.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string) {
  color: var(--md-hljs-string) !important;
}

:is(.md-body, .docs-content) :where(.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet) {
  color: var(--md-hljs-number) !important;
}

:is(.md-body, .docs-content) :where(.hljs-title, .hljs-section, .hljs-name, .hljs-selector-tag, .hljs-tag) {
  color: var(--md-hljs-title) !important;
}

:is(.md-body, .docs-content) :where(.hljs-built_in, .hljs-type, .hljs-class .hljs-title, .hljs-function .hljs-title) {
  color: var(--md-hljs-builtin) !important;
}

:is(.md-body, .docs-content) :where(.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params, .hljs-variable, .hljs-template-variable) {
  color: var(--md-hljs-variable) !important;
}

:is(.md-body, .docs-content) :where(.hljs-emphasis) {
  font-style: italic;
}

:is(.md-body, .docs-content) :where(.hljs-strong) {
  font-weight: 700;
}

.md-body :where(img) {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 14px;
  border: 1px solid var(--md-image-border);
  background: var(--md-image-bg);
}

/* Utility: used throughout templates to prevent flex children from overflowing their container. */
.min-width-0 {
  min-width: 0 !important;
}
