*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #ffffff; color: #1e293b;
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}

header {
  flex-shrink: 0; padding: 0 24px; height: 52px;
  border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; gap: 12px;
}
header h1 { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }

.badge {
  background: #1d4ed8; color: #bfdbfe;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  letter-spacing: 0.6px; text-transform: uppercase;
}

.toolbar {
  flex-shrink: 0; padding: 8px 24px;
  display: flex; gap: 8px; border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap; align-items: center;
}

button {
  padding: 6px 14px; border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: opacity 0.15s; white-space: nowrap;
}
button:hover { opacity: 0.8; }
.btn-primary   { background: #2563eb; color: #fff; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-ghost     { background: transparent; color: #64748b; border: 1px solid #e2e8f0; }

.progress-wrap { flex-shrink: 0; height: 3px; background: #e2e8f0; overflow: hidden; }
.progress-bar  { height: 100%; background: #2563eb; width: 0%; transition: width 0.2s ease; }
.progress-bar.indeterminate { width: 40%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

.panels { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }

.panel {
  display: flex; flex-direction: column;
  min-height: 0; border-right: 1px solid #e2e8f0;
  overflow: hidden; position: relative;
}
.panel:last-child { border-right: none; }

.panel-header {
  flex-shrink: 0; height: 40px; padding: 0 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.8px;
  text-transform: uppercase; color: #94a3b8;
  border-bottom: 1px solid #e2e8f0;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.panel-header > span { flex-shrink: 0; }

.copy-btn {
  font-size: 11px; padding: 3px 10px; border-radius: 4px;
  background: #f1f5f9; color: #64748b; border: none; cursor: pointer;
}
.copy-btn:hover { color: #1e293b; }

.view-toggle { display: flex; gap: 2px; }
.view-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: #f1f5f9; color: #94a3b8;
  border: 1px solid #e2e8f0; cursor: pointer; font-weight: 500; transition: none;
}
.view-btn:hover { opacity: 1; color: #1e293b; }
.view-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }

textarea {
  flex: 1; min-height: 0; resize: none;
  background: #ffffff; color: #1e293b; border: none;
  padding: 16px;
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.65; outline: none; overflow: auto;
}
textarea::placeholder { color: #cbd5e1; }
textarea[readonly] { background: #f8fafc; cursor: default; }

textarea::-webkit-scrollbar,
.error::-webkit-scrollbar,
.tree-view::-webkit-scrollbar { width: 8px; height: 8px; }
textarea::-webkit-scrollbar-track,
.error::-webkit-scrollbar-track,
.tree-view::-webkit-scrollbar-track { background: transparent; }
textarea::-webkit-scrollbar-thumb,
.error::-webkit-scrollbar-thumb,
.tree-view::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
textarea::-webkit-scrollbar-thumb:hover,
.error::-webkit-scrollbar-thumb:hover,
.tree-view::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Tree view */
.tree-view {
  flex: 1; min-height: 0; overflow: auto;
  padding: 16px; background: #f8fafc;
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.8;
}
.tree-row     { display: block; padding-left: 20px; }
.tree-toggle  { cursor: pointer; user-select: none; color: #94a3b8; font-size: 9px; margin-right: 4px; display: inline-block; width: 10px; }
.tree-toggle:hover { color: #2563eb; }
.tree-key     { color: #7c3aed; }
.tree-string  { color: #16a34a; }
.tree-number  { color: #2563eb; }
.tree-bool    { color: #d97706; }
.tree-null    { color: #94a3b8; font-style: italic; }
.tree-bracket { color: #64748b; }
.tree-summary { color: #94a3b8; font-size: 11px; cursor: pointer; }
.tree-summary:hover { color: #2563eb; }
.tree-children { border-left: 1px solid #e2e8f0; margin-left: 4px; }

/* Search bar */
.search-bar {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
}
.search-bar input {
  flex: 1; min-width: 0; padding: 3px 8px;
  border: 1px solid #e2e8f0; border-radius: 4px;
  font-size: 12px; outline: none; font-family: inherit;
  background: #fff; color: #1e293b;
}
.search-bar input:focus { border-color: #2563eb; }
.match-count { font-size: 11px; color: #94a3b8; white-space: nowrap; min-width: 60px; text-align: right; }
.match-no-result { color: #dc2626 !important; }
.search-nav-btn {
  padding: 2px 7px; border: 1px solid #e2e8f0; border-radius: 4px;
  background: #f1f5f9; color: #64748b; cursor: pointer; font-size: 11px; line-height: 1.4;
  display: none;
}
.search-bar.has-query .search-nav-btn { display: inline-block; }
.search-nav-btn:hover { background: #e2e8f0; opacity: 1; }
.search-clear-btn { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; }
.search-clear-btn:hover { color: #64748b; opacity: 1; }
mark { background: #fef08a; border-radius: 2px; padding: 0 1px; font-style: normal; }
mark.mark-active { background: #fb923c; color: #fff; }

/* File banner */
.file-banner {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: #64748b; font-size: 13px; background: #f8fafc;
}
.file-banner .file-icon { font-size: 32px; }
.file-banner .file-name { font-weight: 600; color: #1e293b; }
.file-banner .file-size { color: #94a3b8; font-size: 12px; }
.file-banner .file-clear { margin-top: 8px; font-size: 12px; color: #94a3b8; cursor: pointer; text-decoration: underline; }
.file-banner .file-clear:hover { color: #dc2626; }

.drop-overlay {
  position: absolute; inset: 0;
  background: rgba(37,99,235,0.07); border: 2px dashed #2563eb;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #2563eb;
  pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 10;
}
.panel.drag-over .drop-overlay { opacity: 1; }

.error { flex: 1; min-height: 0; color: #dc2626; padding: 16px; background: #fef2f2; font-family: monospace; font-size: 13px; overflow: auto; }
.hidden { display: none !important; }

.status-bar {
  flex-shrink: 0; height: 28px; padding: 0 24px;
  border-top: 1px solid #e2e8f0; display: flex; align-items: center;
  font-size: 11px; color: #94a3b8;
}
.status-ok  { color: #16a34a; }
.status-err { color: #dc2626; }

/* Footer */
.site-footer { flex-shrink: 0; background: #f8fafc; border-top: 1px solid #e2e8f0; padding: 24px; }
.footer-grid { max-width: 960px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; }
.footer-col h4 { font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: #94a3b8; margin-bottom: 10px; }
.footer-col p, .footer-col li { font-size: 12px; line-height: 1.7; color: #64748b; }
.footer-col ul { padding-left: 16px; }
.footer-bottom { max-width: 960px; margin: 16px auto 0; padding-top: 12px; border-top: 1px solid #e2e8f0; font-size: 11px; color: #94a3b8; }

@media (max-width: 1024px) {
  header, .toolbar, .status-bar { padding-left: 16px; padding-right: 16px; }
  textarea, .error { font-size: 12px; padding: 12px; }
}
@media (max-width: 768px) {
  body { overflow: auto; height: auto; min-height: 100vh; }
  .panels { grid-template-columns: 1fr; flex: none; }
  .panel { border-right: none; border-bottom: 1px solid #e2e8f0; height: 45vh; }
  .panel:last-child { border-bottom: none; }
  textarea, .error { font-size: 12px; padding: 12px; }
  button { font-size: 12px; padding: 6px 12px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  header h1 { font-size: 14px; }
  .toolbar { gap: 6px; }
  button { font-size: 11px; padding: 5px 10px; }
  .footer-grid { grid-template-columns: 1fr; gap: 16px; }
  .site-footer { padding: 16px; }
}
