/* Shared VERDA viewer chrome; the exported artwork intentionally stays on white. */
.md-diagram-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sheet);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-2);
}
.md-diagram-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.md-diagram-toolbar-copy { display: grid; gap: 4px; }
.md-diagram-toolbar-copy b { color: var(--text); font-size: 16px; }
.md-diagram-toolbar-copy span { color: var(--text-muted); font: 11px var(--font-mono); }
.md-diagram-actions, .diagram-zoom { display: flex; align-items: center; gap: 8px; }
.md-diagram-actions { flex-wrap: wrap; }
.md-diagram-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-3);
  background: var(--surface);
  color: var(--brand-strong);
  font: 600 13px var(--font-body);
  text-decoration: none;
  cursor: pointer;
}
.md-diagram-action:hover { background: var(--brand-soft); border-color: var(--brand); }
.md-diagram-action:focus-visible, .md-diagram-stage:focus-visible, .diagram-source-details summary:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: -3px;
}
.md-diagram-action:disabled { opacity: .45; cursor: default; }
.diagram-zoom { padding: 8px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.diagram-zoom output { min-width: 44px; text-align: center; font: 12px var(--font-mono); }
.diagram-zoom-hint { margin-left: auto; color: var(--text-muted); font-size: 12px; }
.md-diagram-stage {
  min-height: 360px;
  max-height: 720px;
  overflow: auto;
  padding: 28px;
  background: #fff;
  color-scheme: light;
  overscroll-behavior: contain;
}
.md-diagram-stage svg {
  display: block;
  width: var(--diagram-render-width, 100%);
  min-width: 0;
  max-width: none !important;
  max-height: none !important;
  height: auto;
  margin: 0 auto;
  color-scheme: light !important;
  background: #fff !important;
}
.md-diagram-stage svg * { color-scheme: light; }
.md-diagram-loading, .md-diagram-error {
  display: grid;
  min-height: 220px;
  place-content: center;
  gap: 12px;
  padding: var(--space-6);
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}
.md-diagram-error { color: var(--danger); }
.md-diagram-source {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font: 12px var(--font-body);
}
.diagram-source-details summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--brand-strong); }
.diagram-source-details summary::before { content: '+'; margin-right: 8px; font: 18px var(--font-mono); }
.diagram-source-details[open] summary::before { content: '−'; }
.diagram-source-details pre { padding: 16px; max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); font: 12px/1.6 var(--font-mono); }
.diagram-dialog {
  width: calc(100vw - 32px);
  max-width: none;
  height: calc(100dvh - 32px);
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sheet);
  background: var(--surface);
  color: var(--text);
}
.diagram-dialog::backdrop { background: rgb(2 27 21 / .65); }
.diagram-dialog .md-diagram-card { height: 100%; display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; }
.diagram-dialog .md-diagram-stage { min-height: 0; max-height: none; }
.diagram-dialog .md-diagram-source { max-height: 160px; overflow: auto; }
body.diagram-open { overflow: hidden; }
@media (max-width: 720px) {
  .md-diagram-toolbar { padding: 12px; gap: 8px; }
  .md-diagram-toolbar-copy { flex-basis: 100%; }
  .md-diagram-actions { width: 100%; }
  .md-diagram-action span { display: inline; }
  .md-diagram-actions .md-diagram-action { flex: 1; }
  .md-diagram-actions .diagram-edit-prefix { display: none; }
  .diagram-zoom { flex-wrap: wrap; padding: 8px 12px; }
  .diagram-zoom-hint { width: 100%; margin-left: 0; }
  .md-diagram-stage { min-height: 380px; max-height: 560px; padding: 20px; }
  .diagram-dialog { width: calc(100vw - 16px); height: calc(100dvh - 16px); }
}
