:root {
  color-scheme: dark;
  --bg: #0a0d12;
  --panel: #10151d;
  --panel-raised: #151c26;
  --field: #080b10;
  --line: #27303d;
  --line-strong: #3d4a5c;
  --text: #eef2f5;
  --muted: #778395;
  --muted-strong: #aab4c1;
  --acid: #c5f467;
  --acid-soft: rgba(197, 244, 103, 0.1);
  --violet: #b7a0ff;
  --cyan: #70dadd;
  --orange: #ffad72;
  --green: #75e3a3;
  --red: #ff707d;
  --shadow: rgba(0, 0, 0, 0.27);
}

body.light {
  color-scheme: light;
  --bg: #edf0ea;
  --panel: #f9faf6;
  --panel-raised: #ffffff;
  --field: #f1f3ed;
  --line: #cbd2c6;
  --line-strong: #9ca89a;
  --text: #172018;
  --muted: #6f7c70;
  --muted-strong: #4d5b4f;
  --acid: #4e7900;
  --acid-soft: rgba(78, 121, 0, 0.09);
  --violet: #6950c8;
  --cyan: #087b81;
  --orange: #b7591c;
  --green: #147a45;
  --red: #c93649;
  --shadow: rgba(36, 47, 34, 0.09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(rgba(197, 244, 103, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(197, 244, 103, 0.018) 1px, transparent 1px),
    radial-gradient(circle at 8% -8%, rgba(197, 244, 103, 0.075), transparent 29rem),
    radial-gradient(circle at 96% 41%, rgba(183, 160, 255, 0.05), transparent 26rem),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
  color: var(--text);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  transition: background-color 0.2s, color 0.2s;
}

button, textarea, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.42; }
button:focus-visible, textarea:focus-visible, pre:focus-visible, input:focus-visible + span { outline: 2px solid var(--acid); outline-offset: 2px; }
.app { width: min(1260px, calc(100% - 48px)); margin: 0 auto; }
.sr-only { width: 1px; height: 1px; position: absolute; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-size: 13px; font-weight: 700; letter-spacing: 0.17em; }
.brand-mark { width: 31px; height: 31px; display: flex; align-items: center; justify-content: center; gap: 2px; border: 1px solid var(--line-strong); background: var(--panel); font: 600 11px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.brand-mark i { color: var(--acid); font-style: normal; }
.brand-mark b { color: var(--violet); font-size: 10px; }
.top-actions { display: flex; align-items: center; gap: 20px; }
.local-status { color: var(--muted); font: 500 10px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.12em; }
.local-status i { width: 6px; height: 6px; display: inline-block; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); }
.square-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; }
.square-button:hover { border-color: var(--line-strong); background: var(--panel); }
.square-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; }

.intro { min-height: 174px; display: flex; align-items: flex-end; justify-content: space-between; gap: 48px; padding: 40px 0 31px; }
.eyebrow, .metric-card > p, .indent-control legend { margin: 0; color: var(--muted); font: 500 9px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.15em; }
.intro h1 { max-width: 760px; margin: 8px 0 0; font-size: clamp(33px, 4.4vw, 58px); font-weight: 500; line-height: 1; letter-spacing: -0.045em; }
.intro > p { width: min(380px, 37%); margin: 0 0 3px; color: var(--muted-strong); font-size: 13px; line-height: 1.65; }

