:root {
  --mermaid-shell-bg: linear-gradient(180deg, rgba(246, 253, 253, 0.9), rgba(233, 247, 248, 0.82));
  --mermaid-shell-border: rgba(110, 174, 196, 0.24);
  --mermaid-shell-shadow: 0 18px 36px rgba(122, 175, 187, 0.12);
  --mermaid-node-fill: #eefafc;
  --mermaid-node-border: #5fa6c4;
  --mermaid-node-text: #14394f;
  --mermaid-line: #5f95b2;
  --mermaid-label-bg: rgba(231, 247, 250, 0.96);
  --mermaid-label-text: #18445d;
  --mermaid-cluster-fill: rgba(217, 240, 245, 0.68);
  --mermaid-cluster-border: rgba(95, 166, 196, 0.32);
}

:root.dark {
  --mermaid-shell-bg: linear-gradient(180deg, rgba(8, 33, 49, 0.86), rgba(8, 26, 40, 0.74));
  --mermaid-shell-border: rgba(63, 183, 205, 0.22);
  --mermaid-shell-shadow: 0 22px 42px rgba(4, 10, 18, 0.26);
  --mermaid-node-fill: #11384a;
  --mermaid-node-border: #34d0db;
  --mermaid-node-text: #dcf8ff;
  --mermaid-line: #3bc4d6;
  --mermaid-label-bg: rgba(9, 43, 58, 0.94);
  --mermaid-label-text: #effcff;
  --mermaid-cluster-fill: rgba(16, 48, 64, 0.58);
  --mermaid-cluster-border: rgba(52, 208, 219, 0.22);
}

.trm-mermaid-shell {
  margin: 28px 0;
  padding: 20px 22px;
  border-radius: 24px;
  border: 1px solid var(--mermaid-shell-border);
  background: var(--mermaid-shell-bg);
  box-shadow: var(--mermaid-shell-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow-x: auto;
}

.trm-mermaid-shell.is-rendering {
  min-height: 180px;
}

.trm-mermaid-shell svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 560px;
  overflow: visible;
}

.trm-mermaid-shell .trm-mermaid-fallback {
  margin: 0;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(8, 20, 34, 0.06);
  color: var(--mermaid-node-text);
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  .trm-mermaid-shell {
    padding: 16px 14px;
    border-radius: 18px;
  }

  .trm-mermaid-shell svg {
    min-width: 480px;
  }
}
