:root {
  --demo-bg: #e8eef5;
  --demo-surface: #f7f9fc;
  --demo-panel: #ffffff;
  --demo-ink: #152033;
  --demo-muted: #5d6b7e;
  --demo-line: #d5dde8;
  --demo-accent: #0f766e;
  --demo-accent-soft: #ccfbf1;
  --demo-primary: #1d4ed8;
  --demo-primary-soft: #dbeafe;
  --demo-topbar-h: 52px;
  --demo-footer-h: 36px;
  --demo-radius: 10px;
  --demo-font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --demo-mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

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

html,
body.demo-v2 {
  height: 100%;
}

body.demo-v2 {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(1200px 480px at 8% -10%, rgba(29, 78, 216, 0.12), transparent 55%),
    radial-gradient(900px 420px at 92% 0%, rgba(15, 118, 110, 0.10), transparent 50%),
    var(--demo-bg);
  color: var(--demo-ink);
  font-family: var(--demo-font);
}

.demo-topbar {
  flex: 0 0 var(--demo-topbar-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  border-bottom: 1px solid var(--demo-line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.demo-brand {
  flex: 0 0 auto;
  color: var(--demo-ink);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.demo-brand:hover {
  color: var(--demo-primary);
}

.demo-topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--demo-muted);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-topbar-links {
  display: flex;
  flex: 0 0 auto;
  gap: 0.85rem;
}

.demo-topbar-links a {
  color: var(--demo-muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.demo-topbar-links a:hover {
  color: var(--demo-primary);
}

.demo-workspace {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  margin: 0.65rem 0.75rem 0.5rem;
  overflow: hidden;
  border: 1px solid var(--demo-line);
  border-radius: var(--demo-radius);
  background: var(--demo-panel);
  box-shadow: 0 10px 30px rgba(21, 32, 51, 0.06);
}

.demo-workspace[data-split="horizontal"] {
  flex-direction: row;
}

.demo-workspace[data-split="vertical"] {
  flex-direction: column;
}

.demo-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--demo-surface);
}

.demo-pane--editor {
  background: #f4f7fb;
}

.demo-pane--preview {
  background: #fff;
}

.demo-pane-bar {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--demo-line);
  background: rgba(255, 255, 255, 0.92);
}

.demo-pane-label {
  color: var(--demo-ink);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.demo-pane-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
}

.demo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--demo-line);
  border-radius: 7px;
  background: #fff;
  color: var(--demo-ink);
  font-size: 0.8rem;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.demo-btn:hover {
  border-color: #b7c4d8;
  background: #f0f4fa;
}

.demo-btn--primary {
  border-color: #1e40af;
  background: var(--demo-primary);
  color: #fff;
}

.demo-btn--primary:hover {
  border-color: #1e3a8a;
  background: #1e40af;
  color: #fff;
}

.demo-btn--accent {
  border-color: #0f766e;
  background: var(--demo-accent);
  color: #fff;
}

.demo-btn--accent:hover {
  border-color: #115e59;
  background: #0d9488;
  color: #fff;
}

.demo-btn.is-active {
  border-color: #99f6e4;
  background: var(--demo-accent-soft);
  color: #115e59;
}

.demo-pane-body {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.demo-pane-body .CodeMirror {
  position: absolute;
  inset: 0;
  height: 100% !important;
  font-family: var(--demo-mono);
  font-size: 13px;
  line-height: 1.5;
  background: transparent;
}

.demo-pane-body .CodeMirror-scroll {
  min-height: 100%;
}

.demo-pane-body .CodeMirror-gutters {
  border-right: 1px solid #e2e8f0;
  background: #edf2f7;
}

.demo-preview-body,
#iframewrapper {
  width: 100%;
  height: 100%;
}

#iframewrapper {
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%) 0 0 / 16px 16px,
    #fff;
}

#iframeResult,
#iframeResultShow {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border: 0 !important;
  background: #fff;
}

.gutter {
  flex: 0 0 auto;
  background-color: #eef2f7;
  background-repeat: no-repeat;
  background-position: 50%;
}

.gutter.gutter-horizontal {
  cursor: col-resize;
  width: 8px;
  background-image: linear-gradient(#94a3b8, #94a3b8);
  background-size: 2px 28px;
}

.gutter.gutter-vertical {
  cursor: row-resize;
  height: 8px;
  background-image: linear-gradient(90deg, #94a3b8, #94a3b8);
  background-size: 28px 2px;
}

.demo-workspace.is-preview-maximized .demo-pane--editor,
.demo-workspace.is-preview-maximized .gutter {
  display: none !important;
}

.demo-workspace.is-preview-maximized .demo-pane--preview {
  width: 100% !important;
  height: 100% !important;
  flex: 1 1 auto !important;
}

.demo-pane--preview:fullscreen,
.demo-pane--preview:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #fff;
}

.demo-pane--preview:fullscreen .demo-pane-bar,
.demo-pane--preview:-webkit-full-screen .demo-pane-bar {
  background: #fff;
}

.demo-footer {
  flex: 0 0 var(--demo-footer-h);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.75rem;
  color: var(--demo-muted);
  font-size: 0.75rem;
}

.demo-footer a {
  color: var(--demo-muted);
  text-decoration: none;
}

.demo-footer a:hover {
  color: var(--demo-primary);
}

.demo-footer-sep {
  opacity: 0.55;
}

@media screen and (max-width: 900px) {
  body.demo-v2 {
    overflow: auto;
  }

  .demo-topbar-links {
    display: none;
  }

  .demo-workspace {
    flex-direction: column !important;
    height: auto;
    min-height: calc(100vh - var(--demo-topbar-h) - var(--demo-footer-h) - 1.2rem);
    margin: 0.5rem;
  }

  .demo-pane--editor,
  .demo-pane--preview {
    flex: 1 1 42vh;
    min-height: 280px;
  }

  .gutter {
    display: none;
  }

  .demo-pane-actions .demo-btn {
    padding: 0.25rem 0.55rem;
  }
}
