:root {
  --ink: #1f2328;
  --muted: #656d76;
  --line: #e8eaed;
  --paper: #ffffff;
  --accent: #16a34a;
  --accent-hover: #15803d;
  --accent-soft: rgba(22, 163, 74, 0.1);
  --danger: #cf222e;
  --danger-soft: rgba(207, 34, 46, 0.08);
  --ok: #1a7f37;
  --ok-soft: rgba(26, 127, 55, 0.1);
  --mono: Consolas, "Courier New", "Cascadia Code", Monaco, monospace;
  --key: #953800;
  --str: #0a3069;
  --num: #0550ae;
  --bool: #cf222e;
  --null: #8250df;
  --punct: #24292f;
  --nav-h: 56px;
  --toolbar-h: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

body.ldm-nav-ready {
  padding-top: var(--nav-h) !important;
}

.workspace {
  display: flex;
  width: 100%;
  height: calc(100vh - var(--nav-h));
  height: calc(100dvh - var(--nav-h));
  background: #fff;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pane-input {
  flex: 1 1 50%;
  width: 50%;
  position: relative;
}

.pane-output {
  flex: 1 1 50%;
  width: 50%;
}

.splitter {
  flex: 0 0 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
}

.splitter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: var(--line);
}

.splitter:hover::before,
.splitter.active::before {
  background: var(--accent);
  width: 2px;
  left: 1.5px;
}

#jsonInput {
  display: none;
}

.CodeMirror {
  flex: 1;
  height: 100% !important;
  width: 100%;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  background: #fff;
}

.CodeMirror-scroll {
  min-height: 100%;
}

.CodeMirror-gutters {
  background: #f6f8fa;
  border-right: 1px solid var(--line);
}

.cm-error-gutter {
  width: 14px;
}

.CodeMirror-linenumber {
  color: #8c959f;
  padding: 0 8px 0 6px;
  min-width: 2.4em;
}

.CodeMirror-cursor {
  border-left: 2px solid var(--accent);
}

.cm-s-default .cm-string { color: #116329; }
.cm-s-default .cm-string-2 { color: #953800; }
.cm-s-default .cm-number { color: #0550ae; }
.cm-s-default .cm-atom { color: #cf222e; }
.cm-s-default .cm-keyword { color: #8250df; }
.cm-s-default .cm-property { color: #953800; }
.cm-s-default .cm-punctuation,
.cm-s-default .cm-bracket { color: #24292f; }

.CodeMirror-focused .CodeMirror-selected {
  background: rgba(22, 163, 74, 0.18);
}

.cm-error-line {
  background: rgba(207, 34, 46, 0.08) !important;
}

.cm-error-char {
  background: rgba(207, 34, 46, 0.22);
  border-bottom: 2px solid var(--danger);
}

.CodeMirror-gutter-elt .cm-error-marker {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 4px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(207, 34, 46, 0.2);
  cursor: pointer;
}

.pane-input.has-error .CodeMirror {
  background: #fffafb;
}

.toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: var(--toolbar-h);
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.btn {
  appearance: none;
  border: 1px solid rgba(22, 163, 74, 0.35);
  background: #fff;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn:active {
  background: rgba(22, 163, 74, 0.16);
  border-color: var(--accent-hover);
  color: var(--accent-hover);
}

.btn.is-active,
.btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.is-active:hover,
.btn[aria-pressed="true"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.dropdown {
  position: relative;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 40;
  min-width: 200px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
}

.dropdown-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.dropdown-menu .hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.search-input {
  width: 140px;
  max-width: 32vw;
  height: 28px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 12px;
  outline: none;
  background: #fff;
  font-family: inherit;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 11px;
  white-space: nowrap;
}

.status-pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill.err {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.empty {
  background: #f3f4f6;
  color: var(--muted);
}

.status-line {
  flex: 0 0 auto;
  display: none;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff8f8;
}

.status-line.show {
  display: flex;
}

.status-meta {
  color: var(--muted);
}

.status-error {
  flex: 1;
  min-width: 0;
  color: var(--danger);
  word-break: break-word;
  line-height: 1.5;
  font-size: inherit;
}

.status-error .err-text {
  display: inline;
}

.status-error .jump-hint,
.status-error .fix-hint {
  display: inline-block;
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  line-height: inherit;
}

.status-error .jump-hint:hover,
.status-error .fix-hint:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

.ai-fix-banner {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(22, 163, 74, 0.25);
  background: linear-gradient(180deg, #f0fdf4, #ecfdf5);
}

.ai-fix-banner[hidden] {
  display: none !important;
}

.ai-fix-body {
  flex: 1 1 260px;
  min-width: 0;
}

.ai-fix-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hover);
  margin-bottom: 4px;
}

.ai-fix-desc {
  font-size: 12px;
  color: #3f6212;
  line-height: 1.5;
}

.ai-fix-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-ai {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

.btn-ai:hover {
  background: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #fff !important;
}

.btn-ai:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-ai-cancel {
  border-color: rgba(22, 163, 74, 0.25) !important;
  color: var(--muted) !important;
  font-weight: 500 !important;
}

.ai-fix-banner.is-loading .ai-fix-title::after {
  content: "（处理中…）";
  font-weight: 600;
  color: var(--muted);
}

.result-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 20px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  background: #fff;
}

.placeholder {
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 24px 8px;
  text-align: center;
}

.tree {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree ul {
  margin: 0;
  padding-left: 18px;
  list-style: none;
}

.tree li {
  padding: 0;
  white-space: nowrap;
}

.tree .row {
  display: inline;
}

.tree .toggle {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 2px;
  border: 1px solid #d0d7de;
  background: #f6f8fa;
  color: #57606a;
  border-radius: 3px;
  font-size: 11px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  padding: 0;
  vertical-align: middle;
  font-family: inherit;
}

.tree .toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tree .toggle.empty {
  visibility: hidden;
}

.tree .collapsed > ul,
.tree .collapsed > .close-brace {
  display: none;
}

.tree .collapsed > .row .ellipsis {
  display: inline;
}

.tree .ellipsis {
  display: none;
  color: var(--muted);
}

.j-key { color: var(--key); }
.j-str { color: #116329; }
.j-num { color: var(--num); }
.j-bool { color: var(--bool); }
.j-null { color: var(--null); }
.j-punct { color: var(--punct); }
.j-index { color: var(--muted); }

.mark-hit {
  background: #fff3bf;
  border-radius: 2px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: #24292f;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 供搜索引擎抓取的 SEO 文案：不占操作区，不遮挡全屏编辑 */
.seo-panel {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
  }

  .pane-input,
  .pane-output {
    flex: 1 1 50%;
    width: 100%;
    height: 50%;
  }

  .splitter {
    flex: 0 0 5px;
    cursor: row-resize;
    width: 100%;
  }

  .splitter::before {
    top: 2px;
    left: 0;
    right: 0;
    width: auto;
    height: 1px;
  }

  .search-input {
    width: 110px;
  }
}
