@font-face {
  font-family: "ui-sans";
  src: local("Inter"), local("Segoe UI"), local("Microsoft YaHei UI");
}

@font-face {
  font-family: "ui-mono";
  src: local("JetBrains Mono"), local("Cascadia Mono"), local("Consolas");
}

:root {
  --bg: #f0f1f3;
  --panel: #ffffff;
  --text: #1e1e1e;
  --muted: #888888;
  --border: #d4d4d4;
  --primary: #0078d4;
  --primary-2: #1a8ae8;
  --ok: #198038;
  --warn: #d66f00;
  --err: #da1e28;
  --line: #e8f3ff;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  --radius: 3px;
  --gap: 8px;
  --topbar-h: 36px;
  --console-h: 180px;
  --tok-kw: #0000ff;
  --tok-type: #0000ff;
  --tok-pre: #800080;
  --tok-str: #a31515;
  --tok-com: #008000;
  --tok-num: #098658;
  --tok-ns: #267f99;
  --run-line-bg: rgba(0, 120, 212, 0.12);
  --run-line-border: rgba(0, 120, 212, 0.7);
  --term-bg: #1e1e1e;
  --term-panel: #252526;
  --term-text: #d4d4d4;
  --term-muted: #858585;
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(120, 120, 120, 0.4);
  --scrollbar-thumb-hover: rgba(120, 120, 120, 0.6);
}

html[data-theme="dark"] {
  --bg: #1e1e1e;
  --panel: #252526;
  --text: #cccccc;
  --muted: #888888;
  --border: #3c3c3c;
  --primary: #4fc1ff;
  --primary-2: #6fc8ff;
  --line: #2a2d2e;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  --tok-kw: #569cd6;
  --tok-type: #569cd6;
  --tok-pre: #c586c0;
  --tok-str: #ce9178;
  --tok-com: #6a9955;
  --tok-num: #b5cea8;
  --tok-ns: #4ec9b0;
  --run-line-bg: rgba(79, 193, 255, 0.15);
  --run-line-border: rgba(79, 193, 255, 0.7);
  --term-bg: #1e1e1e;
  --term-panel: #252526;
  --term-text: #d4d4d4;
  --term-muted: #858585;
  --scrollbar-track: transparent;
  --scrollbar-thumb: rgba(120, 120, 120, 0.4);
  --scrollbar-thumb-hover: rgba(120, 120, 120, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Microsoft YaHei", sans-serif;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 4px;
  padding: 4px;
  min-width: 0;
}

.btn--icon {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.btn--mini {
  padding: 0 8px;
  height: 28px;
  border-radius: var(--radius);
  font-weight: 400;
  font-size: 12px;
}

.btn--mini[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.btn__icon {
  display: inline-block;
  width: 1.2em;
  margin-right: 6px;
  text-align: center;
  opacity: 0.9;
}

.btn__text {
  display: inline-block;
}

.divider {
  width: 1px;
  height: 18px;
  background: var(--border);
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.3;
  transition: border-color 120ms ease, background 120ms ease;
}

.btn:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--panel));
}

.btn:active {
  background: color-mix(in srgb, var(--primary) 12%, var(--panel));
}

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

.btn.is-stepinto-hint {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--panel));
  box-shadow: inset 0 0 0 1px var(--primary);
}

html[data-theme="dark"] .btn.is-stepinto-hint {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--panel));
  box-shadow: inset 0 0 0 1px var(--primary);
}

.btn--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
}

html[data-theme="dark"] .btn--primary {
  color: #1e1e1e;
}

.btn--ghost {
  background: transparent;
}

.main {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 4px 1fr;
  gap: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.main > * {
  min-width: 0;
}

.main-splitter {
  position: relative;
  cursor: col-resize;
  min-height: 0;
  z-index: 1;
}

.main-splitter::before {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  transition: background 120ms ease;
}

.main-splitter::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
  transition: background 120ms ease;
}

.main-splitter:hover::after,
.main-splitter:active::after {
  background: var(--primary);
}