.control-bar { min-height: 68px; display: flex; align-items: center; gap: 26px; padding: 9px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 18px 50px var(--shadow); }
.indent-control { min-width: 325px; display: flex; align-items: center; gap: 15px; margin: 0; padding: 0; border: 0; }
.indent-control legend { float: left; padding: 0; }
.segmented { height: 42px; display: grid; flex: 1; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: var(--field); }
.segmented label { min-width: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { height: 100%; display: grid; place-items: center; padding: 0 8px; color: var(--muted); font: 600 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.07em; cursor: pointer; }
.segmented input:checked + span { background: var(--acid); color: #182106; }
.option-toggle { display: flex; align-items: center; gap: 9px; color: var(--muted); cursor: pointer; }
.option-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.option-toggle > span { width: 27px; height: 15px; position: relative; border: 1px solid var(--line-strong); background: var(--field); }
.option-toggle > span::after { content: ""; width: 9px; height: 9px; position: absolute; top: 2px; left: 2px; background: var(--muted); transition: 0.15s; }
.option-toggle input:checked + span::after { left: 14px; background: var(--acid); }
.option-toggle b { font: 500 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.07em; }
.bar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.bar-actions button { padding: 8px 0; border: 0; background: transparent; color: var(--muted); font: 500 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; }
.bar-actions button:hover { color: var(--text); }
.bar-actions i { color: var(--line-strong); font-style: normal; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.editor-panel { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--line); background: var(--panel); }
.panel-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 17px; border-bottom: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 14px; }
.panel-index { color: var(--acid); font: 600 11px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.output-panel .panel-index { color: var(--violet); }
.panel-head p { margin: 0 0 5px; color: var(--muted); font: 500 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.11em; }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 500; }
.panel-stat { color: var(--muted); font: 500 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.07em; white-space: nowrap; }

#jsonInput, .code-preview { width: 100%; min-height: 390px; margin: 0; flex: 1; border: 0; border-bottom: 1px solid var(--line); outline: 0; background: var(--field); font: 13px/1.72 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; tab-size: 2; }
#jsonInput { display: block; resize: vertical; padding: 22px; color: var(--text); }
#jsonInput::placeholder { color: var(--muted); }
#jsonInput:focus { box-shadow: inset 3px 0 0 var(--acid); }
#jsonInput[aria-invalid="true"] { box-shadow: inset 3px 0 0 var(--red); }
.code-preview { overflow: auto; padding: 22px; color: var(--muted-strong); white-space: pre; }
.code-preview:focus { box-shadow: inset 3px 0 0 var(--violet); }
.code-preview.is-empty { color: var(--muted); }
.code-preview code { font: inherit; }
.token-key { color: var(--cyan); }
.token-string { color: var(--acid); }
.token-number { color: var(--orange); }
.token-boolean { color: var(--violet); }
.token-null { color: var(--red); font-style: italic; }

.validity { display: flex; align-items: center; gap: 7px; color: var(--muted); font: 500 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; }
.validity i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.validity.is-valid { color: var(--green); }
.validity.is-valid i { box-shadow: 0 0 8px var(--green); }
.validity.is-error { color: var(--red); }

.error-panel { min-height: 98px; display: flex; gap: 13px; padding: 13px 16px; border-bottom: 1px solid color-mix(in srgb, var(--red) 55%, var(--line)); background: color-mix(in srgb, var(--red) 6%, var(--panel)); }
.error-panel[hidden] { display: none; }
.error-mark { width: 25px; height: 25px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--red); border-radius: 50%; color: var(--red); font: 700 11px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.error-panel strong { display: block; color: var(--red); font-size: 11px; font-weight: 600; }
.error-panel p { margin: 4px 0 7px; color: var(--muted-strong); font: 400 9px/1.5 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.error-panel pre { max-width: 520px; margin: 0; overflow: hidden; color: var(--muted); font: 400 9px/1.45 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; white-space: pre; }

.panel-foot { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 10px 10px 18px; }
.panel-foot > span { color: var(--muted); font: 400 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.06em; }
.primary-actions, .output-actions { display: flex; align-items: center; gap: 8px; }
.primary-button { width: 168px; height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border: 0; background: var(--acid); color: #172006; font-size: 9px; font-weight: 700; letter-spacing: 0.1em; }
.primary-button b { font-size: 17px; font-weight: 400; }
.primary-button:hover { filter: brightness(1.07); }
.secondary-button, .output-actions button { height: 44px; padding: 0 14px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 600 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; }
.secondary-button:hover, .output-actions button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
.output-foot { padding-right: 10px; }

.metrics { display: grid; grid-template-columns: 1.25fr 0.8fr 1fr 1.15fr; gap: 16px; margin-top: 16px; }
.metric-card { min-height: 196px; padding: 18px; border: 1px solid var(--line); background: var(--panel); }
.metric-card > p { padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.hero-metric { display: grid; grid-template-columns: 66px 1fr; align-content: start; column-gap: 15px; }
.hero-metric > p { grid-column: 1 / -1; }
.status-orb { width: 66px; height: 66px; display: grid; place-items: center; margin-top: 20px; border: 1px solid var(--line-strong); background: var(--field); color: var(--muted); }
.status-orb span { font: 600 13px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.status-orb.is-valid { border-color: var(--acid); background: var(--acid-soft); color: var(--acid); box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--acid) 5%, transparent); }
.status-orb.is-error { border-color: var(--red); color: var(--red); }
.hero-metric > div:last-child { align-self: center; margin-top: 20px; }
.hero-metric h2, .privacy-card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.hero-metric div:last-child p { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.metric-card dl { margin: 8px 0 0; }
.metric-card dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.metric-card dl > div:last-child { border-bottom: 0; }
.metric-card dt { color: var(--muted); font: 500 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.07em; }
.metric-card dd { margin: 0; color: var(--muted-strong); font: 600 10px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 18px; }
.type-grid span { min-height: 51px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); background: var(--field); }
.type-grid i { color: var(--muted); font: normal 500 7px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; }
.type-grid b { color: var(--muted-strong); font: 600 11px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.pipeline { display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; gap: 7px; padding: 27px 0 20px; }
.pipeline span { color: var(--muted-strong); font: 500 7px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.06em; }
.pipeline i { height: 1px; position: relative; background: var(--line-strong); }
.pipeline i::after { content: ""; width: 4px; height: 4px; position: absolute; top: -2px; right: 0; border-radius: 50%; background: var(--acid); }
.privacy-card h2 { margin-bottom: 7px; }
.privacy-card small { color: var(--muted); font-size: 10px; line-height: 1.5; }

footer { min-height: 100px; display: flex; align-items: center; justify-content: space-between; gap: 24px; color: var(--muted); font: 400 8px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 10; padding: 10px 14px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; background: var(--text); color: var(--bg); font: 600 9px "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.06em; transition: 0.18s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1050px) {
  .control-bar { flex-wrap: wrap; }
  .bar-actions { margin-left: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 780px) {
  .app { width: min(100% - 28px, 1260px); }
  .intro { min-height: 0; display: block; padding: 42px 0 30px; }
  .intro > p { width: 100%; margin-top: 20px; }
  .control-bar { align-items: stretch; gap: 15px; padding: 12px; }
  .indent-control { width: 100%; min-width: 0; flex-direction: column; align-items: flex-start; }
  .segmented { width: 100%; flex: none; }
  .option-toggle { min-height: 30px; }
  .bar-actions { width: 100%; justify-content: flex-end; }
  .workspace { grid-template-columns: 1fr; }
  #jsonInput, .code-preview { min-height: 330px; }
}

@media (max-width: 540px) {
  .local-status { display: none; }
  .intro h1 { font-size: 38px; }
  .panel-head { padding: 0 13px; }
  .panel-stat { display: none; }
  .panel-foot { align-items: stretch; flex-direction: column; padding: 12px; }
  .primary-actions, .output-actions { width: 100%; }
  .primary-actions > button, .output-actions > button { flex: 1; width: auto; }
  .metrics { grid-template-columns: 1fr; }
  footer { min-height: 120px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
