:root {
  --bg: #0c0e12;
  --panel: #14181f;
  --panel-2: #1b212b;
  --ink: #e7eaf0;
  --muted: #8b94a3;
  --faint: #5a6271;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #6ea8fe;
  --good: #4ade80;
  --warn: #e0a23a;
  --done: #6b7280;

  --c-project: #c77dff;
  --c-agent: #6ea8fe;
  --c-task: #f4a259;
  --c-event: #67e8f9;
  --c-decision: #f472b6;
  --c-knowledge: #4ade80;
  --c-commit: #94a3b8;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: inherit; color: var(--ink); }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }

.app { display: flex; flex-direction: column; height: 100%; }

/* ---------- header ---------- */
.hdr {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--bg));
}
.hdr h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.hdr h1 .dot { color: var(--accent); }
.hdr .sub { color: var(--muted); font-size: 12px; }
.hdr .spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.pill.err .led { background: var(--warn); }
.btn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); transition: transform .06s, background .15s;
}
.btn:hover { background: #232b37; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: #08111f; border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }

/* ---------- body layout ---------- */
.body { flex: 1; display: flex; min-height: 0; }
.rail {
  width: 210px; flex-shrink: 0; border-right: 1px solid var(--line);
  padding: 14px; overflow-y: auto; background: var(--panel);
}
.rail h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 18px 0 8px; }
.rail h3:first-child { margin-top: 0; }
.field { margin-bottom: 10px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.field select, .field input {
  width: 100%; padding: 6px 8px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; color: var(--ink); cursor: pointer; }
.check input { accent-color: var(--accent); }
.legend-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.center { flex: 1; min-width: 0; position: relative; background:
  radial-gradient(1200px 600px at 50% -10%, #11151c, var(--bg)); }
.graph { width: 100%; height: 100%; display: block; cursor: grab; }
.graph.panning { cursor: grabbing; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 40px; }
.counts { position: absolute; left: 12px; bottom: 10px; font-size: 11px; color: var(--faint); font-family: var(--mono); }

.inspect { width: 320px; flex-shrink: 0; border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; padding: 9px 4px; background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); font-size: 12px; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .n { color: var(--faint); }
.list { flex: 1; overflow-y: auto; padding: 8px; }
.card {
  padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); margin-bottom: 7px; cursor: pointer; transition: border-color .12s, transform .06s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.card:active { transform: scale(0.99); }
.card.sel { border-color: var(--accent); }
.card .t { font-weight: 550; display: flex; align-items: center; gap: 7px; }
.card .m { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.4; }
.card .act { color: var(--faint); font-size: 12px; font-style: italic; margin-top: 3px; }
.tag { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.kpill { font-size: 11px; font-family: var(--mono); color: var(--c-knowledge); }
.state { font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.state.working { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.state.needs_you { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.state.done { background: rgba(255,255,255,0.06); color: var(--done); }
.muted { color: var(--muted); }
.empty-list { color: var(--faint); text-align: center; padding: 30px 10px; font-size: 13px; }

/* ---------- setup gate ---------- */
.gate { height: 100%; display: grid; place-items: center; padding: 24px; }
.gate-card { width: 420px; max-width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
.gate-card h2 { margin: 0 0 6px; font-size: 18px; }
.gate-card p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; font-size: 13px; }
.gate-card .field { margin-bottom: 14px; }
.gate-card .field input { padding: 9px 11px; }
.gate-err { color: var(--warn); font-size: 12px; margin: -6px 0 12px; }
.gate-note { color: var(--faint); font-size: 11px; margin-top: 14px; line-height: 1.5; }

svg text { user-select: none; }
.node-label { fill: var(--ink); font-size: 10px; pointer-events: none; }
.node-label.faint { fill: var(--faint); }

/* Narrow screens: stack rail → graph → inspector so the graph is never crushed. */
@media (max-width: 980px) {
  .body { flex-direction: column; overflow-y: auto; }
  .rail { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
  .inspect { width: 100%; border-left: none; border-top: 1px solid var(--line); }
  .center { min-height: 62vh; }
  .inspect .list { max-height: 48vh; }
}
