.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.middle-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.middle-actions button {
  width: 100%;
  min-height: 44px;
}

.output-area {
  width: 100%;
  min-height: 320px;
  padding: 12px;
  resize: vertical;
  border-bottom-right-radius: 0;
  overflow: auto;
  /* font: 14px/1.5 Consolas, Monaco, monospace; */
  background: var(--control-bg, #fff);
  color: var(--text, #222);
}

.output-area.is-error-output {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

.CodeMirror {
  height: 320px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  /* font: 14px/1.5 Consolas, Monaco, monospace; */
  /* font-family: inherit; */
  font-size: 15px;
  background: var(--control-bg, #fff);
  color: var(--text, #222);
}
.CodeMirror-focused {
  border-color: var(--accent, #f97316);
}

body.is-dark .CodeMirror-gutters {
  background: #151c24;
  border-right: 1px solid #2e3947;
}

body.is-dark .CodeMirror-linenumber {
  color: #8f9bab;
}

body.is-dark .CodeMirror-cursor {
  border-left-color: #f2f5f9;
}

body.is-dark .cm-property {
  color: var(--tree-key);
}

body.is-dark .cm-string {
  color: var(--tree-string);
}

body.is-dark .cm-number {
  color: var(--tree-number);
}

body.is-dark .cm-atom,
body.is-dark .cm-keyword {
  color: var(--tree-boolean);
}

.cm-error-line {
  background: var(--error-line);
}

.cm-error-char {
  background: var(--error-char);
  border-bottom: 2px solid #d32f2f;
}

/* .inspector-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--panel-border, #ddd);
  border-radius: 10px;
  background: var(--soft-bg, #fafafa);
}

.inspector-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: stretch;
  margin-top: 12px;
}

.inspector-child-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
  border: 1px solid var(--panel-border, #ddd);
  border-radius: 10px;
  background: var(--panel-bg, #fff);
} */

.tree-panel,
.stats-panel {
  margin-top: 0;
}

.tree-header {
  margin-top: 0;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

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

.tree-search-input {
  min-width: 220px;
}

.tree-search-count {
  font-size: 12px;
  color: var(--muted, #555);
  padding: 0 4px;
}

.tree-view {
  flex: 1 1 auto;
  min-height: 20px;
  max-height: 520px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--panel-border, #ddd);
  border-radius: 8px;
  background: var(--tree-bg, #fff);
  font: 14px/1.6 Consolas, Monaco, monospace;
}
/* .tree-view:not(:has(.tree-root)) {
  display: none;
} */
.tree-view.is-empty {
  color: var(--tree-empty, #777);
}

.tree-root,
.tree-root ul {
  list-style: none;
  margin: 0;
  padding-left: 18px;
}

.tree-root {
  padding-left: 0;
}

.tree-item {
  margin: 2px 0;
}

.tree-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
  border-radius: 6px;
}

.tree-row.is-search-match {
  background: var(--search-match-bg);
  outline: 1px solid var(--search-match-border);
}

.tree-row.is-search-current {
  background: var(--search-current-bg);
  outline: 1px solid var(--search-current-border);
}

.tree-toggle {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
  line-height: 16px;
  border-radius: 4px;
  text-align: center;
  font-size: 13px;
  line-height: 1;
  font-weight: 500;
  min-height: 0;
}

.tree-toggle.is-hidden {
  visibility: hidden;
}

.tree-key {
  color: var(--tree-key);
  font-weight: bold;
}

.tree-type {
  color: var(--tree-type);
  font-size: 12px;
}

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

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

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

.tree-value-null {
  color: var(--tree-null);
  font-style: italic;
}

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

.tree-meta {
  color: var(--tree-type);
  font-size: 12px;
}

.tree-children.is-collapsed {
  display: none;
}

.stats-grid {
  margin-top: 0;
  display: block;
}

.stats-grid.is-empty {
  display: block;
}

.stats-empty {
  color: var(--muted, #555);
  padding: 12px 0;
}

.stats-card {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--muted-border);
  border-radius: 0;
}

.stats-card-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.4;
}

.stats-card-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .middle-actions {
    flex-direction: row;
    justify-content: stretch;
  }

  .middle-actions button {
    flex: 1 1 0;
  }
}

@media (max-width: 900px) {
  /* .inspector-layout {
    grid-template-columns: 1fr;
  } */

  .tree-view {
    /* min-height: 220px; */
    max-height: 320px;
  }
}

@media (max-width: 768px) {
  .CodeMirror,
  .output-area {
    min-height: 280px;
    height: 280px;
  }

  .tree-search-input {
    min-width: 100%;
  }

  /* .middle-actions {
    flex-direction: column;
  } */
}

/* add */

.tool-description {
  margin-top: 24px;
  padding-top: 8px;
}

.tool-description h2 {
  margin: 20px 0 8px;
  font-size: 20px;
  line-height: 1.4;
}

.tool-description p {
  margin: 0 0 12px;
  color: var(--text, #222);
}

.tool-description ul {
  margin: 0 0 12px 20px;
  padding: 0;
}

.tool-description li {
  margin: 0 0 6px;
}

/* .tree-panel #treeView:not(:has(*)),
.tree-panel:not(:has(#treeView *)) .tree-header .tree-actions { */
/* .tree-panel:not(:has(#treeView *)) {
  opacity: 0.45;
  pointer-events: none;
} */
.tree-panel:not(:has(#treeView *)) .tree-header .tree-actions {
  display: none;
}

.tree-panel:has(#treeSearchInput:placeholder-shown) #treeSearchPrevBtn,
.tree-panel:has(#treeSearchInput:placeholder-shown) #treeSearchNextBtn {
  opacity: 0.3;
  pointer-events: none;
}