@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;700&family=Syne:wght@400;600;800&display=swap');

:root {
  --bg: #0d0f14;
  --surface: #13161e;
  --surface2: #1a1e28;
  --border: #252a38;
  --accent: #4fffb0;
  --accent2: #7b8fff;
  --accent3: #ff7b7b;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --string: #4fffb0;
  --number: #7b8fff;
  --bool: #ff9f4a;
  --null: #ff7b7b;
  --key: #c4b5fd;
  --bracket: #94a3b8;
  --error: #ff7b7b;
  --success: #4fffb0;
  --tab-active: #4fffb0;
  --tree-line: #2a3040;
}

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

body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 16px;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.logo-bracket { color: var(--accent); }
.logo-text { color: var(--text); margin: 0; padding: 0; font-size: inherit; font-weight: inherit; }

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--accent); }

.btn-accent {
  background: var(--accent);
  color: #0d0f14;
  border-color: var(--accent);
}
.btn-accent:hover { background: #39e89a; }

.btn-danger {
  background: transparent;
  color: var(--accent3);
  border-color: var(--accent3);
}
.btn-danger:hover { background: rgba(255,123,123,0.1); }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.tab {
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Main layout */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-width: 0;
}

.pane + .pane {
  border-left: 1px solid var(--border);
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 38px;
  flex-wrap: wrap;
  gap: 6px;
}

.pane-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.pane-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

textarea {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: none;
  outline: none;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: none;
  width: 100%;
}

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

.viewer-pane {
  flex: 1;
  overflow: auto;
  background: var(--bg);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.7;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.status-item {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.ok { background: var(--success); }
.status-dot.err { background: var(--error); }

.status-msg {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--error);
}
.status-msg.ok { color: var(--success); }

/* JSON Tree */
.json-root { padding: 4px 0; }

.json-entry {
  display: flex;
  align-items: baseline;
  gap: 3px;
  line-height: 1.65;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: default;
  white-space: nowrap;
}
.json-entry:hover { background: rgba(255,255,255,0.04); }

/* Tree guide lines — children container */
.json-children {
  padding-left: 20px;
  margin-left: 8px;
  border-left: 1px solid var(--tree-line);
}

/* Horizontal connector for each item inside a children container */
.json-children > .json-entry,
.json-children > .json-close {
  position: relative;
}
.json-children > .json-entry::before,
.json-children > .json-close::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 1px;
  background: var(--tree-line);
}

/* +/− toggle box */
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface2);
  margin-right: 4px;
  transition: color 0.12s, border-color 0.12s;
}
.tree-toggle:hover { color: var(--accent); border-color: var(--accent2); }

/* Invisible spacer for leaf rows (aligns with toggle width + margin) */
.tree-spacer {
  display: inline-block;
  width: 18px;
  flex-shrink: 0;
}

.json-key { color: var(--key); }
.json-colon { color: var(--bracket); margin: 0 1px 0 0; }
.json-string { color: var(--string); word-break: break-all; white-space: normal; }
.json-number { color: var(--number); }
.json-bool { color: var(--bool); }
.json-null { color: var(--null); }
.json-bracket { color: var(--bracket); }
.json-comma { color: var(--bracket); }
.json-index { color: var(--text-muted); font-size: 11px; }
.json-summary { color: var(--text-muted); font-style: italic; font-size: 12px; margin-left: 3px; }

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus { border-color: var(--accent2); }
.search-match-count { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }

.highlight { background: rgba(123, 143, 255, 0.25); border-radius: 2px; }
.highlight-active { background: rgba(79, 255, 176, 0.3); }

/* Path display */
.path-bar {
  padding: 6px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent2);
  min-height: 30px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted);
}

.empty-icon { font-size: 40px; opacity: 0.3; }
.empty-text { font-size: 13px; font-family: 'JetBrains Mono', monospace; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

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

/* File input hidden */
#fileInput { display: none; }

/* Resizer */
.resizer {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}
.resizer:hover { background: var(--accent2); }

/* View tab content */
.tab-content { display: none; flex: 1; overflow: hidden; flex-direction: column; }
.tab-content.active { display: flex; }

select {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}

@media (max-width: 700px) {
  .main { flex-direction: column; }
  .pane + .pane { border-left: none; border-top: 1px solid var(--border); }
  .resizer { display: none; }
  header { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px; }
}
