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

:root {
  --bg:          #0d0f14;
  --surface:     #13161d;
  --card:        #181c25;
  --panel:       #1c2030;
  --border:      #252a36;
  --border-hi:   #2f3647;
  --accent:      #00e5a0;
  --accent2:     #0099ff;
  --accent-dim:  #00b07a;
  --danger:      #ff4d6d;
  --warn:        #ffb627;
  --success:     #00e5a0;
  --text:        #e2e8f0;
  --muted:       #64748b;
  --mono:        'JetBrains Mono', monospace;
  --sans:        'Syne', sans-serif;

  /* JSON syntax colours */
  --j-key:       #7dd3fc;
  --j-str:       #86efac;
  --j-num:       #fbbf24;
  --j-bool:      #c084fc;
  --j-null:      #fb923c;
  --j-brace:     #94a3b8;
  --j-comma:     #64748b;
}

html, body { height: 100%; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,229,160,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,160,.025) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,153,255,.05) 0%, transparent 70%);
  bottom: -200px;
  left: -150px;
  pointer-events: none;
  z-index: 0;
}

/* Layout */
.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 1.75rem 1.5rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Header */
.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.header-left .tag {
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .35rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.header-left .tag::before { content: '>'; }
h1 {
  font-family: var(--sans);
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1;
}
h1 span { color: var(--accent); }
.header-meta { font-size: .68rem; color: var(--muted); line-height: 1.6; text-align: right; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.btn {
  font-family: var(--mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .07em;
  padding: .42rem .85rem;
  border-radius: 6px;
  border: 1px solid var(--border-hi);
  cursor: pointer;
  transition: all .14s ease;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #0d0f14; border-color: var(--accent); font-weight: 700; }
.btn-primary:hover { background: #00ffb3; border-color: #00ffb3; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); border-color: var(--border-hi); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255,77,109,.3); }
.btn-danger:hover { background: rgba(255,77,109,.08); }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

/* Indent selector */
.indent-group { display: flex; align-items: center; gap: .4rem; font-size: .68rem; color: var(--muted); }
.indent-group select {
  font-family: var(--mono);
  font-size: .68rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  padding: .3rem .5rem;
  outline: none;
  cursor: pointer;
}
.indent-group select:focus { border-color: var(--accent); }

/* Flash feedback */
.flash { font-size: .68rem; padding: .35rem .7rem; border-radius: 5px; opacity: 0; transition: opacity .2s; margin-left: auto; }
.flash.show { opacity: 1; }
.flash.ok  { color: var(--success); background: rgba(0,229,160,.08); border: 1px solid rgba(0,229,160,.2); }
.flash.err { color: var(--danger);  background: rgba(255,77,109,.08); border: 1px solid rgba(255,77,109,.2); }

/* Main panels */
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; flex: 1; min-height: 0; }

@media (max-width: 780px) {
  .panels { grid-template-columns: 1fr; }
  .header-meta { display: none; }
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 480px;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.panel-title { font-size: .65rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); flex: 1; }
.panel-badge { font-size: .6rem; padding: .15rem .45rem; border-radius: 4px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.badge-valid   { background: rgba(0,229,160,.12); color: var(--accent); border: 1px solid rgba(0,229,160,.25); }
.badge-invalid { background: rgba(255,77,109,.12); color: var(--danger); border: 1px solid rgba(255,77,109,.25); }
.badge-idle    { background: rgba(100,116,139,.1);  color: var(--muted);  border: 1px solid var(--border); }
.panel-action {
  font-size: .65rem; color: var(--muted); cursor: pointer;
  padding: .2rem .4rem; border-radius: 4px;
  border: 1px solid transparent; transition: all .12s;
  background: none; font-family: var(--mono);
  display: flex; align-items: center; gap: .3rem;
}
.panel-action:hover { color: var(--text); border-color: var(--border-hi); background: var(--card); }

/* Input textarea */
textarea#jsonInput {
  flex: 1;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.7;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  padding: 1rem;
  tab-size: 2;
  caret-color: var(--accent);
}
textarea#jsonInput::placeholder { color: var(--muted); opacity: .6; }
textarea#jsonInput:focus { background: rgba(0,229,160,.015); }

/* Output */
#jsonOutput { flex: 1; overflow: auto; padding: 1rem; font-size: .8rem; line-height: 1.7; white-space: pre; font-family: var(--mono); }

/* Output placeholder */
.output-placeholder { color: var(--muted); font-size: .75rem; font-style: italic; }

/* Syntax highlighting */
.j-key   { color: var(--j-key); }
.j-str   { color: var(--j-str); }
.j-num   { color: var(--j-num); }
.j-bool  { color: var(--j-bool); }
.j-null  { color: var(--j-null); }
.j-brace { color: var(--j-brace); }
.j-comma { color: var(--j-comma); }

/* Error display */
.error-bar {
  padding: .6rem 1rem; font-size: .72rem; color: var(--danger);
  background: rgba(255,77,109,.06);
  border-top: 1px solid rgba(255,77,109,.15);
  display: flex; align-items: flex-start; gap: .5rem; line-height: 1.5;
}
.error-bar svg { flex-shrink: 0; margin-top: .1rem; }

/* Stats bar */
.stats-bar {
  display: flex; gap: 1.5rem;
  padding: .7rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
  margin-top: .5rem;
  border-radius: 10px;
  align-items: center;
}
.stat { display: flex; align-items: center; gap: .4rem; font-size: .65rem; }
.stat-label { color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.stat-val   { color: var(--accent); font-weight: 600; }

/* Footer */
.footer-note { font-size: .63rem; color: var(--muted); text-align: center; margin-top: .9rem; letter-spacing: .04em; }
.footer-note a { color: var(--accent-dim); text-decoration: none; }
.footer-note a:hover { color: var(--accent); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page { animation: fadeUp .35s ease both; }


/* ── Site Nav ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(13,15,20,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-nav-inner {
  display: flex;
  align-items: center;
  height: 56px;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  width: 100%;
}
.nav-logo {
  font-family: var(--mono);
  font-size: .85rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -.01em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .15rem;
}
.nav-logo .brace { color: var(--muted); font-weight: 400; }
.nav-links { display: flex; align-items: center; gap: 1.5rem; flex: 1; }
.nav-links a {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: .03em;
  transition: color .14s;
}
.nav-links a:hover { color: var(--text); }
.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--accent);
  padding: 0;
  letter-spacing: .03em;
  transition: color .14s;
}
.nav-dropdown-toggle:hover { color: #00ffb3; }
.nav-dropdown-toggle svg { transition: transform .2s ease; }
.nav-dropdown.open .nav-dropdown-toggle svg { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 1rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 210px;
  background: #181c25;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: .4rem;
  display: none;
  flex-direction: column;
  gap: .15rem;
  box-shadow: 0 12px 32px rgba(0,0,0,.6);
  z-index: 999;
}
.nav-dropdown.open .nav-dropdown-menu { display: flex; animation: dropIn .15s ease both; }
.nav-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  border-radius: 7px;
  font-size: .75rem;
  color: #94a3b8;
  text-decoration: none;
  transition: background .12s, color .12s;
  white-space: nowrap;
  letter-spacing: .02em;
}
.nav-dropdown-menu a:hover { background: rgba(0,229,160,.07); color: var(--accent); }
.nav-dropdown-menu a.active { background: rgba(0,229,160,.1); color: var(--accent); }
.nav-dropdown-menu a svg { opacity: .55; flex-shrink: 0; }
.nav-dropdown-menu a:hover svg,
.nav-dropdown-menu a.active svg { opacity: 1; }
@keyframes dropIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.nav-cv {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 700;
  padding: .35rem .85rem;
  border-radius: 6px;
  background: var(--accent);
  color: #0d0f14;
  text-decoration: none;
  letter-spacing: .05em;
  transition: background .14s;
  white-space: nowrap;
  margin-left: auto;
}
.nav-cv:hover { background: #00ffb3; }
@media (max-width: 640px) {
  .nav-links a:not(.nav-dropdown-toggle) { display: none; }
}
