:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #17202a;
  --muted: #5f6b7a;
  --line: #d8ded6;
  --panel: #ffffff;
  --accent: #306998;
  --accent-strong: #1f4f75;
  --gold: #ffd43b;
  --good: #24755b;
  --bad: #a63d40;
  --shadow: 0 18px 50px rgba(35, 45, 55, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(135deg, rgba(255, 212, 59, 0.18), transparent 32rem),
    linear-gradient(315deg, rgba(60, 138, 109, 0.14), transparent 30rem),
    var(--bg);
  color: var(--ink);
}

a {
  color: var(--accent);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 46px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.back-link {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  font-weight: 800;
}

.brand-title {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  letter-spacing: 0;
  line-height: 1.05;
}

.intro {
  max-width: 760px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.status {
  min-width: 138px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: right;
}

.status[data-kind="ready"] {
  border-left-color: var(--good);
  color: var(--good);
}

.status[data-kind="error"] {
  border-left-color: var(--bad);
  color: var(--bad);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.panel-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.panel-actions input:not(.file-input) {
  width: min(160px, 36vw);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  min-height: 40px;
}

.tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  padding: 0 13px;
  cursor: pointer;
  font-weight: 800;
}

.tab-button[aria-selected="true"] {
  border-color: var(--accent);
  background: #eef4f8;
  color: var(--accent);
}

.tab-panel[hidden] {
  display: none;
}

.notes-list {
  display: grid;
  gap: 10px;
}

.note-item {
  display: grid;
  gap: 3px;
  border: 1px solid #d7dfdf;
  border-radius: 7px;
  background: #fff;
  padding: 10px 12px;
}

.note-item b {
  color: var(--ink);
}

.note-item span {
  color: var(--muted);
  line-height: 1.45;
}

.panel-body {
  padding: 16px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

label,
.field-label {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c9d2d6;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  line-height: 1.45;
}

textarea {
  min-height: 220px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(48, 105, 152, 0.24);
  outline-offset: 1px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 12px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.check input {
  width: auto;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--accent-strong);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 0 15px;
  cursor: pointer;
  font-weight: 800;
}

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

.button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--accent);
}

.button.secondary:hover {
  background: #eef4f8;
}

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf7;
  padding: 11px;
}

