/* ─── Mermaid diagram — clickable hint ──────────────────────────────────── */

.mermaid {
  cursor: zoom-in;
  position: relative;
  transition: opacity 0.15s ease;
}

.mermaid:hover {
  opacity: 0.88;
}

.mermaid::after {
  content: '⤢';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 18px;
  color: rgba(100, 100, 120, 0.5);
  pointer-events: none;
  transition: color 0.15s;
}

.mermaid:hover::after {
  color: rgba(100, 100, 120, 0.85);
}

/* ─── ER diagram legend ─────────────────────────────────────────────────── */

.mermaid-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 20px;
  padding: 10px 16px;
  margin: 0 0 12px;
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 8px;
  font-size: 12.5px;
}

.mermaid-legend-title {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-default-fg-color--light);
  flex-basis: 100%;
  margin-bottom: 2px;
}

.mermaid-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
}

.mermaid-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mermaid-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid;
  flex-shrink: 0;
}

.mermaid-legend-label {
  color: var(--md-default-fg-color);
  white-space: nowrap;
}

/* ─── Modal overlay ─────────────────────────────────────────────────────── */

#mermaid-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

#mermaid-modal.is-open {
  display: flex;
  animation: mm-fade-in 0.18s ease;
}

@keyframes mm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.mm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

/* ─── Modal window ──────────────────────────────────────────────────────── */

.mm-window {
  position: relative;
  z-index: 1;
  width: 95vw;
  height: 92vh;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: mm-scale-in 0.18s ease;
}

@keyframes mm-scale-in {
  from { transform: scale(0.96); }
  to   { transform: scale(1); }
}

[data-md-color-scheme="slate"] .mm-window {
  background: #1a1d23;
  box-shadow: 0 32px 96px rgba(0, 0, 0, 0.7);
}

/* ─── Toolbar ───────────────────────────────────────────────────────────── */

.mm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  gap: 12px;
}

[data-md-color-scheme="slate"] .mm-toolbar {
  border-bottom-color: #2d3340;
}

.mm-hint {
  font-size: 12px;
  color: #9ca3af;
  white-space: nowrap;
}

.mm-close {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
  line-height: 1;
}

.mm-close:hover {
  background: #e5e7eb;
  color: #111827;
}

[data-md-color-scheme="slate"] .mm-close {
  background: #2d3340;
  color: #d1d5db;
}

[data-md-color-scheme="slate"] .mm-close:hover {
  background: #3d4452;
  color: #f3f4f6;
}

/* ─── Scrollable content area ───────────────────────────────────────────── */

.mm-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  background:
    radial-gradient(circle, #e5e7eb 1px, transparent 1px) 0 0 / 24px 24px;
}

[data-md-color-scheme="slate"] .mm-content {
  background:
    radial-gradient(circle, #2d3340 1px, transparent 1px) 0 0 / 24px 24px;
}

.mm-content:active {
  cursor: grabbing;
}

.mm-svg-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}

.mm-svg-wrapper svg {
  display: block;
}
