.editor-stack {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.editor-host {
  position: absolute;
  inset: 0;
  display: none;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="github-light-default"] {
  --editor-bg: #ffffff;
  --editor-fg: #1f2328;
  --editor-gutter-bg: #f6f8fa;
  --editor-gutter-fg: #6e7781;
  --editor-gutter-border: #d0d7de;
  --editor-active-line: #f6f8fa;
  --editor-selection: #b6d7ff;
  --editor-selection-fg: #1f2328;
  --editor-caret: var(--color-accent);
  --editor-guide: #d0d7de;
  --color-syntax-key: #0550ae;
  --color-syntax-string: #0a3069;
  --color-syntax-number: #953800;
  --color-syntax-literal: #8250df;
  --color-syntax-invalid: #cf222e;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="ayu-light"] {
  --editor-bg: #fafafa;
  --editor-fg: #5c6773;
  --editor-gutter-bg: #f3f4f5;
  --editor-gutter-fg: #abb0b6;
  --editor-gutter-border: #d8d8d8;
  --editor-active-line: #f0f0f0;
  --editor-selection: #ffe0a3;
  --editor-selection-fg: #1f2328;
  --editor-caret: #ffaa33;
  --editor-guide: #d8d8d8;
  --color-syntax-key: #55b4d4;
  --color-syntax-string: #86b300;
  --color-syntax-number: #a37acc;
  --color-syntax-literal: #f07171;
  --color-syntax-invalid: #f51818;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="github-dark-default"] {
  --editor-bg: #0d1117;
  --editor-fg: #e6edf3;
  --editor-gutter-bg: #0d1117;
  --editor-gutter-fg: #8b949e;
  --editor-gutter-border: #30363d;
  --editor-active-line: #161b22;
  --editor-selection: #264f78;
  --editor-selection-fg: #f0f6fc;
  --editor-caret: var(--color-accent);
  --editor-guide: #30363d;
  --color-syntax-key: #79c0ff;
  --color-syntax-string: #a5d6ff;
  --color-syntax-number: #79c0ff;
  --color-syntax-literal: #ff7b72;
  --color-syntax-invalid: #ff7b72;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="one-dark-pro"] {
  --editor-bg: #282c34;
  --editor-fg: #abb2bf;
  --editor-gutter-bg: #282c34;
  --editor-gutter-fg: #5c6370;
  --editor-gutter-border: #3e4451;
  --editor-active-line: #2c313a;
  --editor-selection: #3d4f6a;
  --editor-selection-fg: #ffffff;
  --editor-caret: #528bff;
  --editor-guide: #3e4451;
  --color-syntax-key: #e06c75;
  --color-syntax-string: #98c379;
  --color-syntax-number: #d19a66;
  --color-syntax-literal: #c678dd;
  --color-syntax-invalid: #f44747;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="dracula"] {
  --editor-bg: #282a36;
  --editor-fg: #f8f8f2;
  --editor-gutter-bg: #282a36;
  --editor-gutter-fg: #6272a4;
  --editor-gutter-border: #44475a;
  --editor-active-line: #44475a;
  --editor-selection: #4a5578;
  --editor-selection-fg: #ffffff;
  --editor-caret: #f8f8f0;
  --editor-guide: #44475a;
  --color-syntax-key: #ff79c6;
  --color-syntax-string: #f1fa8c;
  --color-syntax-number: #bd93f9;
  --color-syntax-literal: #8be9fd;
  --color-syntax-invalid: #ff5555;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="atom-one-dark"] {
  --editor-bg: #282c34;
  --editor-fg: #abb2bf;
  --editor-gutter-bg: #21252b;
  --editor-gutter-fg: #636d83;
  --editor-gutter-border: #181a1f;
  --editor-active-line: #2c313c;
  --editor-selection: #3d4f6a;
  --editor-selection-fg: #ffffff;
  --editor-caret: #528bff;
  --editor-guide: #3b4048;
  --color-syntax-key: #e06c75;
  --color-syntax-string: #98c379;
  --color-syntax-number: #d19a66;
  --color-syntax-literal: #c678dd;
  --color-syntax-invalid: #be5046;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="night-owl"] {
  --editor-bg: #011627;
  --editor-fg: #d6deeb;
  --editor-gutter-bg: #011627;
  --editor-gutter-fg: #4b6479;
  --editor-gutter-border: #0b2942;
  --editor-active-line: #0b2942;
  --editor-selection: #123d5a;
  --editor-selection-fg: #ffffff;
  --editor-caret: #80a4c2;
  --editor-guide: #2a4458;
  --color-syntax-key: #82aaff;
  --color-syntax-string: #ecc48d;
  --color-syntax-number: #f78c6c;
  --color-syntax-literal: #c792ea;
  --color-syntax-invalid: #ef5350;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="tokyo-night"] {
  --editor-bg: #1a1b26;
  --editor-fg: #c0caf5;
  --editor-gutter-bg: #1a1b26;
  --editor-gutter-fg: #565f89;
  --editor-gutter-border: #292e42;
  --editor-active-line: #24283b;
  --editor-selection: #3b426b;
  --editor-selection-fg: #ffffff;
  --editor-caret: #c0caf5;
  --editor-guide: #292e42;
  --color-syntax-key: #7aa2f7;
  --color-syntax-string: #9ece6a;
  --color-syntax-number: #ff9e64;
  --color-syntax-literal: #bb9af7;
  --color-syntax-invalid: #f7768e;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="github-dark-high-contrast"] {
  --editor-bg: #0a0c10;
  --editor-fg: #f0f3f6;
  --editor-gutter-bg: #0a0c10;
  --editor-gutter-fg: #f0f3f6;
  --editor-gutter-border: #7a828e;
  --editor-active-line: #272b33;
  --editor-selection: #1158c7;
  --editor-selection-fg: #ffffff;
  --editor-caret: #71b7ff;
  --editor-guide: #7a828e;
  --color-syntax-key: #71b7ff;
  --color-syntax-string: #addcff;
  --color-syntax-number: #ffb77c;
  --color-syntax-literal: #ff9492;
  --color-syntax-invalid: #ff9492;
}

:is(.editor-host, .diff-workspace)[data-editor-theme="synthwave-84"] {
  --editor-bg: #262335;
  --editor-fg: #f92aad;
  --editor-gutter-bg: #241b2f;
  --editor-gutter-fg: #848bbd;
  --editor-gutter-border: #495495;
  --editor-active-line: #2a2139;
  --editor-selection: #5a285f;
  --editor-selection-fg: #fdf2ff;
  --editor-caret: #fede5d;
  --editor-guide: #495495;
  --color-syntax-key: #36f9f6;
  --color-syntax-string: #fede5d;
  --color-syntax-number: #f97e72;
  --color-syntax-literal: #ff7edb;
  --color-syntax-invalid: #fe4450;
}

.editor-host.active,
.editor-host.compare-editor-host {
  display: block;
}

.editor-host .cm-editor {
  height: 100%;
  color: var(--editor-fg, var(--color-neutral-200));
  background: var(--editor-bg, transparent);
}

.editor-host .cm-scroller {
  font: var(--font-size-code) / var(--line-height-code) var(--font-mono);
  overflow: auto;
}

.editor-host .cm-content {
  padding-block: var(--space-4);
  caret-color: var(--editor-caret);
}

.editor-host .cm-line {
  padding-inline: var(--space-pane-inline);
}

.editor-host .cm-indent-guide {
  box-shadow: inset calc(-1 * var(--space-border)) 0 var(--editor-guide);
}

.editor-host .cm-gutters {
  border-right: var(--space-border) solid var(--editor-gutter-border);
  color: var(--editor-gutter-fg);
  background: var(--editor-gutter-bg);
}

.editor-host .cm-activeLine,
.editor-host .cm-activeLineGutter {
  background: var(--editor-active-line);
}

.workspace .editor-host .cm-editor.cm-has-selection .cm-activeLine {
  background: transparent;
}

.workspace .editor-host .cm-editor .cm-selectionLayer .cm-selectionBackground,
.workspace .editor-host .cm-editor.cm-focused .cm-selectionLayer .cm-selectionBackground,
.workspace .editor-host .cm-editor .cm-content ::selection,
.workspace .editor-host .cm-editor.cm-focused .cm-content ::selection {
  background: var(--editor-selection);
  color: var(--editor-selection-fg);
  opacity: 1;
}

.editor-host .cm-editor.cm-focused {
  outline: none;
  box-shadow: inset var(--focus-ring);
}

.editor-host .cm-parser-error {
  border-bottom: var(--space-border) solid var(--color-error);
  background: color-mix(in srgb, var(--color-error) 18%, transparent);
  background-image: none;
}

.editor-host .cm-parser-error-line {
  background: color-mix(in srgb, var(--color-error) 14%, transparent);
}

.editor-host .cm-parser-error-point {
  display: inline-block;
  width: var(--space-border);
  height: var(--line-height-code);
  background: var(--color-error);
}

.output-canvas {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.output-editor-surface,
.output-view-surface {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.output-editor-surface.surface-hidden,
.output-view-surface.surface-hidden {
  display: none;
}

.projection-output {
  position: relative;
  overflow: hidden;
}

.output-canvas pre {
  margin: 0;
  padding: var(--space-4) var(--space-pane-inline);
  color: var(--color-neutral-300);
  font: var(--font-size-code) / var(--line-height-code) var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.xml-output {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-content: start;
}

.xml-line-numbers {
  min-height: 100%;
  margin: 0;
  padding: var(--space-4) var(--space-3);
  border-right: var(--space-border) solid var(--color-border-subtle);
  background: var(--color-divider-soft);
  color: var(--color-neutral-600);
  font: var(--font-size-code) / var(--line-height-code) var(--font-mono);
  list-style: none;
  text-align: right;
  user-select: none;
}

.xml-output pre {
  min-width: max-content;
  padding-left: var(--space-4);
  white-space: pre;
  word-break: normal;
}

.output-message {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-pane-inline);
  color: var(--color-neutral-300);
}

.editor-host .cm-placeholder {
  color: var(--color-neutral-500);
  font-family: var(--font-mono);
  font-style: normal;
  opacity: 1;
}

.formatter-empty-state {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-pane-inline);
  overflow: hidden;
  text-align: center;
}

.formatter-empty-glyph {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border: var(--space-border) solid var(--color-divider);
  border-radius: 50%;
  color: var(--color-accent);
  font: var(--font-weight-emphasis) var(--font-size-title) / 1 var(--font-mono);
}

.formatter-empty-kicker {
  color: var(--color-neutral-500);
  font-size: var(--font-size-label);
  letter-spacing: var(--tracking-label);
}

.formatter-empty-copy {
  max-width: 30rem;
  margin: 0;
  color: var(--color-neutral-400);
  line-height: var(--line-height-copy);
}

.problems-panel {
  padding: var(--space-4) var(--space-pane-inline);
}

.problems-panel h2 {
  margin: 0 0 var(--space-3);
  font: 600 var(--font-size-body) / var(--line-height-body) var(--font-ui);
}

.problems-list {
  position: relative;
  height: 100%;
  overflow: auto;
}

.problems-spacer {
  position: relative;
}

.problem-row-wrap {
  position: absolute;
  left: 0;
  right: 0;
}

.problem-row {
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr);
  gap: var(--space-3);
  align-items: center;
  min-height: 30px;
  width: 100%;
  border: var(--space-border) solid var(--color-divider);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-error) 10%, transparent);
  font: inherit;
  text-align: left;
}

