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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --border: #0f3460;
  --text: #e0e0e0;
  --muted: #909090;
  --accent: #e94560;

  --json-key: #79b8ff;
  --json-string: #9ecbff;
  --json-number: #f8c555;
  --json-bool: #f97583;
  --json-null: #b392f0;
}

body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-weight: 600;
  letter-spacing: .05em;
  font-size: .85rem;
  color: #ff7091;
  text-transform: uppercase;
  white-space: nowrap;
}

#input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
  font-size: .88rem;
  outline: none;
}

#input::placeholder { color: var(--muted); }
#input:focus { border-color: var(--accent); }

main {
  flex: 1;
  min-height: 0;
}

#right {
  position: relative;
  display: flex;
  height: 100%;
  min-width: 0;
}

#output {
  flex: 1;
  padding: 16px;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
  font-size: .82rem;
  line-height: 1.6;
  overflow: auto;
  background: var(--bg);
  white-space: pre-wrap;
}

#buttons {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

#wrap, #copy {
  padding: 10px 23px;
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity .15s, transform .15s;
}

#wrap {
  background: var(--border);
  box-shadow: 0 4px 16px rgba(15, 52, 96, .5);
}
#wrap.active { background: #1a6b9a; box-shadow: 0 4px 16px rgba(26, 107, 154, .5); }
#wrap:hover { transform: scale(1.02); }
#wrap:active { transform: scale(0.98); }

#copy {
  background: var(--accent);
  box-shadow: 0 4px 16px rgba(233, 69, 96, .4);
}
#copy:hover { transform: scale(1.02); }
#copy:active { transform: scale(0.98); }
#copy.copied { background: #2ea043; box-shadow: 0 4px 16px rgba(46, 160, 67, .4); }

footer {
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .75rem;
}

footer a {
  color: var(--muted);
  text-decoration: none;
}

footer a:hover { color: var(--text); }

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

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

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

.json-key    { color: var(--json-key); }
.json-string { color: var(--json-string); }
.json-number { color: var(--json-number); }
.json-bool   { color: var(--json-bool); }
.json-null   { color: var(--json-null); }
.json-punct  { color: var(--muted); }

@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 14px;
  }

  /* Prevent iOS auto-zoom on focus */
  #input { font-size: 1rem; }

  main { min-height: 0; }

  #output { font-size: .8rem; padding: 12px; }

  #buttons { bottom: 14px; gap: 8px; }

  #wrap, #copy {
    padding: 12px 20px;
    font-size: .85rem;
  }
}
