/* jsonviewer.esbl.digital — deep-ink workbench, amber signature, Plex family */

:root {
  --bg: #101318;
  --panel: #161a21;
  --panel-raised: #1c212b;
  --border: #262c38;
  --text: #e9e6dd;
  --text-dim: #8b91a0;
  --accent: #e6b450;
  --accent-dim: #8a6d31;
  --key: #9fb6d9;
  --string: #64b598;
  --number: #d99a62;
  --boolean: #b48ad6;
  --null: #6d7484;
  --match: #e6b45033;
  --error: #d97066;
  --guide: #232936;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f3f1ec;
  --panel: #fbfaf7;
  --panel-raised: #efece5;
  --border: #ddd8cd;
  --text: #23272e;
  --text-dim: #7a7f8a;
  --accent: #a3690f;
  --accent-dim: #caa25c;
  --key: #3c5f8f;
  --string: #257a5b;
  --number: #a05f1f;
  --boolean: #7b4fa6;
  --null: #8d93a0;
  --match: #a3690f26;
  --error: #b3392e;
  --guide: #e4e0d6;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 48px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
}

.wordmark .brace { color: var(--accent); font-weight: 400; }
.wordmark .wm-name { padding: 0 2px; }
.wordmark .wm-domain {
  margin-left: 10px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
}

.topbar-actions { display: flex; gap: 6px; }

/* ---------- buttons & inputs ---------- */

.btn {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.btn:hover { border-color: var(--accent-dim); }
.btn:active { background: var(--border); }
.btn:focus-visible, #search:focus-visible, textarea:focus-visible, .tree:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.btn.ghost { background: transparent; }
.btn.icon { font-size: 15px; line-height: 1; padding: 4px 8px; }

#search {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  width: 190px;
}

#search::placeholder { color: var(--text-dim); }

/* ---------- workbench layout ---------- */

.workbench {
  flex: 1;
  display: flex;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
}

.pane-input { flex: 0 0 38%; }
.pane-tree { flex: 1; }

.pane-divider {
  flex: none;
  width: 1px;
  background: var(--border);
}

.pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex: none;
  flex-wrap: wrap;
}

.pane-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  user-select: none;
}

.toolbar-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- input pane ---------- */

textarea {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  padding: 14px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

textarea::placeholder { color: var(--text-dim); }

/* ---------- tree pane ---------- */

.tree {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 40px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}

.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  text-align: center;
  gap: 4px;
  padding: 24px;
}

.empty-glyph {
  font-size: 42px;
  color: var(--accent-dim);
  margin-bottom: 8px;
  user-select: none;
}

.empty-state p { margin: 0; }
.empty-sub { font-size: 12px; opacity: 0.75; }

/* nodes */

.node { position: relative; }

.node-row {
  display: flex;
  align-items: baseline;
  gap: 1px;
  border-radius: 4px;
  padding: 0 4px;
  cursor: default;
  white-space: nowrap;
}

.node-row:hover { background: var(--panel-raised); }
.node-row.selected { background: var(--match); }

.toggle {
  flex: none;
  width: 16px;
  margin-left: -18px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 10px;
  cursor: pointer;
  align-self: center;
  transition: transform 120ms;
}

.node.open > .node-row .toggle { transform: rotate(90deg); }
.toggle:hover { color: var(--accent); }

.key { color: var(--key); }
.key .q { opacity: 0.45; }
.idx { color: var(--text-dim); }
.colon { color: var(--text-dim); margin-right: 6px; }

.v-string { color: var(--string); }
.v-string .q { opacity: 0.45; }
.v-number { color: var(--number); }
.v-boolean { color: var(--boolean); }
.v-null { color: var(--null); font-style: italic; }

.preview { color: var(--text-dim); }
.count {
  color: var(--text-dim);
  font-size: 11px;
  margin-left: 8px;
  opacity: 0.8;
}

.children {
  margin-left: 7px;
  padding-left: 17px;
  border-left: 1px solid var(--guide);
  display: none;
}

.node.open > .children { display: block; }

.hl {
  background: var(--match);
  border-radius: 2px;
  outline: 1px solid var(--accent-dim);
}

.more-btn {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  background: none;
  border: 1px dashed var(--accent-dim);
  border-radius: 4px;
  padding: 1px 8px;
  margin: 2px 0 2px 4px;
  cursor: pointer;
}

.tree-notice {
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 4px;
}

/* error display */

.parse-error {
  margin: 8px 4px;
  padding: 12px 14px;
  border: 1px solid var(--error);
  border-radius: 6px;
  color: var(--error);
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.parse-error .err-title {
  font-family: var(--sans);
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

/* ---------- status bar ---------- */

.statusbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 30px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  min-width: 0;
}

.status-chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  user-select: none;
}

.status-chip.ok { color: var(--string); border-color: var(--string); }
.status-chip.err { color: var(--error); border-color: var(--error); }

.status-stats { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-spacer { flex: 1; }

.status-path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 55%;
  direction: rtl;
  text-align: left;
}

.status-path:empty { display: none; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translate(-50%, 8px);
  background: var(--panel-raised);
  border: 1px solid var(--accent-dim);
  color: var(--text);
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms, transform 160ms;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .workbench { flex-direction: column; }
  .pane-input { flex: 0 0 34%; }
  .pane-divider { width: auto; height: 1px; }
  #search { width: 130px; }
  .status-stats { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
