:root {
  color-scheme: light;
  --bg: oldlace;
  --text: #2c2416;
  --muted: #7a6e5a;
  --faint: #9a8d78;
  --line: #d4c8b0;
  --line-soft: #e6dcc8;
  --quote: #5c5346;
  --error: #8a3b2b;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1814;
  --text: #efe6d4;
  --muted: #a89a82;
  --faint: #8a7d68;
  --line: #4a4034;
  --line-soft: #342c24;
  --quote: #c4b8a4;
  --error: #e8a090;
}

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

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

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  font: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 0.35rem 0.15rem;
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--text);
}

.page {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.5rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  min-height: 100vh;
}

.input-pane,
.output-pane {
  min-width: 0;
  width: 100%;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

#json-input,
#js-expression {
  display: block;
  width: 100%;
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0.4rem 0 0.6rem;
  outline: none;
}

#json-input:focus,
#js-expression:focus {
  border-bottom-color: var(--text);
}

#json-input {
  min-height: 18rem;
  resize: vertical;
  margin-bottom: 1.75rem;
  line-height: 1.55;
}

.error {
  margin: 0 0 1rem;
  color: var(--error);
  font-size: 0.95rem;
}

.output {
  font-size: 1.05rem;
}

.output:empty::before {
  content: "Paste JSON to see it as text.";
  color: var(--faint);
}

.item + .item {
  margin-top: 1.75rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line-soft);
}

.field + .field {
  margin-top: 0.85rem;
}

.field-key {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.field-value {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nested {
  margin: 0.35rem 0 0 0.9rem;
  padding-left: 0.85rem;
  border-left: 1px solid var(--line-soft);
}

.md {
  overflow-wrap: anywhere;
}

.md p,
.md ul,
.md ol,
.md blockquote,
.md pre,
.md table {
  margin: 0 0 0.85rem;
}

.md p:last-child,
.md ul:last-child,
.md ol:last-child,
.md blockquote:last-child,
.md pre:last-child,
.md table:last-child {
  margin-bottom: 0;
}

.md h1,
.md h2,
.md h3,
.md h4 {
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.35;
  margin: 1.1rem 0 0.45rem;
}

.md h1:first-child,
.md h2:first-child,
.md h3:first-child,
.md h4:first-child {
  margin-top: 0;
}

.md ul,
.md ol {
  padding-left: 1.2rem;
}

.md blockquote {
  padding-left: 0.85rem;
  border-left: 2px solid var(--line);
  color: var(--quote);
}

.md code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9em;
}

.md pre {
  white-space: pre-wrap;
}

.md a {
  color: inherit;
}

.md table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.95rem;
}

.md th,
.md td {
  text-align: left;
  vertical-align: top;
  padding: 0.3rem 0.6rem 0.3rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.md hr {
  border: none;
  border-top: 1px solid var(--line-soft);
  margin: 1.1rem 0;
}

@media (max-width: 720px) {
  .page {
    gap: 2rem;
    padding: 1.5rem 1.15rem 3rem;
  }

  #json-input {
    min-height: 12rem;
  }
}