.problem-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.problem-severity {
  color: var(--color-error);
  font-weight: 600;
}

.problem-location {
  color: var(--color-neutral-300);
}

.problem-message {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-error,
.status-error {
  color: var(--color-error);
}

.virtual-list {
  height: 100%;
  overflow: auto;
  font: var(--font-size-code) / var(--virtual-row-height) var(--font-mono);
}

.virtual-spacer {
  position: relative;
  min-width: max-content;
}

.virtual-row {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--virtual-row-height);
  padding-inline: var(--space-pane-inline);
  overflow: hidden;
  border-bottom: var(--space-border) solid var(--color-divider-soft);
  color: var(--color-neutral-300);
  white-space: nowrap;
}

.tree-row {
  display: grid;
  grid-template-columns: 1.25rem minmax(8rem, 1fr) max-content;
  align-items: center;
  column-gap: var(--space-2);
  padding-left: calc(
    var(--space-pane-inline) +
    var(--virtual-tree-depth) *
    var(--tree-indent-step)
  );
}

.tree-toggle,
.tree-toggle-placeholder {
  inline-size: 1.25rem;
  block-size: 1.25rem;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--color-neutral-400);
  cursor: pointer;
}

.tree-toggle:hover,
.tree-toggle:focus-visible {
  color: var(--color-text);
}

