.schematic-markdown {
  --sm-panel: #ffffff;
  --sm-ink: #172033;
  --sm-muted: #647084;
  --sm-line: #d8dee9;
  --sm-danger: #b42318;
  --sm-warn: #9a5b00;
  margin: 1.5rem 0;
  color: var(--sm-ink);
}

.schematic-markdown .diagram-card {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--sm-line);
  border-radius: 10px;
  background: var(--sm-panel);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.schematic-markdown .diagram-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--sm-line);
  color: var(--sm-muted);
  font-size: 0.85rem;
  font-weight: 650;
}

.schematic-markdown .diagram-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.schematic-markdown .download-svg {
  display: none;
}

.schematic-markdown .diagram-canvas {
  overflow: auto;
  padding: 1rem;
  scrollbar-color: #64748b #e2e8f0;
  scrollbar-width: auto;
}

.schematic-markdown .diagram-canvas::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.schematic-markdown .diagram-canvas::-webkit-scrollbar-track {
  background: #e2e8f0;
}

.schematic-markdown .diagram-canvas::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 7px;
  background: #64748b;
  background-clip: padding-box;
}

.schematic-markdown .diagram-svg {
  display: block;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}

.schematic-markdown .symbol-shell { overflow: visible; }
.schematic-markdown .symbol-label {
  fill: #172033;
  font: 600 12px/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
}
.schematic-markdown .wire {
  fill: none;
  stroke: #2563eb;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.schematic-markdown .wire-underlay {
  fill: none;
  stroke: #ffffff;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.schematic-markdown .junction-dot { fill: currentColor; }
.schematic-markdown .net-label text {
  font: 600 11px/1 Inter, ui-sans-serif, system-ui, sans-serif;
}
.schematic-markdown .net-label-scope { font-size: 9px; font-weight: 800; }
.schematic-markdown .net-label-local polygon { stroke-dasharray: 3 2; }
.schematic-markdown .no-connect line {
  stroke: #dc2626;
  stroke-width: 2;
  stroke-linecap: round;
}
.schematic-markdown .fallback-symbol {
  fill: #f8fafc;
  stroke: currentColor;
  stroke-width: 1.5;
}

.schematic-markdown .diagnostics {
  border-top: 1px solid var(--sm-line);
  padding: 0.7rem 0.9rem;
  background: #fff7ed;
}
.schematic-markdown .diagnostic {
  margin: 0 0 0.35rem;
  color: var(--sm-warn);
  font: 13px/1.4 "Cascadia Code", Consolas, monospace;
}
.schematic-markdown .diagnostic.error { color: var(--sm-danger); }
.schematic-markdown .diagram-error-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid #fecaca;
  border-radius: 4px;
  background: #fef2f2;
  color: var(--sm-danger);
  font-size: 0.75rem;
}
.schematic-load-error {
  padding: 1rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
}

@media (max-width: 768px) {
  .schematic-markdown .diagram-header { align-items: flex-start; }
  .schematic-markdown .diagram-meta { justify-content: flex-start; }
  .schematic-markdown .diagram-canvas { padding: 0.75rem; }
}

@media (prefers-color-scheme: dark) {
  .schematic-markdown {
    --sm-panel: #f8fafc;
    --sm-ink: #172033;
    --sm-muted: #475569;
    --sm-line: #cbd5e1;
  }
}
