:root {
  color-scheme: light;
  --bg: #f7f3ed;
  --panel: #fffaf3;
  --panel-strong: #ffffff;
  --ink: #202124;
  --muted: #6f6b63;
  --line: #ded7cb;
  --accent: #245d63;
  --accent-strong: #17464b;
  --accent-soft: #dcebec;
  --danger: #b42318;
  --danger-soft: #ffe5df;
  --key: #7a3e9d;
  --string: #186c43;
  --number: #9a4b00;
  --boolean: #0f5eaf;
  --null: #7b6875;
  --shadow: 0 24px 60px rgba(39, 31, 20, 0.14);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(36, 93, 99, 0.1), transparent 36%),
    linear-gradient(315deg, rgba(150, 72, 34, 0.12), transparent 32%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  width: min(1440px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
}

.panel {
  display: flex;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.92);
  box-shadow: var(--shadow);
}

.input-panel,
.output-panel {
  flex-direction: column;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 750;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.ghost-button:hover,
.ghost-button.active {
  background: var(--accent-soft);
}

.primary-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

input,
textarea {
  width: 100%;
  border: 0;
  outline: 0;
}

input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--panel-strong);
  color: var(--ink);
}

.advanced-fields {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

.advanced-fields[hidden] {
  display: none;
}

.field-block {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.response-label {
  padding: 12px 18px 8px;
  border-bottom: 1px solid rgba(222, 215, 203, 0.6);
  background: rgba(255, 255, 255, 0.42);
}

.main-textarea,
.small-textarea {
  resize: none;
  background: #171b1d;
  color: #eef7f8;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.94rem;
  line-height: 1.55;
  tab-size: 2;
}

.main-textarea {
  flex: 1;
  min-height: 300px;
  padding: 18px;
}

.small-textarea {
  min-height: 132px;
  border-radius: 7px;
  padding: 12px;
}

.main-textarea::placeholder,
.small-textarea::placeholder {
  color: #97abad;
}

.status-line {
  min-height: 42px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.status-line.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.tree-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px 18px 22px;
  background: var(--panel);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
  line-height: 1.5;
}

.empty-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--muted);
  font-family: inherit;
  font-weight: 700;
  text-align: center;
}

.context-section {
  margin: 0 0 18px;
}

.context-section:last-child {
  margin-bottom: 0;
}

.context-title {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.request-url {
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
}

.tree-list,
.tree-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tree-list ul {
  margin-left: 22px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

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

.tree-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-height: 28px;
  border-radius: 6px;
  padding: 2px 7px 2px 2px;
}

.tree-row:hover {
  background: rgba(36, 93, 99, 0.08);
}

.toggle {
  display: inline-grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 900;
}

.toggle:hover {
  background: var(--accent-soft);
}

.toggle.placeholder {
  visibility: hidden;
}

.tree-node.collapsed > .tree-list {
  display: none;
}

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

.attribute {
  color: var(--number);
}

.punctuation,
.summary {
  color: var(--muted);
}

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

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

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.copy-helper {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .panel {
    min-height: 48vh;
  }

  .main-textarea {
    min-height: 320px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100vw - 20px, 1440px);
    margin: 10px auto;
  }

  .panel-header {
    align-items: stretch;
    padding: 14px;
  }

  .actions,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .primary-button,
  .ghost-button {
    justify-content: center;
  }
}
