:root {
  color-scheme: light;
  --bg: 48 30% 96%;
  --fg: 30 8% 10%;
  --card: 45 25% 93%;
  --muted: 45 22% 90%;
  --muted-fg: 40 6% 39%;
  --accent: 217 84% 46%;
  --accent-fg: 0 0% 98%;
  --destructive: 4 70% 47%;
  --ok: 145 55% 32%;
  --border: 45 18% 85%;
  --str: 145 45% 30%;
  --num: 25 80% 40%;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --display: "Space Grotesk", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: 30 8% 8%;
    --fg: 45 25% 90%;
    --card: 30 7% 11%;
    --muted: 30 6% 15%;
    --muted-fg: 40 6% 60%;
    --accent: 217 90% 62%;
    --accent-fg: 30 8% 8%;
    --destructive: 4 75% 58%;
    --ok: 145 50% 55%;
    --border: 30 6% 20%;
    --str: 145 40% 62%;
    --num: 30 85% 62%;
  }
}
*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; height: 100%; }
body {
  background: hsl(var(--bg));
  color: hsl(var(--fg));
  font: 13px/1.5 var(--mono);
  display: flex;
  flex-direction: column;
}
a { color: hsl(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.top { display: flex; align-items: baseline; gap: 16px; padding: 14px 24px; border-bottom: 1px solid hsl(var(--border)); flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 700; font-size: 18px; color: hsl(var(--fg)); }
.brand:hover { text-decoration: none; }
.mark { color: hsl(var(--accent)); font-weight: 400; }
.tag { color: hsl(var(--muted-fg)); }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px 24px; width: 100%; max-width: 1600px; margin: 0 auto; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border: 1px solid hsl(var(--border)); background: hsl(var(--card)); }
.bar { display: flex; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid hsl(var(--border)); flex-wrap: wrap; }
.bar.sub { padding: 6px 8px; }
.grow { flex: 1; }

.btn {
  font: inherit; color: hsl(var(--fg)); background: hsl(var(--bg));
  border: 1px solid hsl(var(--border)); padding: 4px 10px; cursor: pointer;
  transition: border-color .12s, background-color .12s, color .12s; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover:not(:disabled) { border-color: hsl(var(--accent)); color: hsl(var(--accent)); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .code:focus-visible, summary:focus-visible, .k:focus-visible {
  outline: 1px solid hsl(var(--accent)); outline-offset: 1px;
}
.btn.ghost { background: transparent; }
.btn.tiny { padding: 0 8px; font-size: 12px; }
.sel, .root input {
  font: inherit; color: hsl(var(--fg)); background: hsl(var(--bg)); border: 1px solid hsl(var(--border)); padding: 4px 6px;
}
.root { color: hsl(var(--muted-fg)); display: inline-flex; align-items: center; gap: 8px; }
.root input { width: 160px; color: hsl(var(--fg)); }

.tabs { display: flex; gap: 0; flex-wrap: wrap; }
.tab { font: inherit; background: transparent; color: hsl(var(--muted-fg)); border: 1px solid transparent; padding: 4px 10px; cursor: pointer; }
.tab:hover { color: hsl(var(--fg)); }
.tab[aria-selected="true"] { color: hsl(var(--accent)); border-color: hsl(var(--accent)); background: hsl(var(--bg)); }
.tab:focus-visible { outline: 1px solid hsl(var(--accent)); }

textarea#src {
  flex: 1; min-height: 300px; resize: none; border: 0; background: hsl(var(--bg)); color: hsl(var(--fg));
  font: 12.5px/1.55 var(--mono); padding: 12px; tab-size: 2; white-space: pre; overflow: auto;
}
.status { padding: 6px 10px; border-top: 1px solid hsl(var(--border)); color: hsl(var(--muted-fg)); min-height: 32px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.ok::before { content: "● "; color: hsl(var(--ok)); }
.status.err { color: hsl(var(--destructive)); cursor: pointer; }
.status.err::before { content: "● "; }

.code { flex: 1; margin: 0; padding: 12px; overflow: auto; background: hsl(var(--bg)); font: 12.5px/1.55 var(--mono); tab-size: 4; min-height: 300px; }
.treewrap { flex: 1; display: flex; flex-direction: column; min-height: 0; background: hsl(var(--bg)); }
.pathbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid hsl(var(--border)); color: hsl(var(--muted-fg)); }
.pathbar span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: hsl(var(--accent)); }
.tree { flex: 1; overflow: auto; padding: 10px 12px; font-size: 12.5px; min-height: 260px; }
.tree details { padding-left: 14px; }
.tree > details { padding-left: 0; }
.tree summary { cursor: pointer; list-style: none; margin-left: -14px; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; display: inline-block; width: 14px; color: hsl(var(--muted-fg)); }
.tree details[open] > summary::before { content: "▾"; }
.tree .leaf { padding-left: 14px; }
.tree .row:hover, .tree summary:hover { background: hsl(var(--muted)); }
.k { color: hsl(var(--fg)); cursor: copy; }
.k:hover { color: hsl(var(--accent)); }
.s { color: hsl(var(--str)); word-break: break-all; }
.n { color: hsl(var(--num)); }
.b, .z { color: hsl(var(--accent)); }
.meta { color: hsl(var(--muted-fg)); }

.foot { display: flex; justify-content: space-between; gap: 16px; padding: 10px 24px; border-top: 1px solid hsl(var(--border)); color: hsl(var(--muted-fg)); font-size: 12px; flex-wrap: wrap; }

.dropzone { position: fixed; inset: 0; display: grid; place-items: center; background: hsl(var(--bg) / .85); border: 2px dashed hsl(var(--accent)); font-family: var(--display); font-size: 28px; font-weight: 700; color: hsl(var(--accent)); z-index: 10; pointer-events: none; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: hsl(var(--fg)); color: hsl(var(--bg)); padding: 6px 14px; z-index: 11; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 12px; }
  textarea#src { min-height: 240px; }
  .top, .foot { padding-left: 12px; padding-right: 12px; }
}