.panel {
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.panel--editor {
  grid-template-rows: auto 1fr;
}

.panel--viz {
  margin-top: 0;
  grid-template-rows: auto auto auto 1fr;
}

.editor-body {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.panel--editor textarea#codeArea {
  display: none;
}

.CodeMirror {
  height: 100%;
  width: 100%;
  min-width: 0;
  font-family: var(--code-font-family, ui-mono, Consolas, monospace);
  font-size: var(--code-font-size, 13px);
  line-height: var(--code-line-height, 20px);
  background: transparent;
  color: var(--text);
}

.editor-body .CodeMirror {
  flex: 1 1 auto;
  min-height: 0;
}

.editor-body .CodeMirror-hscrollbar {
  height: 12px;
}

.editor-body .CodeMirror-vscrollbar {
  width: 12px;
}

.editor-body .CodeMirror-hscrollbar,
.editor-body .CodeMirror-vscrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  background: transparent;
}

.editor-body .CodeMirror-hscrollbar::-webkit-scrollbar {
  height: 10px;
}

.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar {
  width: 10px;
}

.editor-body .CodeMirror-hscrollbar::-webkit-scrollbar-track,
.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

.editor-body .CodeMirror-hscrollbar::-webkit-scrollbar-thumb,
.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.editor-body .CodeMirror-hscrollbar::-webkit-scrollbar-thumb:hover,
.editor-body .CodeMirror-vscrollbar::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.editor-body .CodeMirror-hscrollbar:hover,
.editor-body .CodeMirror-vscrollbar:hover {
  background: var(--panel);
}

.editor-body .CodeMirror-hscrollbar:hover::-webkit-scrollbar-thumb,
.editor-body .CodeMirror-vscrollbar:hover::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb-hover);
}

.editor-float-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.editor-appearance {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.editor-appearance__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 140px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}

.editor-appearance__menu.is-hidden {
  display: none;
}

.editor-appearance__menu .btn {
  width: 100%;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 12px;
}

.editor-examples {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  height: 26px;
  width: auto;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}

.editor-examples::after {
  content: "▾";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}

.editor-examples__select {
  height: 100%;
  width: 220px;
  min-width: 220px;
  padding: 0 28px 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  outline: none;
  appearance: none;
}

.editor-examples:focus-within {
  border-color: var(--primary);
}

.editor-float-actions .btn {
  padding: 4px 6px;
  font-size: 12px;
  border-radius: var(--radius);
}

.runtime-io {
  flex: 0 0 auto;
  height: 180px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.runtime-io__bar {
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 28px;
}

.runtime-io__bar-title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.runtime-io__bar-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.runtime-io__body {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
}

.runtime-io.is-hide-dbg .runtime-io__body {
  grid-template-columns: 1fr 1fr;
}

.runtime-io.is-hide-dbg .runtime-io__pane--dbg {
  display: none;
}

.runtime-io.is-collapse-io {
  height: auto;
}

.runtime-io.is-collapse-io .runtime-io__body {
  display: none;
}

.runtime-io__pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  border-right: 1px solid var(--border);
}

.runtime-io__pane:last-child {
  border-right: 0;
}

