:root {
  color-scheme: light;
  --bg-1: #f6f0e2;
  --bg-2: #efe4cf;
  --rail-bg: linear-gradient(180deg, #25313a 0%, #1b242b 100%);
  --panel-bg: rgba(255, 252, 246, 0.84);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --card-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(253, 248, 240, 0.98));
  --text: #1f2937;
  --muted: #667085;
  --muted-strong: #46505c;
  --border: rgba(95, 74, 51, 0.12);
  --accent: #c86b32;
  --accent-strong: #a14b18;
  --accent-soft: rgba(200, 107, 50, 0.14);
  --teal: #0f766e;
  --teal-soft: rgba(15, 118, 110, 0.13);
  --danger: #c2410c;
  --danger-soft: rgba(194, 65, 12, 0.12);
  --shadow-lg: 0 24px 60px rgba(65, 44, 24, 0.14);
  --shadow-md: 0 16px 34px rgba(74, 50, 25, 0.1);
  --shadow-sm: 0 10px 22px rgba(57, 41, 21, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --font-display: "Segoe UI Semibold", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 760px;
  min-height: 760px;
  background:
    radial-gradient(circle at top left, rgba(200, 107, 50, 0.22), transparent 24%),
    radial-gradient(circle at bottom right, rgba(15, 118, 110, 0.14), transparent 24%),
    linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 100%);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  padding: 22px;
}

button,
textarea,
input,
select,
summary {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  min-height: calc(100vh - 44px);
}

.side-rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  background: var(--rail-bg);
  color: #f8fafc;
  box-shadow: var(--shadow-lg);
}

.brand-block {
  position: relative;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  overflow: hidden;
}

.brand-block::after {
  content: "";
  position: absolute;
  inset: auto -30px -42px auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(200, 107, 50, 0.3), transparent 68%);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.side-rail .eyebrow {
  color: rgba(255, 255, 255, 0.66);
}

.brand-block h1,
.workspace-header h2,
.section-banner h3,
.card h3 {
  margin: 0;
  font-family: var(--font-display);
}

.brand-block h1 {
  font-size: 28px;
  line-height: 1.15;
}

.hero-text,
.workspace-subtitle,
.section-text,
.side-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.side-rail .hero-text {
  color: rgba(255, 255, 255, 0.74);
}

.panel-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-chip,
.ghost-button,
.copy-btn,
.action-row button,
.section-tab {
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.panel-chip,
.ghost-button,
.copy-btn,
.action-row button,
.section-tab {
  border: 1px solid var(--border);
  cursor: pointer;
}

.panel-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px 15px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.88);
  text-align: left;
}

.panel-chip:hover,
.ghost-button:hover,
.copy-btn:hover,
.action-row button:hover,
.section-tab:hover {
  transform: translateY(-1px);
}

.panel-chip.active {
  border-color: rgba(255, 255, 255, 0.1);
  background: linear-gradient(135deg, rgba(200, 107, 50, 0.22), rgba(15, 118, 110, 0.14));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.chip-title {
  font-weight: 700;
}

.chip-desc {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  line-height: 1.45;
}

.side-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: auto;
  padding: 14px 15px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.note-dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: linear-gradient(135deg, #f4b47f, #c86b32);
  box-shadow: 0 0 0 5px rgba(200, 107, 50, 0.12);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.workspace-header,
.tool-panel {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-xl);
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-lg);
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 24px 28px;
}

.workspace-header .eyebrow {
  color: var(--accent-strong);
}

.workspace-header h2 {
  font-size: 30px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-button,
.copy-btn,
.action-row button,
.section-tab {
  padding: 10px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
}

.ghost-button {
  box-shadow: var(--shadow-sm);
}

.copy-btn,
.action-row button:not(.secondary),
.section-tab.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #e18d4f);
  color: #fff;
  box-shadow: 0 14px 26px rgba(200, 107, 50, 0.18);
}

.action-row button.secondary,
.section-tab {
  background: rgba(255, 255, 255, 0.72);
}

.tool-panel {
  display: none;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.tool-panel.active {
  display: flex;
}

.section-banner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(255, 250, 244, 0.95), rgba(244, 235, 221, 0.96)),
    linear-gradient(135deg, rgba(200, 107, 50, 0.06), rgba(15, 118, 110, 0.05));
  border: 1px solid rgba(200, 107, 50, 0.08);
}

.panel-kicker {
  color: var(--accent-strong);
}

