*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f6f7fb;
  color: #1f2937;
}

.container {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 16px 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.home-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 6px;
  background: #e5e7eb;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.home-link:hover {
  background: #d1d5db;
  color: #1f2937;
}

.btn-primary,
.btn-secondary {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-primary {
  background: #4caf50;
  color: #fff;
}

.btn-primary:hover {
  background: #45a049;
}

.btn-secondary {
  background: #9ca3af;
  color: #fff;
}

.btn-secondary:hover {
  background: #6b7280;
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mermaid-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  height: calc(100vh - 140px);
  min-height: 420px;
}

.editor-pane,
.preview-pane {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.pane-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pane-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.zoom-btn {
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #fff;
  color: #374151;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.zoom-btn:hover {
  border-color: #4caf50;
  color: #16a34a;
}

.zoom-fit {
  font-size: 0.72rem;
}

/* 占满窗口模式：预览面板覆盖整个视口，code 面板被遮在后面 */
body.diagram-expanded {
  overflow: hidden;
}

body.diagram-expanded .preview-pane {
  position: fixed;
  inset: 0;
  z-index: 100;
  border-radius: 0;
  border: none;
}

.zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 0.78rem;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.status {
  font-size: 0.8rem;
  color: #6b7280;
}

.status.status-error {
  color: #ef4444;
}

.status.status-ok {
  color: #16a34a;
}

.example-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.example-btn {
  padding: 4px 10px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  color: #374151;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.example-btn:hover {
  border-color: #4caf50;
  color: #16a34a;
}

.example-btn.active {
  background: #4caf50;
  border-color: #4caf50;
  color: #fff;
}

#code-input {
  flex: 1;
  width: 100%;
  padding: 12px;
  border: none;
  outline: none;
  resize: none;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #1f2937;
  background: #fff;
}

.preview {
  flex: 1;
  overflow: auto;
  display: flex;
  padding: 16px;
}

.preview svg {
  display: block;
  margin: auto;
}

.error-box {
  padding: 12px;
  border-top: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  max-height: 30%;
  overflow: auto;
}

@media (max-width: 800px) {
  .mermaid-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .editor-pane,
  .preview-pane {
    min-height: 320px;
  }
}
