*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;

  --bg: #1a1b26;
  --surface: #24283b;
  --surface2: #2f3349;
  --border: #3b4261;
  --text: #c0caf5;
  --muted: #565f89;
  --label: #7982b0;
  --accent: #7aa2f7;

  --json-string: #9ece6a;
  --json-number: #ff9e64;
  --json-boolean: #7dcfff;
  --json-index: #e0af68;

  --error-color: #f7768e;
  --error-bg: rgba(247, 118, 142, 0.10);
  --on-path-bg: rgba(122, 162, 247, 0.06);

  --mono-font: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
}

html {
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Header ── */

.app-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.app-header .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Layout ── */

.app-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 0;
}

/* ── Inputs ── */

.inputs-panel {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.input-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border-bottom: 1px solid var(--border);
}

.input-group:has(#error-input) {
  flex: 0.4;
}

.input-group label {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--label);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.input-group textarea {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: none;
  outline: none;
  padding: 12px 14px;
  font-family: var(--mono-font);
  font-size: 12.5px;
  line-height: 1.65;
  resize: none;
  tab-size: 2;
}

.input-group textarea:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.input-group textarea::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* ── Examples bar ── */

.examples-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface2);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.examples-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--label);
  white-space: nowrap;
}

#examples {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#examples button {
  font-family: inherit;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

#examples button:hover {
  background: var(--bg);
  border-color: var(--accent);
}

/* ── Output ── */

.output-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.path-display {
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--error-color);
  font-size: 13px;
  flex-shrink: 0;
}

.path-display.error-mismatch { border-left-color: var(--muted); color: var(--muted); }
.path-display.hint { border-left-color: var(--muted); }

.path-label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.error-type-tag {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono-font);
  color: var(--accent);
}

.path-segment {
  font-family: var(--mono-font);
  color: var(--text);
}

.missing-key-label {
  font-family: var(--mono-font);
  color: var(--error-color);
}

.path-message {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#output {
  flex: 1;
  overflow: auto;
  padding: 14px 16px;
}

.output-placeholder {
  color: var(--muted);
  font-size: 14px;
}

.output-error {
  color: var(--error-color);
  font-size: 13px;
  font-family: var(--mono-font);
}

/* ── JSON tree ── */

.json-tree {
  font-family: var(--mono-font);
  font-size: 13px;
  line-height: 1.7;
}

.json-children {
  padding-left: 18px;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}

.json-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
}

.json-string  { color: var(--json-string); }
.json-number  { color: var(--json-number); }
.json-boolean { color: var(--json-boolean); }
.json-null    { color: var(--muted); }
.json-key     { color: var(--accent); }
.json-index   { color: var(--json-index); }
.json-sep     { color: var(--text); opacity: 0.5; margin-right: 4px; }
.json-punct   { color: var(--text); opacity: 0.6; }

/* Highlighted node */

.json-array.highlighted,
.json-object.highlighted {
  background: var(--error-bg);
  border-radius: 4px;
  outline: 1px solid var(--error-color);
  outline-offset: 2px;
}

.json-string.highlighted,
.json-number.highlighted,
.json-boolean.highlighted,
.json-null.highlighted {
  background: var(--error-bg);
  border-radius: 3px;
  outline: 1px solid var(--error-color);
  padding: 0 2px;
}

/* Ancestor of highlighted node */

.json-array.on-path,
.json-object.on-path {
  background: var(--on-path-bg);
  border-radius: 4px;
}

/* Missing key ghost row */

.json-missing-row {
  opacity: 0.75;
}

.json-missing-key {
  color: var(--error-color);
  text-decoration: underline dotted;
}

.json-missing-hint {
  color: var(--error-color);
  font-style: italic;
  margin-left: 6px;
  font-size: 12px;
}