.section-banner h3 {
  font-size: 28px;
  line-height: 1.2;
}

.section-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.section-tags span {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(200, 107, 50, 0.14);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 600;
}

.section-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.split-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 16px;
}

.es-workbench {
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  align-items: stretch;
}

.subpanel-stack {
  display: flex;
  flex-direction: column;
}

.subpanel {
  display: none;
}

.subpanel.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(95, 74, 51, 0.1);
  background: var(--card-bg);
  box-shadow: var(--shadow-md);
}

.card.tall {
  min-height: 420px;
}

.workspace-pane {
  min-height: 460px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.info-badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.mode-switch {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-pill {
  padding: 10px 14px;
  border: 1px solid rgba(95, 74, 51, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--muted-strong);
  cursor: pointer;
}

.mode-pill.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #e18d4f);
  color: #fff;
  box-shadow: 0 12px 22px rgba(200, 107, 50, 0.18);
}

textarea,
.field-grid input,
.field-grid select {
  width: 100%;
  border: 1px solid rgba(107, 114, 128, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

textarea {
  min-height: 154px;
  resize: vertical;
  padding: 14px 15px;
  line-height: 1.55;
}

textarea.output {
  background: #fff;
}

.tall textarea {
  min-height: 290px;
}

.workbench-input {
  min-height: 240px;
}

.wide-output {
  min-height: 260px;
}

.es-output-card {
  gap: 16px;
}

.es-output-card .card-header {
  align-items: flex-start;
}

.es-output-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.es-output-heading .helper-text {
  margin-top: 0;
}

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

.es-output-stats .compare-stat {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(248, 242, 232, 0.96)),
    rgba(200, 107, 50, 0.08);
}

.es-output-area {
  min-height: 420px;
  padding: 16px 18px;
  border-color: rgba(95, 74, 51, 0.16);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 245, 238, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(95, 74, 51, 0.04);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid label,
.range-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field-grid input,
.field-grid select {
  padding: 12px 14px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.action-row.compact button {
  padding: 9px 12px;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.helper-text code {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tree-card {
  min-height: 420px;
}

.tree-view {
  min-height: 260px;
  padding: 16px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(107, 114, 128, 0.26);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(247, 243, 237, 0.9));
  font-family: Consolas, "Courier New", monospace;
}

.tree-view.empty-state,
.diff-output.empty-state,
.image-compare-grid.empty-state,
.result-list.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.tree-branch {
  margin-left: 10px;
}

.tree-summary,
.tree-leaf {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  line-height: 1.45;
}

.tree-summary {
  cursor: pointer;
  list-style: none;
}

.tree-summary:hover,
.tree-leaf:hover {
  background: rgba(200, 107, 50, 0.08);
}

.tree-summary::-webkit-details-marker {
  display: none;
}

.tree-summary::before {
  content: "▸";
  color: var(--accent-strong);
  font-size: 12px;
  transition: transform 0.15s ease;
}

.tree-branch[open] > .tree-summary::before {
  transform: rotate(90deg);
}

.tree-children {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 4px 18px;
  padding-left: 12px;
  border-left: 1px dashed rgba(107, 114, 128, 0.26);
}

.tree-key {
  color: var(--accent-strong);
}

.tree-type,
.tree-count {
  color: var(--muted);
  font-size: 12px;
}

.tree-value.string {
  color: var(--teal);
}

.tree-value.number {
  color: #2457d6;
}

.tree-value.boolean,
.tree-value.null {
  color: #7c3aed;
}

.diff-output {
  min-height: 140px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(107, 114, 128, 0.26);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(246, 241, 233, 0.92));
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-viewer-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diff-viewer-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted-strong);
  font-weight: 600;
}

.diff-viewer {
  min-height: 300px;
  padding: 14px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(107, 114, 128, 0.22);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 243, 237, 0.94));
}

.diff-viewer.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.diff-viewer-head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 3;
  padding-bottom: 8px;
  background: linear-gradient(180deg, rgba(247, 243, 237, 0.96), rgba(247, 243, 237, 0.82));
  backdrop-filter: blur(8px);
}

.diff-head-cell {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(95, 74, 51, 0.1);
  color: var(--muted-strong);
  font-weight: 700;
}

.diff-branch {
  margin: 0;
}

.diff-branch + .diff-branch,
.diff-row + .diff-row {
  margin-top: 8px;
}

