/* ── Mermaid editor pane ────────────────────────────────────────────── */
#mermaid-pane {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
}
#mermaid-pane.active { display: flex; }

.me-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.me-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  height: 40px;
}
.me-toolbar::-webkit-scrollbar { display: none; }

.me-sep {
  display: inline-block;
  width: 1px; height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.me-select {
  background: var(--bg2);
  color: var(--text0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  height: 28px;
  cursor: pointer;
}
.me-select:focus { outline: 2px solid var(--accent); }

.me-btn {
  background: var(--bg2);
  color: var(--text1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  height: 28px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.me-btn i { font-size: 13px; }
.me-btn:hover { background: var(--bg3); color: var(--text0); }
.me-btn-accent { color: var(--accent); border-color: var(--accent); }
.me-btn-accent:hover { background: var(--accent); color: var(--bg0); }
.me-btn-accent.active { background: var(--accent); color: var(--bg0); }

.me-shapes { display: flex; gap: 3px; }
.me-shape-btn {
  background: var(--bg2);
  color: var(--text1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 30px; height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.me-shape-btn:hover { background: var(--bg3); color: var(--text0); }
.me-shape-btn.active { background: var(--accent); color: var(--bg0); border-color: var(--accent); }

.me-edge-group { display: flex; align-items: center; gap: 6px; }
.me-label { font-family: var(--font-ui); font-size: 11px; color: var(--text2); font-weight: 500; }

.me-workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.me-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg0);
}

#me-svg {
  width: 100%;
  height: 100%;
  display: block;
}
#me-svg:focus { outline: none; }

.me-drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text2);
  pointer-events: none;
}
.me-drop-hint[hidden] { display: none; }

/* Node port handles */
.me-port {
  fill: var(--accent);
  stroke: var(--bg0);
  stroke-width: 1.5;
  cursor: crosshair;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.me-node:hover .me-port,
.me-port.highlight {
  opacity: 1;
  pointer-events: all;
}

/* SVG node styles */
.me-shape {
  fill: var(--bg2);
  stroke: var(--accent2);
  stroke-width: 1.5;
  transition: stroke 0.15s, fill 0.15s;
}
.me-shape.selected {
  stroke: var(--accent);
  fill: var(--bg3);
  stroke-width: 2;
}
.me-shape--terminal {
  fill: var(--accent);
  stroke: none;
}
.me-shape--section { fill: var(--accent2); opacity: 0.25; }
.me-shape--c4-person { fill: #1a6fa6; }
.me-shape--c4-system { fill: #1a6fa6; }
.me-shape--c4-ext { fill: var(--bg2); }
.me-shape--boundary { fill: none; stroke-dasharray: 8 4; }
.me-class-header { fill: var(--bg3); stroke: none; }
.me-class-divider { stroke: var(--border); stroke-width: 1; fill: none; }
.me-class-member { fill: var(--text1); font-family: var(--font-mono); font-size: 11px; pointer-events: none; user-select: none; }
.me-class-stereotype { fill: var(--text2); font-family: var(--font-mono); font-size: 10px; font-style: italic; pointer-events: none; user-select: none; }
.me-task-score-bar { fill: var(--accent); }
.me-task-score-empty { fill: var(--bg1); stroke: var(--border); stroke-width: 0.5; }
.me-node { cursor: move; }
.me-svg.me-link-mode { cursor: crosshair; }
.me-svg.me-link-mode .me-node:hover { cursor: crosshair; }
.me-edge-hit { cursor: pointer; }
.me-edge-hit:hover { stroke: var(--accent); stroke-width: 2; }
.me-node.selected .me-shape { stroke: var(--accent); fill: var(--bg3); }
.me-node.selected .me-shape--terminal { filter: brightness(1.1); }
.me-node-label {
  fill: var(--text0);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}
.me-shape-line {
  stroke: var(--accent2);
  stroke-width: 1;
}
.me-node.selected .me-shape-line { stroke: var(--accent); }
.me-edge {
  fill: none;
  stroke: var(--accent2);
  stroke-width: 1.5;
  marker-end: url(#me-arrow);
}
.me-edge.dotted { stroke-dasharray: 5 3; }
.me-edge.thick  { stroke-width: 3; }
.me-edge.selected { stroke: var(--accent); stroke-width: 2; }
.me-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 10;
  cursor: pointer;
}
.me-edge--er   { stroke: var(--accent2); stroke-width: 1.5; marker-end: none; }
.me-er-label   { fill: var(--text1); font-family: var(--font-mono); font-size: 11px; dominant-baseline: auto; }
.me-edge-label {
  fill: var(--text1);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Sidebar */
.me-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg1);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
  gap: 8px;
}
.me-sidebar-title {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text2);
}
.me-prop-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.me-prop-label {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text2);
  width: 32px;
  flex-shrink: 0;
  font-weight: 500;
}
.me-prop-input {
  flex: 1;
  background: var(--bg0);
  color: var(--text0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  height: 26px;
  min-width: 0;
}
.me-prop-input--short { flex: 0 0 50px; }
.me-prop-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(63, 185, 80, 0.15); }

.me-source-area {
  flex: 1;
  background: var(--bg0);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  resize: none;
  outline: none;
  line-height: 1.5;
  min-height: 120px;
}
.me-source-area:focus { border-color: var(--accent); }

.me-status {
  height: 24px;
  padding: 0 12px;
  background: var(--bg1);
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text2);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Context menu */
.me-context-menu {
  position: fixed;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 0;
  z-index: 200;
  min-width: 140px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.me-ctx-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text0);
  font-family: var(--font-ui);
  font-size: 12px;
  padding: 6px 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.me-ctx-item:hover { background: var(--bg3); }
.me-ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 0;
}

/* Resize handles */
.me-rh {
  fill: var(--accent);
  stroke: var(--bg0);
  stroke-width: 1;
  cursor: pointer;
}
.me-rh:hover { fill: var(--accent2); }

/* Rich label foreignObject */
foreignObject.me-rich-label { pointer-events: none; }
foreignObject.me-rich-label a { pointer-events: all; }

/* Label edit popup */
.me-label-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.me-label-popup {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  min-width: 320px;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.me-label-popup-title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  color: var(--text0);
  margin-bottom: 12px;
}
.me-label-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px;
  background: var(--bg0);
  color: var(--text0);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
  box-sizing: border-box;
}
.me-label-popup-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text2);
  font-family: var(--font-ui);
}
.me-label-popup-btns {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Tab badge for mermaid tabs */
.file-tab.mermaid-tab .tab-name::before {
  content: '\2B21 ';
  color: var(--accent);
  font-size: 10px;
}