:root {
  --bg: #f7f6f3; --panel: #ffffff; --ink: #1d1d1b; --muted: #6b6a66; --line: #d9d6cf;
  --queued: #9a978f; --running: #2f6fdb; --split: #7a5cc8; --waiting_input: #d98a00; --done: #2e8b57; --failed: #c8382e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151514; --panel: #1f1f1d; --ink: #ecebe7; --muted: #a3a19b; --line: #383733;
    --queued: #8b8881; --running: #5b93f0; --split: #a08ae6; --waiting_input: #f0a52a; --done: #4fb37b; --failed: #ea6157; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.muted { color: var(--muted); }
button { font: inherit; padding: 6px 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px; cursor: pointer; }
button.danger { border-color: var(--failed); color: var(--failed); }
input, textarea, select { font: inherit; width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink); margin: 4px 0; }
header { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.progress { flex: 1 1 160px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 120px; }
#bar { height: 100%; width: 0; background: var(--done); transition: width .4s; }
.counts span { margin-right: 10px; white-space: nowrap; }
.counts i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
main { display: grid; grid-template-columns: 1fr 360px; height: calc(100vh - 54px); }
#treewrap { position: relative; overflow: hidden; touch-action: none; }
#tree { width: 100%; height: 100%; cursor: grab; }
#legend { position: absolute; left: 12px; bottom: 10px; font-size: 12px; background: var(--panel); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); }
#side { overflow-y: auto; border-left: 1px solid var(--line); padding: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; color: var(--muted); }
.q { border-top: 1px solid var(--line); padding: 8px 0; }
.q:first-child { border-top: 0; }
.q .meta { font-size: 12px; color: var(--muted); }
.node rect { stroke-width: 1.5; rx: 6; }
.node text { font-size: 11px; fill: var(--ink); pointer-events: none; }
.node .id { font-weight: 600; }
.node.sel rect { stroke-width: 3.5; }
.edge { fill: none; stroke: var(--line); stroke-width: 1.5; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--bg); padding: 8px; border-radius: 6px; max-height: 300px; overflow: auto; }
dl { display: grid; grid-template-columns: 90px 1fr; gap: 2px 8px; margin: 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; width: min(360px, 100%); }
.card h1 { font-size: 18px; margin: 0 0 12px; }
@media (max-width: 800px) {
  main { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  #side { border-left: 0; border-top: 1px solid var(--line); }
}