.diff-branch-summary {
  list-style: none;
  cursor: pointer;
}

.diff-branch-summary::-webkit-details-marker {
  display: none;
}

.diff-branch-summary::marker {
  content: "";
}

.diff-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.diff-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 58px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid rgba(95, 74, 51, 0.1);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.diff-cell.empty {
  justify-content: center;
  color: rgba(102, 112, 133, 0.6);
  background: rgba(247, 243, 237, 0.72);
  border-style: dashed;
}

.diff-cell.added {
  background: rgba(15, 118, 110, 0.08);
  border-color: rgba(15, 118, 110, 0.18);
}

.diff-cell.removed {
  background: rgba(194, 65, 12, 0.08);
  border-color: rgba(194, 65, 12, 0.18);
}

.diff-cell.changed {
  background: rgba(200, 107, 50, 0.1);
  border-color: rgba(200, 107, 50, 0.2);
}

.diff-cell.unchanged {
  background: rgba(255, 255, 255, 0.84);
}

.diff-cell-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.diff-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  color: var(--accent-strong);
  font-size: 12px;
  flex: 0 0 auto;
  transition: transform 0.16s ease;
}

.diff-branch[open] > .diff-branch-summary .diff-toggle-icon {
  transform: rotate(90deg);
}

.diff-key {
  color: var(--accent-strong);
  font-weight: 700;
  min-width: 0;
  word-break: break-word;
}

.diff-meta {
  color: var(--muted);
  font-size: 12px;
}

.diff-preview {
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.diff-status.added {
  background: var(--teal-soft);
  color: var(--teal);
}

.diff-status.removed {
  background: var(--danger-soft);
  color: var(--danger);
}

.diff-status.changed {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.diff-status.unchanged {
  background: rgba(102, 112, 133, 0.12);
  color: var(--muted-strong);
}

.diff-branch-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 0 16px;
  padding-left: 12px;
  border-left: 1px dashed rgba(107, 114, 128, 0.22);
}

.stat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-stat-grid,
.result-metrics {
  display: grid;
  gap: 10px;
}

.mini-stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-item,
.compare-stat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(200, 107, 50, 0.08);
  color: var(--muted-strong);
}

.compare-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.diff-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compare-stat strong,
.stat-item strong {
  color: var(--text);
}

.upload-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 140px;
  padding: 18px;
  border: 2px dashed rgba(107, 114, 128, 0.25);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(250, 244, 235, 0.84));
  cursor: pointer;
  text-align: center;
}

.upload-box input {
  display: none;
}

.result-list,
.image-compare-grid {
  display: grid;
  gap: 12px;
}

.result-item,
.image-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(95, 74, 51, 0.12);
  background: rgba(255, 255, 255, 0.88);
}

.result-item .meta,
.image-card .meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.result-item a {
  color: var(--accent-strong);
}

.image-compare-grid {
  grid-template-columns: repeat(var(--image-columns, 2), minmax(0, 1fr));
  max-height: 620px;
  overflow: auto;
}

.image-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-card.loading {
  border-color: rgba(200, 107, 50, 0.22);
}

.image-card.loaded {
  border-color: rgba(15, 118, 110, 0.2);
}

.image-card.failed {
  border-color: rgba(194, 65, 12, 0.28);
  background: rgba(255, 245, 241, 0.96);
}

.image-status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.image-status.loading {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.image-status.loaded {
  background: var(--teal-soft);
  color: var(--teal);
}

.image-status.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.image-card img {
  width: 100%;
  height: var(--preview-height, 240px);
  object-fit: contain;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
}

.image-placeholder {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: var(--preview-height, 240px);
  padding: 18px;
  border-radius: 12px;
  background: rgba(194, 65, 12, 0.08);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-line;
}

.image-card.failed img {
  display: none;
}

.image-card.failed .image-placeholder {
  display: flex;
}

.toast {
  position: fixed;
  right: 30px;
  bottom: 28px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(31, 41, 55, 0.94);
  color: #fff;
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1240px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    gap: 16px;
  }

  .panel-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .workspace-header,
  .section-banner,
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .grid.two,
  .grid.three,
  .split-workbench,
  .field-grid,
  .compare-stats,
  .diff-stats,
  .diff-viewer-head,
  .diff-row,
  .mini-stat-grid,
  .result-metrics,
  .image-compare-grid,
  .panel-nav {
    grid-template-columns: 1fr;
  }
}