.runtime-io__pane-title {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  min-height: 26px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.runtime-io__pane-title--with-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.runtime-io__pane-title-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.runtime-io__pane-title-actions .btn {
  padding: 2px 6px;
  font-size: 11px;
}

.runtime-io__pane-out {
  margin: 0;
  padding: 6px 8px;
  overflow: auto;
  background: var(--term-bg);
  color: var(--term-text);
  font-family: ui-mono, Consolas, monospace;
  font-size: 12.5px;
  line-height: 18px;
  white-space: pre-wrap;
  word-break: break-word;
}

.runtime-out-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.runtime-out-line.is-cursor {
  outline: 1px solid color-mix(in srgb, var(--term-text) 35%, transparent);
  background: color-mix(in srgb, var(--term-bg) 85%, var(--tok-kw));
  padding: 1px 2px;
}

.runtime-out-line.is-pending {
  color: var(--term-muted);
}

.runtime-out-span--pending {
  color: var(--term-muted);
}

.runtime-io__pane-out--dbg {
  background: color-mix(in srgb, var(--term-bg) 85%, #000);
}

.runtime-io__pane-in {
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
  resize: none;
  padding: 6px 8px;
  background: var(--term-panel);
  color: var(--term-text);
  font-family: ui-mono, Consolas, monospace;
  font-size: 12.5px;
  line-height: 18px;
}

.runtime-io__pane-in::placeholder {
  color: color-mix(in srgb, var(--term-muted) 90%, transparent);
}

.CodeMirror-gutters {
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.CodeMirror-linenumber {
  color: var(--muted);
}

.CodeMirror-foldgutter {
  width: 14px;
}

.CodeMirror-foldgutter-open,
.CodeMirror-foldgutter-folded {
  cursor: pointer;
  color: var(--muted);
  text-align: center;
}

.CodeMirror-foldmarker {
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 4px;
}

.cm-error-balloon {
  display: inline-block;
  margin-left: 2px;
  transform: translateY(-1px);
  user-select: none;
  cursor: help;
  animation: cppviz-breathe 1.25s ease-in-out infinite;
}

.cm-error-balloon--warn {
  filter: hue-rotate(55deg) saturate(2.2) brightness(1.22) contrast(1.05);
}

.cm-road-sign {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  transform: translateY(-2px);
  user-select: none;
  pointer-events: none;
  font-family: ui-mono, Consolas, monospace;
}

.cm-road-sign__text {
  font-size: 10px;
  line-height: 1;
  padding: 1px 5px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}

.cm-road-sign--depart .cm-road-sign__text {
  color: color-mix(in srgb, var(--primary) 85%, var(--text));
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  background: color-mix(in srgb, var(--primary) 12%, var(--panel));
}

.cm-road-sign--return .cm-road-sign__text {
  color: color-mix(in srgb, var(--ok) 85%, var(--text));
  border-color: color-mix(in srgb, var(--ok) 35%, var(--border));
  background: color-mix(in srgb, var(--ok) 10%, var(--panel));
}

@keyframes cppviz-breathe {
  0% { transform: translateY(-1px) scale(1); }
  50% { transform: translateY(-1px) scale(1.18); }
  100% { transform: translateY(-1px) scale(1); }
}

.cppviz-tip {
  position: fixed;
  z-index: 9999;
  max-width: min(480px, calc(100vw - 24px));
  padding: 4px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #333;
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cm-devcpp .cm-keyword {
  color: var(--tok-kw);
}

.cm-devcpp .cm-def,
.cm-devcpp .cm-variable-2,
.cm-devcpp .cm-variable-3 {
  color: var(--text);
}

.cm-devcpp .cm-string {
  color: var(--tok-str);
}

.cm-devcpp .cm-comment {
  color: var(--tok-com);
}

.cm-devcpp .cm-number {
  color: var(--tok-num);
}

.cm-devcpp .cm-meta {
  color: var(--tok-pre);
}

.cm-devcpp .CodeMirror-activeline-background {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.cm-devcpp .cm-exec-line {
  background: var(--run-line-bg) !important;
  box-shadow: inset 3px 0 0 var(--run-line-border);
}

.cm-exec-flash {
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--run-line-border) 32%, transparent) 45%,
    color-mix(in srgb, var(--run-line-border) 26%, transparent) 55%,
    transparent 100%
  );
  background-size: 240% 100%;
  background-position: -140% 0;
  background-repeat: no-repeat;
  animation: cppviz-exec-sweep 520ms ease-out 1, cppviz-exec-pulse 520ms ease-out 1;
}

@keyframes cppviz-exec-sweep {
  0% { background-position: -140% 0; }
  100% { background-position: 140% 0; }
}

@keyframes cppviz-exec-pulse {
  0%, 100% { box-shadow: inset 3px 0 0 var(--run-line-border); }
  45% {
    box-shadow:
      inset 3px 0 0 var(--run-line-border),
      0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent),
      0 10px 28px -18px color-mix(in srgb, var(--primary) 55%, transparent);
  }
}

.cm-classic .CodeMirror {
  background: #ffffff;
  color: #000000;
}

.cm-classic .CodeMirror-gutters {
  background: #f7f7f7;
  border-right: 1px solid #d0d0d0;
}

.cm-classic .CodeMirror-linenumber {
  color: #666666;
}

.cm-classic .cm-keyword {
  color: #000000;
  font-weight: 700;
}

.cm-classic .cm-type {
  color: #000000;
  font-weight: 700;
}

.cm-classic .cm-comment {
  color: #0000ff;
}

.cm-classic .cm-string {
  color: #0000ff;
}

.cm-classic .cm-number {
  color: #000000;
}

.cm-classic .cm-meta,
.cm-classic .cm-include {
  color: #008000;
}

.cm-classic .cm-operator,
.cm-classic .cm-bracket,
.cm-classic .cm-punctuation {
  color: #ff0000 !important;
}

.cm-classic .cm-tag {
  color: #ff0000;
}

.cm-classic .cm-def,
.cm-classic .cm-variable,
.cm-classic .cm-variable-2,
.cm-classic .cm-variable-3,
.cm-classic .cm-property {
  color: #000000;
}

.cm-classic .CodeMirror-activeline-background {
  background: #eaf2ff;
}

.cm-classic .cm-exec-line {
  background: var(--run-line-bg) !important;
  box-shadow: inset 3px 0 0 var(--run-line-border);
}

.cm-classic .CodeMirror-foldgutter-open,
.cm-classic .CodeMirror-foldgutter-folded {
  color: #666666;
}

.cm-classic .CodeMirror-foldmarker {
  color: #666666;
  background: #ffffff;
  border: 1px solid #d0d0d0;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}

.panel--viz .panel__header {
  border-bottom: 0;
}

.viz-progress {
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border);
}

.viz-progress.is-hidden {
  display: none;
}

.viz-progress__track {
  height: 8px;
  border-radius: var(--radius);
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.viz-progress__cells {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
}

.viz-stepcell {
  flex: 1 1 0;
  min-width: 1px;
  height: 100%;
  opacity: 0.28;
  border-right: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
}

.viz-stepcell:last-child {
  border-right: 0;
}

.viz-stepcell.is-done {
  opacity: 0.9;
}

.viz-stepcell.is-current {
  opacity: 1;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.viz-stepcell--d0 { background: #0b3a4a; }
.viz-stepcell--d1 { background: #1e88e5; }
.viz-stepcell--d2 { background: #43a047; }
.viz-stepcell--d3 { background: #fdd835; }
.viz-stepcell--d4 { background: #8e24aa; }
.viz-stepcell--d5 { background: #fb8c00; }
.viz-stepcell--d6 { background: #9e9e9e; }

.viz-progress__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  opacity: 0;
}

.viz-progress__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  font-family: ui-mono, Consolas, monospace;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 0 6px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.viz-exec {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  min-height: 28px;
}

.viz-exec.is-hidden {
  display: none;
}

.viz-exec__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.viz-exec__title {
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
}

.viz-exec__code {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
  border-radius: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: ui-mono, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel__header-right,
.viz-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

.panel__header-right {
  margin-left: auto;
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.panel__header-right .viz-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.viz-appearance {
  position: relative;
}

.viz-appearance__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  min-width: 140px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}

.viz-appearance__menu.is-hidden {
  display: none;
}

.viz-appearance__menu .btn {
  width: 100%;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 12px;
}

.panel__title {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.panel__meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-family: ui-mono, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  min-width: 10ch;
  text-align: right;
}

.editor {
  min-height: 0;
  display: grid;
  grid-template-columns: 52px 1fr;
  height: 100%;
}

.editor__lines {
  margin: 0;
  padding: 8px 0;
  border-right: 1px solid var(--border);
  font-family: ui-mono, Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
  color: var(--muted);
  user-select: none;
  background: var(--panel);
  overflow: hidden;
  text-align: right;
}

.editor__lines span {
  display: block;
  padding-right: 12px;
  height: 20px;
}

.editor__lines span.is-current {
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 14%, var(--line));
  box-shadow: inset 3px 0 0 var(--primary);
  font-weight: 700;
}

.editor__codewrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.editor__codewrap.is-plain .editor__highlight {
  visibility: hidden;
}

.editor__codewrap.is-plain .editor__code {
  color: var(--text);
  -webkit-text-fill-color: var(--text);
}

.editor__code::selection {
  background: rgba(22, 93, 255, 0.22);
  color: transparent;
}

.editor__code::-moz-selection {
  background: rgba(22, 93, 255, 0.22);
  color: transparent;
}

.editor__highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 8px 8px;
  font-family: ui-mono, Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
  color: var(--text);
  background: transparent;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
  white-space: pre;
  font-variant-ligatures: none;
  letter-spacing: 0;
  tab-size: 2;
}

.editor__highlight code {
  display: block;
  transform: translate3d(0, 0, 0);
}

.editor__line-highlight {
  position: absolute;
  left: 0;
  right: 0;
  height: 20px;
  top: 8px;
  background: var(--run-line-bg);
  border-left: 3px solid var(--run-line-border);
  pointer-events: none;
  z-index: 1;
}

.editor__line-highlight.is-flash,
.editor__line-highlight.flash {
  animation: runLineFlash 280ms ease-out;
}

@keyframes runLineFlash {
  0% {
    box-shadow: 0 0 0 1px var(--run-line-border), 0 0 0 0 transparent;
  }
  40% {
    box-shadow: 0 0 0 1px var(--run-line-border), 0 0 0 6px color-mix(in srgb, var(--primary) 18%, transparent);
  }
  100% {
    box-shadow: 0 0 0 1px var(--run-line-border), 0 0 0 0 transparent;
  }
}

.editor__code {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 3;
  border: 0;
  outline: 0;
  resize: none;
  padding: 8px 8px;
  font-family: ui-mono, Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--text);
  background: transparent;
  overflow: auto;
  font-variant-ligatures: none;
  letter-spacing: 0;
  tab-size: 2;
}

.tok-kw {
  color: var(--tok-kw);
  font-weight: 400;
}

.tok-type {
  color: var(--tok-type);
}

.tok-pre {
  color: var(--tok-pre);
}

.tok-str {
  color: var(--tok-str);
}

.tok-com {
  color: var(--tok-com);
}

.tok-num {
  color: var(--tok-num);
}

.tok-ns {
  color: var(--tok-ns);
}

.hl-keyword {
  color: var(--tok-kw);
  font-weight: 400;
}

.hl-macro {
  color: var(--tok-pre);
}

.hl-string {
  color: var(--tok-str);
}

.hl-comment {
  color: var(--tok-com);
}

.hl-number {
  color: var(--tok-num);
}

/* 新版统一可视化容器 */
.viz-container {
  min-height: 0;
  overflow: auto;
  padding: 4px;
  display: block;
}

.viz-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  font-family: ui-mono, Consolas, monospace;
  table-layout: fixed;
}

col.viz-col--idx {
  width: 36px;
}

.viz-th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: relative;
  white-space: nowrap;
}

.viz-th--idx {
  text-align: right;
  padding-right: 6px;
}

.viz-resizer {
  position: absolute;
  top: 0;
  right: -6px;
  width: 12px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.viz-resizer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10%;
  width: 2px;
  height: 80%;
  transform: translateX(-50%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  opacity: 0.0;
  transition: opacity 120ms ease, background 120ms ease;
}

.viz-th:hover .viz-resizer::before,
.viz-resizer:hover::before,
.viz-table.is-col-resizing .viz-resizer::before {
  opacity: 1;
}

.viz-table.is-col-resizing {
  user-select: none;
}

.viz-td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 13px;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}

.viz-td--idx {
  padding-right: 6px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.viz-td--type {
  width: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.viz-td--name {
  width: auto;
  color: var(--text);
  font-weight: 700;
  min-width: 0;
  white-space: nowrap;
}

.viz-toggle {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0 0 0 4px;
  width: 12px;
  height: 12px;
  line-height: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  vertical-align: middle;
}

.viz-toggle:hover {
  color: var(--text);
}

.viz-name {
  display: inline-block;
  min-width: 0;
  max-width: calc(100% - 20px);
  padding: 0 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.viz-name--r0 {
  --viz-rarity: 255 59 48;
}

.viz-name--r1 {
  --viz-rarity: 168 85 247;
}

.viz-name--r2 {
  --viz-rarity: 59 130 246;
}

.viz-name--r3 {
  --viz-rarity: 34 211 238;
}

.viz-name--r0,
.viz-name--r1,
.viz-name--r2,
.viz-name--r3 {
  border-left: 3px solid rgb(var(--viz-rarity));
  background: linear-gradient(90deg, rgba(var(--viz-rarity) / 0.08), transparent 70%);
}

.viz-td--value {
  width: auto;
  overflow-wrap: anywhere;
  word-break: break-all;
  color: var(--tok-num);
}

.viz-td--value.has-val-anim {
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  word-break: normal;
  overflow-wrap: normal;
}

.viz-td--value.is-expanded.has-val-anim {
  white-space: pre-wrap;
  overflow-x: auto;
  overflow-y: auto;
}

.viz-td--value.is-expanded .viz-val-anim {
  display: inline;
  white-space: pre-wrap;
}

.viz-td--value.is-expanded .viz-val-prefix,
.viz-td--value.is-expanded .viz-val-mid,
.viz-td--value.is-expanded .viz-val-suffix {
  white-space: pre-wrap;
}

.viz-td--value.is-changed {
  /* background moved to inner .viz-val-text / .viz-val-anim */
}

.viz-td--value.is-changed .viz-val-text,
.viz-td--value.is-changed .viz-val-anim {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.viz-val-text {
  display: inline;
}

.viz-val-anim {
  display: inline-flex;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
}

.viz-val-mid {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  max-width: 0;
  opacity: 0;
}

.viz-td--value.is-changed .viz-val-mid--old {
  max-width: 1200px;
  opacity: 1;
  animation: viz-mid-collapse 220ms ease forwards;
}

.viz-td--value.is-changed .viz-val-mid--new {
  max-width: 0;
  opacity: 0;
  animation: viz-mid-expand 240ms ease forwards;
  animation-delay: 220ms;
}

@keyframes viz-mid-collapse {
  0% { max-width: 1200px; opacity: 1; filter: blur(0px); }
  100% { max-width: 0px; opacity: 0; filter: blur(1px); }
}

@keyframes viz-mid-expand {
  0% { max-width: 0px; opacity: 0; filter: blur(1px); }
  100% { max-width: 1200px; opacity: 1; filter: blur(0px); }
}

@media (prefers-reduced-motion: reduce) {
  .viz-td--value.is-changed .viz-val-mid--old,
  .viz-td--value.is-changed .viz-val-mid--new {
    animation: none !important;
    max-width: none;
    opacity: 1;
  }
}

.viz-table tbody tr:last-child .viz-td {
  border-bottom: 0;
}

.viz-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
}

.viz-header {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  font-family: ui-mono, Consolas, monospace;
  font-size: 12px;
}

.viz-type {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.viz-name {
  color: var(--text);
  font-weight: 700;
}

.viz-body {
  padding: 8px;
}

.viz-val {
  font-family: ui-mono, Consolas, monospace;
  font-size: 13px;
  color: var(--tok-num);
}

.viz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
}

.viz-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  background: var(--panel);
  text-align: center;
  font-family: ui-mono, Consolas, monospace;
  font-size: 12px;
}

.viz-cell-idx {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
}

.viz-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: ui-mono, Consolas, monospace;
}

.viz-stack {
  display: grid;
  gap: 4px;
  justify-items: center;
}

.viz-stack-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  background: color-mix(in srgb, var(--primary) 6%, var(--panel));
  font-family: ui-mono, Consolas, monospace;
  font-size: 12px;
  min-width: 60px;
  text-align: center;
}

.viz-queue {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.viz-queue-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  background: color-mix(in srgb, var(--primary) 6%, var(--panel));
  font-family: ui-mono, Consolas, monospace;
  font-size: 12px;
}

.viz-queue-arrow {
  color: var(--muted);
}

.viz-pill {
  font-size: 11px;
  color: var(--muted);
  padding: 1px 5px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.console {
  height: var(--console-h);
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.console.is-collapsed {
  height: 32px;
}

.console__bar {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.console__title {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.console__summary {
  display: none;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.console.is-collapsed .console__summary {
  display: block;
}

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

.console.is-collapsed #btnConsoleCollapse {
  display: none;
}

.console:not(.is-collapsed) #btnConsoleExpand {
  display: none;
}

.console__out {
  margin: 0;
  padding: 6px 8px;
  overflow: auto;
  font-family: ui-mono, Consolas, monospace;
  font-size: 12.5px;
  line-height: 18px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.console-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.console-line--hint {
  color: var(--muted);
}

.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  max-width: 480px;
  width: calc(100% - 32px);
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.modal__body {
  padding: 12px;
}

.modal__title {
  font-weight: 800;
  margin-bottom: 8px;
}

.modal__text {
  color: var(--muted);
  line-height: 1.6;
}

.modal__actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  body {
    grid-template-rows: auto 1fr auto;
  }

  .topbar {
    width: 100%;
    justify-content: space-between;
    position: static;
    height: auto;
    overflow: visible;
    flex-wrap: wrap;
  }

  .main {
    grid-template-columns: 1fr;
    gap: var(--gap);
  }

  .main-splitter {
    display: none;
  }

  .panel--viz {
    margin-top: 0;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .panel__header-right {
    flex-wrap: wrap;
  }

  .panel__header-right .viz-actions {
    flex-wrap: wrap;
  }
}