.tree-node-main {
  display: inline-flex;
  min-width: 0;
  align-items: baseline;
  gap: var(--space-2);
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-key {
  flex: 0 0 auto;
  color: var(--color-text);
  font-weight: var(--font-weight-emphasis);
}

.tree-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-value-string {
  color: var(--color-syntax-string);
}

.tree-value-number {
  color: var(--color-syntax-number);
}

.tree-value-boolean,
.tree-value-null {
  color: var(--color-syntax-literal);
}

.tree-summary {
  color: var(--color-neutral-500);
  font-weight: var(--font-weight-emphasis);
}

.virtual-row.search-active {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
  background: var(--color-accent-soft);
}

.status-row {
  min-height: var(--status-height);
  flex: none;
  gap: var(--space-4);
  padding: var(--space-row-block) var(--space-pane-inline);
  border-top: var(--space-border) solid var(--color-divider);
  color: var(--color-neutral-500);
  font-size: var(--font-size-control);
}

.status-valid {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-positive);
}

.status-row > span {
  white-space: nowrap;
}

@media (max-width: 680px) {
  .editor-host .cm-content:has(.cm-placeholder) {
    min-width: 0;
    width: calc(100% - 32px);
  }

  .editor-host .cm-line:has(> .cm-placeholder) {
    width: 100%;
    padding-inline-end: var(--space-3);
    white-space: normal;
  }

  .editor-host .cm-placeholder {
    display: inline;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .workspace *,
  html body .workspace *::before,
  html body .workspace *::after {
    scroll-behavior: auto;
    animation-duration: var(--motion-reduced-duration);
    animation-iteration-count: 1;
    transition-duration: var(--motion-reduced-duration);
  }
}

.editor-host .cm-editor .cm-searchMatch,
.tree-search-match {
  border-radius: 2px;
  color: var(--color-search-match-text);
  background: var(--color-search-match);
  box-shadow: none;
}

.editor-host .cm-editor .cm-searchMatch-selected,
.editor-host .cm-editor .cm-searchMatch-selected *,
.tree-row.search-active .tree-search-match {
  color: var(--color-search-match-text);
  background: var(--color-search-match-active);
  outline: 2px solid var(--color-search-match-text);
  outline-offset: -1px;
  box-shadow: none;
}

.tree-search-match {
  padding: 0;
  font: inherit;
}
