/* CodeFlow — dense developer-tool interface.
   Palette is graphite/slate so the semantic node colours (which carry the
   actual information) are the only saturated things on screen. */

:root {
  --bg: #14171c;
  --panel: #1b1f26;
  --panel-2: #21262f;
  --line: #2c333d;
  --text: #dfe4ec;
  --muted: #8b95a5;
  --accent: #4a9eff;
  --ok: #48b884;
  --warn: #e0a44a;
  --err: #e2685f;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;

  --c-module: #4a9eff;
  --c-class: #e0a44a;
  --c-function: #a98bd6;
  --c-method: #8f7cc0;
  --c-database: #e2685f;
  --c-data: #d6c14a;
  --c-env: #48b884;
  --c-external: #8b95a5;
  --c-api: #e2685f;
  --c-layer: #4a9eff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 13px;
}

button, select, input { font-family: inherit; font-size: 13px; color: inherit; }
button { cursor: pointer; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------------------------------------------------------- auth */
.auth-body { display: grid; place-items: center; background: var(--bg); }
.auth-card {
  width: min(420px, 92vw); padding: 32px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.auth-card h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.auth-sub { color: var(--muted); margin: 6px 0 22px; }
.auth-note {
  background: var(--panel-2); border-left: 3px solid var(--accent);
  padding: 10px 12px; color: var(--muted); line-height: 1.5; border-radius: 4px;
}
.auth-card label { display: block; margin: 16px 0 6px; color: var(--muted); }
.auth-card input {
  width: 100%; padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px;
}
.auth-card input:focus, .auth-card button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.auth-card button {
  width: 100%; margin-top: 20px; padding: 11px;
  background: var(--accent); color: #06101c; border: 0; border-radius: 6px;
  font-weight: 600;
}
.auth-error { color: var(--err); margin: 14px 0 0; }

/* ---------------------------------------------------------- chrome */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.01em; margin-right: 6px; }
.field { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.field select {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 5px 8px; min-width: 150px;
}
.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); }

button.primary {
  background: var(--accent); color: #06101c; border: 0;
  border-radius: 5px; padding: 6px 14px; font-weight: 600;
}
button.ghost, a.ghost {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 5px; padding: 6px 12px; text-decoration: none;
}
button.ghost:hover, a.ghost:hover { border-color: var(--accent); }
button.small { padding: 4px 10px; }
button.icon {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 4px 9px; color: var(--text);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: #3a2f1a;
  border-bottom: 1px solid var(--warn); color: #f0d9a8;
}

/* ---------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 340px;
  height: calc(100vh - 42px - 26px);
}
.explorer, .inspector {
  background: var(--panel); overflow-y: auto;
  border-right: 1px solid var(--line);
}
.inspector { border-right: 0; border-left: 1px solid var(--line); }

.search-box { position: relative; padding: 10px; }
.search-box input {
  width: 100%; padding: 7px 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 5px;
}
.search-results {
  position: absolute; z-index: 30; left: 10px; right: 10px; top: 46px;
  max-height: 340px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
}
.search-results div {
  padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.search-results div:hover { background: #2b323d; }
.search-results .kind {
  color: var(--muted); font-size: 11px; margin-right: 6px;
  font-family: var(--mono);
}

.filters { padding: 4px 10px 10px; border-bottom: 1px solid var(--line); }
.filters-title, .tree-group-title {
  color: var(--muted); font-size: 11px; margin: 6px 0;
}
#filter-list { display: flex; flex-wrap: wrap; gap: 4px; }
#filter-list label {
  display: flex; align-items: center; gap: 4px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 7px; font-size: 12px; cursor: pointer;
}

.tree { padding: 8px 6px 30px; }
.tree-group { margin-bottom: 4px; }
.tree-group > summary {
  cursor: pointer; padding: 5px 6px; border-radius: 4px;
  color: var(--text); list-style: none;
}
.tree-group > summary:hover { background: var(--panel-2); }
.tree-group .count { color: var(--muted); font-size: 11px; margin-left: 4px; }
.tree-item {
  padding: 3px 6px 3px 20px; font-family: var(--mono); font-size: 11.5px;
  color: var(--muted); cursor: pointer; border-radius: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-item:hover { background: var(--panel-2); color: var(--text); }

/* ---------------------------------------------------------- canvas */
.canvas-wrap { position: relative; display: flex; flex-direction: column; }
.canvas-bar {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  background: var(--panel-2); border-bottom: 1px solid var(--line);
}
.breadcrumb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.breadcrumb button {
  background: none; border: 0; color: var(--accent);
  font-family: var(--mono); font-size: 12px; padding: 2px 4px;
}
.breadcrumb .sep { color: var(--muted); }
.breadcrumb .current { color: var(--text); font-family: var(--mono); font-size: 12px; }
.canvas-tools { margin-left: auto; display: flex; gap: 5px; }

