:root {
  --primary: #3B82F6;
  --primary-dim: rgba(59,130,246,0.12);
  --primary-glow: rgba(59,130,246,0.25);
  --secondary: #60A5FA;
  --accent: #818CF8;
  --bg: #0A1628;
  --bg-card: rgba(10,22,40,0.85);
  --bg-input: rgba(6,14,28,0.9);
  --border: rgba(59,130,246,0.12);
  --border-hover: rgba(59,130,246,0.25);
  --text: #E2E8F0;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --transition: 250ms ease;
  --glass: rgba(10,22,40,0.65);
  --glass-border: rgba(59,130,246,0.08);
  --type-string: #10B981;
  --type-number: #F59E0B;
  --type-boolean: #EF4444;
  --type-union: #8B5CF6;
  --type-generic: #F472B6;
  --type-object: var(--primary);
  --type-array: #06B6D4;
  --type-cond: #EC4899;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  min-height: 100vh; line-height: 1.6;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(59,130,246,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(129,140,248,0.04) 0%, transparent 50%);
}
.app { max-width: 1400px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; min-height: 100vh; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.header { padding: 16px 0; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); }
.header h1 { font-size: 1.2rem; font-weight: 700; background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: var(--radius-sm); border: none; font-family: var(--font); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2563EB; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--primary-dim); }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

.select-sm { padding: 6px 28px 6px 10px; background: var(--bg-input); color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.78rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M3 5l3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; cursor: pointer; outline: none; }
.select-sm:hover { border-color: var(--primary); }

.main { flex: 1; display: grid; grid-template-columns: 380px 1fr; gap: 16px; padding: 16px 0; align-items: start; }

.panel { background: var(--glass); backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; animation: fadeIn 0.3s ease; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 0.88rem; font-weight: 600; }
.panel-body { padding: 16px; flex: 1; }

.code-editor { width: 100%; min-height: 200px; max-height: 400px; resize: vertical; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-family: var(--mono); font-size: 0.82rem; color: var(--text); line-height: 1.7; outline: none; margin-bottom: 12px; transition: border-color var(--transition); white-space: pre; tab-size: 2; }
.code-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); }
.code-editor::placeholder { color: var(--text-muted); }

.viz-panel { position: relative; }
.viz-body { overflow: auto; max-height: calc(100vh - 200px); }
.viz-controls { display: flex; gap: 6px; }

/* Tree */
.tree-container { font-family: var(--mono); font-size: 0.82rem; }
.tree-node { margin-left: 16px; border-left: 2px solid var(--border); padding-left: 12px; margin-bottom: 2px; }
.tree-node-root { margin-left: 0; border-left: none; padding-left: 0; }
.tree-label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: all 150ms ease; user-select: none; }
.tree-label:hover { background: var(--primary-dim); }
.tree-toggle { width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; color: var(--text-muted); transition: transform 200ms ease; }
.tree-toggle.collapsed { transform: rotate(-90deg); }
.tree-key { color: var(--secondary); font-weight: 600; }
.tree-sep { color: var(--text-muted); }
.tree-type { padding: 2px 6px; border-radius: 4px; font-size: 0.72rem; font-weight: 600; }
.tree-type.t-string { background: rgba(16,185,129,0.15); color: var(--type-string); }
.tree-type.t-number { background: rgba(245,158,11,0.15); color: var(--type-number); }
.tree-type.t-boolean { background: rgba(239,68,68,0.15); color: var(--type-boolean); }
.tree-type.t-union { background: rgba(139,92,246,0.15); color: var(--type-union); }
.tree-type.t-generic { background: rgba(244,114,182,0.15); color: var(--type-generic); }
.tree-type.t-object { background: var(--primary-dim); color: var(--primary); }
.tree-type.t-array { background: rgba(6,182,212,0.15); color: var(--type-array); }
.tree-type.t-cond { background: rgba(236,72,153,0.15); color: var(--type-cond); }
.tree-type.t-unknown { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.tree-opt { color: var(--text-muted); font-size: 0.72rem; }
.tree-children { overflow: hidden; transition: max-height 200ms ease; }
.empty-state { color: var(--text-muted); font-size: 0.82rem; text-align: center; padding: 40px 20px; }

/* Tooltip */
.tooltip { position: fixed; padding: 10px 14px; background: #1E293B; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.78rem; color: var(--text); box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 100; max-width: 320px; pointer-events: none; }
.tooltip .tt-title { font-weight: 600; color: var(--secondary); margin-bottom: 4px; }
.tooltip .tt-detail { color: var(--text-dim); }
.hidden { display: none !important; }

.footer { padding: 16px 0; text-align: center; font-size: 0.72rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: auto; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
@media (max-width: 800px) { .main { grid-template-columns: 1fr; } }