.metric b {
  display: block;
  font-size: 1.3rem;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-banner {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-left-width: 8px;
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 13px 14px;
  background: #f7f8f5;
}

.result-banner[data-state="yes"] {
  border-color: rgba(36, 117, 91, 0.38);
  border-left-color: var(--good);
  background: #eef8f3;
}

.result-banner[data-state="no"] {
  border-color: rgba(166, 61, 64, 0.34);
  border-left-color: var(--bad);
  background: #fff2f1;
}

.result-banner[data-state="empty"] {
  border-left-color: var(--gold);
}

.result-banner-label,
.result-banner-detail {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.result-banner strong {
  color: var(--ink);
  font-size: 1.02rem;
}

.match-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.match-card {
  border: 1px solid #cad6d6;
  border-radius: 8px;
  background: #fbfcf8;
  padding: 12px;
}

.match-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.match-card-header strong {
  font-size: 0.95rem;
}

.span-pill {
  border-radius: 999px;
  background: rgba(48, 105, 152, 0.12);
  color: var(--accent-strong);
  padding: 4px 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.match-context {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.match-context-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.match-context-line {
  display: block;
  overflow-x: auto;
  border: 1px solid #d8e1dd;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

.match-context-line mark {
  border-radius: 5px;
  background: #b8f3c3;
  color: #17202a;
  padding: 2px 3px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  font-weight: 900;
}

.context-elision {
  color: var(--muted);
  font-weight: 900;
}

.group-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.group-chip {
  border: 1px solid rgba(48, 105, 152, 0.24);
  border-radius: 999px;
  background: #edf5fb;
  color: #163d5d;
  padding: 5px 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 800;
}

.group-chip.muted,
.match-empty {
  border-color: var(--line);
  background: #f6f7f2;
  color: var(--muted);
}

.match-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
}

.json-tree {
  display: grid;
  gap: 8px;
  max-height: 380px;
  overflow: auto;
  border: 1px solid #d7dfdf;
  border-radius: 8px;
  background: #fbfcf8;
  padding: 10px 10px 10px 18px;
  margin-top: 22px;
}

.json-node {
  border: 1px solid #d8e1dd;
  border-radius: 8px;
  background: #fff;
}

.json-node summary {
  padding-left: 4px;
  cursor: pointer;
  list-style-position: outside;
}

.json-node summary::marker {
  color: var(--accent);
}

.json-leaf {
  padding: 0;
}

.json-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
}

.json-node-main {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.json-path {
  color: var(--ink);
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  font-weight: 800;
}

.json-preview {
  color: var(--muted);
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.8rem;
}

.type-badge {
  border-radius: 999px;
  padding: 3px 7px;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.type-object {
  background: #306998;
}

.type-array {
  background: #6b5fb5;
}

.type-string {
  background: #24755b;
}

.type-number {
  background: #9a5f1e;
}

.type-boolean {
  background: #8b4f8f;
}

.type-null {
  background: #687380;
}

.json-node-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.copy-node {
  display: inline-grid;
  place-items: center;
  position: relative;
  width: 30px;
  height: 30px;
  border: 1px solid #c9d2d6;
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  font-weight: 850;
}

.copy-node:hover {
  background: #eef4f8;
}

.copy-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + 7px);
  z-index: 5;
  min-width: max-content;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  border: 1px solid #c9d2d6;
  border-radius: 6px;
  background: #17202a;
  color: #fff;
  padding: 5px 7px;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.18);
}

.copy-tooltip-below {
  top: calc(100% + 7px);
  bottom: auto;
}

.copy-node:hover .copy-tooltip,
.copy-node:focus-visible .copy-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.json-children {
  display: grid;
  gap: 7px;
  border-top: 1px solid #edf0ec;
  margin-left: 16px;
  padding: 8px;
}

pre,
code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

pre.output {
  min-height: 220px;
  max-height: 520px;
  margin: 0;
  overflow: auto;
  border: 1px solid #d7dfdf;
  border-radius: 7px;
  background: #111820;
  color: #e9f0ef;
  padding: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.healed-preview {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.healed-source {
  max-height: 180px;
  margin: 0;
  overflow: auto;
  border: 1px solid #b8d4c7;
  border-radius: 7px;
  background: #f5fbf7;
  color: var(--ink);
  padding: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.json-added {
  border-radius: 3px;
  background: lightgreen;
  box-shadow: 0 0 0 1px rgba(32, 125, 73, 0.2);
}

.visual-diff {
  max-height: 460px;
  margin-bottom: 14px;
  overflow: auto;
  border: 1px solid #d7dfdf;
  border-radius: 7px;
  background: #fff;
}

.diff-row {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  min-width: 720px;
  border-bottom: 1px solid #edf0ec;
}

.diff-row:last-child {
  border-bottom: 0;
}

.diff-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f8f8;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diff-cell {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  min-height: 34px;
  border-right: 1px solid #edf0ec;
  align-items: stretch;
}

.diff-cell:last-child {
  border-right: 0;
}

.diff-line-number {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  border-right: 1px solid rgba(87, 102, 104, 0.18);
  color: #778486;
  padding: 6px 8px;
  user-select: none;
}

.diff-line-text {
  min-width: 0;
  padding: 6px 10px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.diff-row[data-kind="delete"] .diff-cell-left,
.diff-row[data-kind="replace"] .diff-cell-left {
  background: #ffe9e7;
}

.diff-row[data-kind="insert"] .diff-cell-right,
.diff-row[data-kind="replace"] .diff-cell-right {
  background: #e5f8eb;
}

.diff-row[data-kind="delete"] .diff-cell-right,
.diff-row[data-kind="insert"] .diff-cell-left {
  background: #f7f8f6;
}

.error-text {
  color: #ffd9d5;
}

.preview-frame {
  width: 100%;
  min-height: 260px;
  border: 1px solid #d7dfdf;
  border-radius: 7px;
  background: #fff;
}

.hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

@media (max-width: 760px) {
  .page {
    width: min(100% - 22px, 1180px);
    padding-top: 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status {
    width: 100%;
    text-align: left;
  }

  .tool-grid,
  .summary {
    grid-template-columns: 1fr;
  }
}