#cy { flex: 1; background: var(--bg); }

.empty {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; color: var(--muted); pointer-events: none;
}
.empty h2 { color: var(--text); font-weight: 600; margin-bottom: 4px; }

.progress-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, 90%); padding: 20px 22px; z-index: 20;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.progress-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.progress-track {
  height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden;
}
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.stages { list-style: none; margin: 14px 0 0; padding: 0; }
.stages li { padding: 3px 0; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.stages li.done { color: var(--ok); }
.stages li.running { color: var(--accent); }
.stages li.error { color: var(--err); }
.progress-msg { margin-top: 10px; color: var(--muted); font-size: 12px; min-height: 16px; }

.legend {
  position: absolute; right: 12px; bottom: 12px; display: flex;
  flex-wrap: wrap; gap: 8px; max-width: 60%;
  background: rgba(27, 31, 38, .92); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; font-size: 11px; color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------------------------------------------------------- inspector */
.inspector-empty { padding: 18px; color: var(--muted); }
.hint { font-size: 12px; }
#inspector-body { padding: 14px; }
#inspector-body h3 {
  margin: 0 0 2px; font-size: 15px; font-family: var(--mono);
  word-break: break-all;
}
#inspector-body .subtitle { color: var(--muted); margin-bottom: 12px; font-size: 12px; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 4px 8px; margin-bottom: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-word; }
.section-title {
  margin: 14px 0 6px; color: var(--muted); font-size: 11px;
  border-top: 1px solid var(--line); padding-top: 10px;
}
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 3px; padding: 2px 6px; font-family: var(--mono);
  font-size: 11px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.inferred { border-style: dashed; border-color: var(--warn); }
.badge {
  display: inline-block; padding: 1px 6px; border-radius: 3px;
  font-size: 10.5px; margin-left: 6px;
}
.badge.resolved { background: #1d3a2c; color: var(--ok); }
.badge.inferred { background: #3a2f1a; color: var(--warn); }
.badge.unresolved { background: #3a2224; color: var(--err); }
pre.code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px; overflow-x: auto; font-family: var(--mono);
  font-size: 11.5px; line-height: 1.45; max-height: 320px;
}
pre.code .ln { color: #5b6472; user-select: none; margin-right: 10px; }
.inspector-actions { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------- status */
.statusbar {
  display: flex; align-items: center; gap: 12px; height: 26px;
  padding: 0 12px; background: var(--panel);
  border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
}

/* ---------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: grid; place-items: center; z-index: 50;
}
.modal {
  width: min(720px, 94vw); max-height: 88vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal header h2 { margin: 0; font-size: 16px; }
.modal > div { padding: 18px; }
.modal footer {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
}
.form-row { display: grid; grid-template-columns: 160px 1fr; gap: 10px; margin-bottom: 9px; align-items: center; }
.form-row label { color: var(--muted); }
.form-row input[type=text], .form-row select {
  padding: 7px 9px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 5px; width: 100%; font-family: var(--mono); font-size: 12px;
}
.form-help { color: var(--muted); font-size: 12px; margin: 4px 0 14px; line-height: 1.5; }
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.export-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  background: var(--panel-2); cursor: pointer;
}
.export-card:hover { border-color: var(--accent); }
.export-card h4 { margin: 0 0 4px; }
.export-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.error-list { max-height: 240px; overflow-y: auto; font-family: var(--mono); font-size: 11.5px; }
.error-list div { padding: 4px 0; border-bottom: 1px solid var(--line); }

.toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 9px 16px; z-index: 80;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.toast.error { border-color: var(--err); color: #ffd7d4; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* ---------------------------------------------------------------- explorer
   Finder-style nested tree: a disclosure arrow, an icon, the name, and the
   one-line description of what the entry actually does. */
.explorer-title {
  padding: 8px 10px 4px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #6f7a8a;
}
.tree-node > .tree-children { margin: 0; }
.tree-children.hidden { display: none; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 0;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
}
.tree-row:hover { background: #1d232c; }
.tree-row.active { background: #24303f; box-shadow: inset 2px 0 0 #4a9eff; }
.tree-row .twisty {
  width: 12px;
  flex: 0 0 12px;
  color: #6f7a8a;
  font-size: 10px;
  text-align: center;
}
.tree-row .twisty.clickable:hover { color: #dfe4ec; }
.tree-row .t-icon { flex: 0 0 12px; font-size: 10px; }
.tree-row .t-name {
  font-size: 12.5px;
  color: #dfe4ec;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-row.t-folder .t-name { font-weight: 600; }
.tree-row.t-function .t-name,
.tree-row.t-method .t-name { color: #c3b2e3; font-family: ui-monospace, Menlo, monospace; }
.tree-row.t-class .t-name { color: #e0a44a; }
.tree-row .t-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  background: #24402f;
  color: #7fd9a6;
}
.tree-row .t-badge.err { background: #3d1f1f; color: #e2685f; }
.tree-sub {
  font-size: 11px;
  color: #7d8798;
  padding-right: 10px;
  margin-bottom: 2px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-node.open > .tree-sub { white-space: normal; }

/* ------------------------------------------------------------- focus card
   Sits directly under the canvas: what is selected, an arrow, what it does. */
.focus-card {
  border-top: 1px solid #232a35;
  background: #12161d;
  padding: 10px 14px 12px;
  max-height: 34%;
  overflow: auto;
}
.focus-card.hidden { display: none; }
.fc-card {
  display: inline-block;
  border: 1px solid #3d7bd6;
  border-radius: 6px;
  padding: 6px 12px;
  background: #1b2029;
}
.fc-head { display: flex; align-items: baseline; gap: 10px; }
.fc-name { font-weight: 600; font-size: 13px; color: #eef2f7; }
.fc-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #7fa8e0;
}
.fc-path { font-size: 10.5px; color: #6f7a8a; margin-top: 2px; }
.fc-arrow {
  color: #3d7bd6;
  font-size: 16px;
  line-height: 1;
  margin: 2px 0 2px 18px;
}
.fc-desc {
  border-left: 2px solid #3d7bd6;
  padding: 4px 0 4px 12px;
  margin-left: 18px;
}
.fc-summary { font-size: 13px; color: #dfe4ec; }
.fc-behaviour { font-size: 12px; color: #9aa5b5; margin-top: 4px; }
.fc-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  margin-top: 8px;
  font-size: 11.5px;
}
.fc-fact-k { color: #6f7a8a; }
.fc-fact-v { color: #c3cad6; }

/* description blocks in the inspector */
.desc-text { font-size: 13px; color: #dfe4ec; margin: 4px 0; }
.desc-behaviour { font-size: 12px; color: #9aa5b5; margin: 2px 0 6px; }
.kv.facts dt { color: #6f7a8a; }
.source-view { max-height: 60vh; overflow: auto; }
