/* css/style.css — FlowLens
   A dark developer-tool surface: quiet chrome, loud findings.

   Restraint rules: colour carries meaning (severity, inputs, the current
   selection), never decoration — no gradients, no coloured card stripes,
   no pills for plain facts. Headings are sentence case. Lists are rows
   with hairlines, not stacks of boxed cards. */

:root {
  /* surfaces, darkest to lightest */
  --bg-0: #0b0f17;
  --bg-1: #111725;
  --bg-2: #161e2f;
  --bg-3: #1d2739;
  --bg-hover: #22304a;

  --line: #243044;
  --line-soft: #1b2434;

  --ink: #e6edf7;
  --ink-dim: #9aa8bf;
  --ink-faint: #64748b;

  /* accents */
  --accent: #7c9cff;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --crit: #fb7185;
  --violet: #a78bfa;

  /* severity */
  --sev-critical: #fb7185;
  --sev-high: #fb923c;
  --sev-medium: #fbbf24;
  --sev-low: #60a5fa;
  --sev-info: #94a3b8;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --code-size: 13px;
  --code-line: 20px;

  --explorer-w: 270px;
  --dock-w: 460px;
  --output-h: 190px;

  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { color-scheme: dark; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a374d; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #38496a; }

/* =========================================================
   TOP BAR
========================================================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  height: 48px;
  flex: 0 0 auto;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.logo { font-weight: 700; font-size: 14px; color: var(--ink); }

.toolbar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.toolbar select { max-width: 170px; text-overflow: ellipsis; }
.workspaceActions { display: flex; gap: 6px; }
.workspaceActions .btn { background: transparent; color: var(--ink-dim); }
.workspaceActions [aria-expanded="true"] { background: var(--bg-3); color: var(--ink); }
.searchAction kbd { font: 10px var(--mono); color: var(--ink-faint); margin-left: 8px; }
.topRight { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-3);
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--bg-hover); border-color: #33445f; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 11.5px; }

.btn-primary {
  background: #3654d1;
  border-color: #4763d8;
  color: #fff;
}
.btn-primary:hover { background: #4262e0; }
.btn .glyph { font-size: 11px; opacity: .95; }

.iconBtn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.iconBtn:hover { background: var(--bg-3); color: var(--ink); border-color: var(--line); }

.field { display: flex; align-items: center; gap: 6px; }
.field.wide { flex: 1; min-width: 0; }
.fieldLabel { color: var(--ink-faint); font-size: 11px; font-weight: 600; }

select, input[type="text"], input:not([type]) {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 8px;
  color: var(--ink);
  outline: none;
  min-width: 0;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }

/* Python status: text with a dot, coloured only when something is wrong. */
.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-dim);
  white-space: nowrap;
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.status[data-state="ready"]::before { background: var(--ok); }
.status[data-state="failed"] { color: var(--danger); }
.status[data-state="failed"]::before { background: var(--danger); }
.status[data-state="busy"] { color: var(--warn); }
.status[data-state="busy"]::before { background: var(--warn); }

/* The header verdict: issue counts, not a score. */
.issueSummary {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-dim);
  font-size: 11.5px;
  cursor: pointer;
  white-space: nowrap;
}
.issueSummary:hover { background: var(--bg-3); color: var(--ink); }
.issueSummary .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.issueSummary .n.critical { color: var(--sev-critical); }
.issueSummary .n.high { color: var(--sev-high); }
.issueSummary .n.medium { color: var(--sev-medium); }
.issueSummary .sep { color: var(--ink-faint); margin: 0 3px; }

/* =========================================================
   LAYOUT
========================================================= */
.startGuide {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
}
.startGuideCopy { flex: 1 1 260px; }
.startGuideCopy strong { font-size: 13px; }
.startGuideCopy p { margin: 2px 0 0; font-size: 12px; color: var(--ink-dim); }
.startGuideActions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.startGuideActions .btn { font-size: 11px; padding: 4px 8px; }

.layout {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--explorer-w) 5px minmax(0, 1fr) 5px var(--dock-w);
}
.layout.explorer-hidden { grid-template-columns: 0 0 minmax(0, 1fr) 5px var(--dock-w); }
.layout.explorer-hidden .explorerPane, .layout.explorer-hidden #splitLeft { display: none; }
.explorerPane { background: var(--bg-1); }
.explorerBackdrop { position: absolute; inset: 0; border: 0; background: rgba(3, 6, 12, .6); z-index: 25; }

.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.splitter { background: var(--bg-0); position: relative; }
.splitter { touch-action: none; }
.splitter.vertical { cursor: col-resize; }
.splitter.horizontal { cursor: row-resize; height: 5px; flex: 0 0 5px; }
.splitter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--line-soft);
  transition: background .12s;
}
.splitter.vertical::after { left: 2px; right: 2px; }
.splitter.horizontal::after { top: 2px; bottom: 2px; }
.splitter:hover::after, .splitter.dragging::after { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing-v { cursor: row-resize; user-select: none; }

.paneHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 6px 0 12px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.paneHead.compact { padding-left: 6px; }
.paneTitle { font-size: 12px; font-weight: 600; color: var(--ink-dim); }
.paneActions { display: flex; align-items: center; gap: 2px; }

/* =========================================================
   EXPLORER
========================================================= */
.explorerPane { background: var(--bg-1); border-right: 1px solid var(--line); }
.explorerBody { flex: 1; overflow: auto; padding: 6px 0 12px; position: relative; }
.explorerBody.dropping { background: rgba(124, 156, 255, .08); outline: 2px dashed var(--accent); outline-offset: -6px; }

.tree { font-size: 12.5px; }

.node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  white-space: nowrap;
  color: var(--ink-dim);
  border-left: 2px solid transparent;
}
.node:hover { background: var(--bg-2); color: var(--ink); }
.node.active { background: var(--bg-3); color: var(--ink); border-left-color: var(--accent); }
.node.entry .nodeName { color: var(--accent-2); }
.node.dirty .nodeName::after { content: " ●"; color: var(--warn); font-size: 9px; }
.node.dragover { background: rgba(124, 156, 255, .16); }

.nodeTwisty { width: 12px; text-align: center; font-size: 9px; opacity: .7; flex: 0 0 12px; }
.nodeIcon { width: 14px; text-align: center; font-size: 11px; flex: 0 0 14px; opacity: .85; }
.nodeName { overflow: hidden; text-overflow: ellipsis; }
.nodeBadge {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--ink-faint);
}
.nodeBadge.crit { background: rgba(251, 113, 133, .18); color: var(--sev-critical); }
.nodeBadge.warn { background: rgba(251, 191, 36, .16); color: var(--sev-medium); }

.icon-py { color: #6ea8fe; }
.icon-js { color: #f7df1e; }
.icon-md { color: #94a3b8; }
.icon-dir { color: var(--ink-faint); }

.dropHint {
  margin: 18px 12px;
  padding: 14px 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-faint);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.5;
}

.explorerFoot {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 10.5px;
  background: var(--bg-1);
}

/* rename input inside the tree */
.renameInput {
  flex: 1;
  background: var(--bg-0);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
  min-width: 0;
}

/* =========================================================
   EDITOR
========================================================= */
.editorPane { background: var(--bg-0); }

.tabstrip {
  display: flex;
  align-items: stretch;
  height: 34px;
  flex: 0 0 auto;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.tabstrip::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 12px;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  border-top: 2px solid transparent;
}
.tab:hover { background: var(--bg-2); color: var(--ink-dim); }
.tab.active { background: var(--bg-0); color: var(--ink); border-top-color: var(--accent); }
.tab .tabClose { opacity: 0; font-size: 13px; line-height: 1; padding: 0 2px; border-radius: 3px; }
.tab:hover .tabClose, .tab.active .tabClose { opacity: .6; }
.tab .tabClose:hover { opacity: 1; background: var(--bg-hover); }
.tab.dirty .tabClose { opacity: 1; }
.tab.dirty .tabClose::before { content: "●"; font-size: 9px; }
.tab.dirty:hover .tabClose::before { content: "✕"; font-size: 11px; }
.tab:not(.dirty) .tabClose::before { content: "✕"; font-size: 11px; }

.editorHost { flex: 1 1 auto; min-height: 0; position: relative; }

.selectionSummary {
  position: absolute;
  inset: auto 12px 12px auto;
  z-index: 5;
  width: min(340px, calc(100% - 24px));
  max-height: min(220px, 92%);
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  box-shadow: 0 10px 28px #0008;
  color: var(--ink);
  font-size: 12px;
}
.selectionSummaryHead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.selectionSummaryHead strong { overflow-wrap: anywhere; }
.selectionSummaryBody { line-height: 1.5; overflow-wrap: anywhere; }
.selectionSummaryBody p { margin: 4px 0; }
.selectionSummaryBody ul { margin: 5px 0 0; padding-left: 18px; }

.editorScroll {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  overflow: auto;
  background: var(--bg-0);
}

.gutter {
  flex: 0 0 auto;
  min-height: 100%;
  padding: 10px 8px 10px 12px;
  text-align: right;
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--code-line);
  color: #3f4c63;
  -webkit-user-select: none;
  user-select: none;
  background: var(--bg-0);
  position: sticky;
  left: 0;
  z-index: 3;
  border-right: 1px solid var(--line-soft);
}
.gutter .gline { display: block; height: var(--code-line); position: relative; white-space: nowrap; }
.gutter .gline.hasFinding { color: var(--sev-medium); font-weight: 700; cursor: pointer; }
.gutter .gline.hasFinding.critical, .gutter .gline.hasFinding.high { color: var(--sev-critical); }
.gutter .gline.failed { color: var(--danger); font-weight: 800; }
.gutter .gline.failed::before {
  content: "▸";
  position: absolute; left: -8px;
  color: var(--danger);
}

/* Let the textarea establish the full content height. Stretching this flex
   item to the viewport clips its absolute highlight layer on longer files. */
.codeWrap { position: relative; flex: 1 0 auto; min-width: 0; min-height: 100%; font: var(--code-size) var(--mono); }
.editorFoot { display: flex; justify-content: space-between; gap: 10px; padding: 4px 10px; background: var(--bg-1); border-top: 1px solid var(--line-soft); color: var(--ink-dim); font: 10.5px var(--mono); flex: 0 0 auto; }
#editorSaveStatus[data-dirty="true"] { color: var(--warn); }
/* Nothing is reaching IndexedDB: the text explains it, the colour has to match. */
#editorSaveStatus[data-stored="false"] { color: var(--danger); }

.highlight, #code {
  margin: 0;
  padding: 10px 16px 10px 10px;
  font-family: var(--mono);
  font-size: var(--code-size);
  line-height: var(--code-line);
  white-space: pre;
  tab-size: 4;
  border: 0;
  min-height: 100%;
}

.highlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  color: var(--ink);
  z-index: 1;
}
.highlight code { font: inherit; }

#code {
  position: relative;
  display: block;
  width: 100%;
  min-width: 100%;
  height: 100%;
  background: transparent;
  color: transparent;
  caret-color: var(--accent-2);
  resize: none;
  outline: none;
  overflow: hidden;
  z-index: 2;
}
#code::selection { background: rgba(124, 156, 255, .3); color: transparent; }
body.no-highlight .highlight { display: none; }
body.no-highlight #code { color: var(--ink); }

/* python syntax colours */
.tok-kw { color: #ff7bb0; }
.tok-def { color: #7dd3fc; font-weight: 600; }
.tok-str { color: #a5e6a5; }
.tok-num { color: #ffb86c; }
.tok-com { color: #5b6b85; font-style: italic; }
.tok-fn { color: #c4b5fd; }
.tok-builtin { color: #67e8f9; }
.tok-self { color: #fca5a5; font-style: italic; }
.tok-dec { color: #fbbf24; }

.emptyEditor {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-0);
  z-index: 5;
}
.emptyEditor[hidden] { display: none; }
.emptyInner { text-align: center; max-width: 340px; }
.emptyInner h2 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.emptyInner p { margin: 0 0 16px; color: var(--ink-faint); line-height: 1.6; }

/* =========================================================
   OUTPUT PANE
========================================================= */
.outputPane {
  flex: 0 0 var(--output-h);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-top: 1px solid var(--line);
}
.outputPane.collapsed { flex-basis: 34px; }

.miniTabs { display: flex; gap: 2px; }
.miniTab {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
}
.miniTab:hover { background: var(--bg-2); color: var(--ink-dim); }
.miniTab.active { background: var(--bg-3); color: var(--ink); }
.miniTab .count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-0);
  font-size: 10px;
}
.miniTab .count.hot { background: rgba(251, 113, 133, .2); color: var(--sev-critical); }

.runMeta { font-size: 10.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.outputBody { flex: 1; min-height: 0; position: relative; }
.outView { position: absolute; inset: 0; overflow: auto; padding: 8px 12px; display: none; }
.outView.active { display: block; }

#outStdout, #outProblems { font-family: var(--mono); font-size: 12px; line-height: 1.6; }

/* Suppressions: the `# flowlens: ignore` comment and what it hid. */
.suppressedCard { border-style: dashed; opacity: .92; }
.suppressNote {
  display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline;
  padding: 6px 10px; background: var(--bg-1); border-top: 1px solid var(--line-soft);
  font: 11px var(--mono); color: var(--ink-dim);
}
.suppressLabel { color: var(--ink-faint); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; }
.suppressDirective { padding: 1px 5px; border-radius: 3px; background: var(--bg-1); outline: 1px solid var(--line-soft); }
.suppressReason.empty { font-style: italic; }
.suppressWhere { color: var(--ink-faint); }

/* Rule switches: a preference for this browser, so marked apart from a comment
   that recorded a decision about one line of code. */
.suppressedCard.hiddenByRule { border-left: 3px solid var(--warn); }
.ruleOffRow {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin: 5px 0; padding: 6px 10px;
  background: var(--bg-1); border: 1px solid var(--line-soft); border-left: 3px solid var(--warn);
  border-radius: 4px;
}
.ruleOffNote { flex: 1; min-width: 120px; font-size: 11.5px; color: var(--ink-dim); }
.toast.warn { border-left: 3px solid var(--warn); }
#outStdout pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.streamLabel { color: var(--ink-faint); font-size: 11px; margin: 8px 0 2px; }
.streamLabel:first-child { margin-top: 0; }
.stderrText { color: var(--warn); }
.errorBlock {
  margin-top: 8px;
  padding: 8px 10px;
  border-left: 3px solid var(--danger);
  background: rgba(248, 113, 113, .08);
  border-radius: 0 6px 6px 0;
  color: #ffc9c9;
  white-space: pre-wrap;
  word-break: break-word;
}
.errorBlock .errType { color: var(--danger); font-weight: 700; }
.resultBlock {
  margin-top: 8px;
  padding: 6px 10px;
  border-left: 3px solid var(--ok);
  background: rgba(52, 211, 153, .07);
  border-radius: 0 6px 6px 0;
}

#stdinBox {
  width: 100%; height: 100%;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  resize: none;
  outline: none;
}

.problemRow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--ui);
}
.problemRow:hover { background: var(--bg-2); }
.problemLoc { color: var(--accent); font-family: var(--mono); font-size: 11px; flex: 0 0 auto; }
.problemMsg { color: var(--ink-dim); font-size: 12px; }

/* =========================================================
   DOCK
========================================================= */
.dockPane { background: var(--bg-1); border-left: 1px solid var(--line); }

.dockTabs {
  display: flex;
  height: 34px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}
.dockTab {
  flex: 1;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-faint);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.dockTab:hover { color: var(--ink-dim); background: var(--bg-2); }
.dockTab.active { color: var(--ink); border-bottom-color: var(--accent); }

.dockView { flex: 1; min-height: 0; display: none; flex-direction: column; position: relative; }
.dockView.active { display: flex; }

/* ---- flow ---- */
.flowControls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  flex-wrap: wrap;
}
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-dim); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); margin: 0; }
.flowControls .check:last-child { margin-left: auto; }
.graphNavigation { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); background: var(--bg-1); }
.graphNavigation select { flex: 1; min-width: 0; width: 0; font-size: 11px; }
.graphZoom { display: flex; align-items: center; gap: 3px; }
.graphZoom .iconBtn { width: 25px; height: 28px; }
.graphZoom .btn { padding: 5px 7px; font-size: 11px; }
#graphZoomValue { min-width: 35px; text-align: center; font: 10px var(--mono); color: var(--ink-dim); }
.graphSelection { flex: 0 0 98px; min-width: 0; padding: 9px 12px; border-top: 1px solid var(--line); background: var(--bg-2); }
.graphSelectionTitle { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.graphSelectionTitle strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 12px var(--mono); color: var(--accent-2); }
.graphSelectionTitle span { max-width: 42%; overflow: hidden; text-overflow: ellipsis; color: var(--ink-faint); font-size: 10px; white-space: nowrap; }
#graphSelectionMeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-dim); font-size: 11px; margin: 5px 0 8px; }
.graphSelectionActions { display: flex; gap: 6px; }
.graphSelectionActions .btn { font-size: 11px; padding: 4px 8px; }
@media (max-width: 640px) {
  .graphSelection { flex-basis: 78px; padding: 6px 10px; }
  .graphSelectionTitle strong { font-size: 11px; }
  #graphSelectionMeta { font-size: 10px; margin: 4px 0 6px; }
  .graphSelectionActions .btn { padding: 3px 7px; }
}

#p5holder { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; background: var(--bg-0); }
#p5holder canvas { display: block; touch-action: none; }

.graphLegend {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--ink-dim);
}
.graphLegend span { display: inline-flex; align-items: center; gap: 5px; }
.graphTooltip {
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: min(240px, calc(100% - 12px));
  pointer-events: none;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: 0 5px 16px #0009;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.graphTooltip strong { display: block; margin-bottom: 3px; }

.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }
.dot.static { background: #55647f; }
.dot.runtime { background: var(--ok); }
.dot.broken { background: var(--danger); }

.graphHint {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 10.5px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}

/* ---- insights ---- */
.proofDemo {
  flex: 0 0 auto;
  max-height: 55%;
  overflow: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 12px;
}
.proofDemo strong { color: var(--ink); }
.proofDemo p { margin: 4px 0 8px; color: var(--ink-dim); }
#proofDemoStatus { color: var(--accent-2); }
.proofActions { display: flex; gap: 6px; flex-wrap: wrap; }
.proofDiff { margin-top: 8px; max-height: 165px; overflow: auto; }
.proofDiff pre { margin: 4px 0 8px; font-size: 11px; }
.insightTabs {
  display: flex;
  /* The strip hides its scrollbar, so tabs pushed past the edge are neither seen nor
     clicked. Wrapping keeps all fourteen reachable; overflow-x stays for a dock narrow
     enough that one tab alone is wider than the strip. */
  flex-wrap: wrap;
  gap: 2px;
  padding: 6px 8px;
  flex: 0 0 auto;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.insightTabs::-webkit-scrollbar { display: none; }
.insightTab {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.insightTab:hover { background: var(--bg-2); color: var(--ink-dim); }
.insightTab.active { background: var(--bg-3); color: var(--ink); }
.insightTab .tabCount { opacity: .6; margin-left: 3px; }

.insightBody { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px 24px; }

.placeholder { color: var(--ink-faint); font-size: 12px; padding: 18px 4px; line-height: 1.6; }
.placeholder.small { padding: 10px 2px; font-size: 11.5px; }

/* overview: one sentence, then the few numbers that change what to do */
.overviewLead { margin: 2px 0 12px; font-size: 12.5px; line-height: 1.6; color: var(--ink-dim); }
.sevCount { font-weight: 600; }
.sevCount.critical { color: var(--sev-critical); }
.sevCount.high { color: var(--sev-high); }
.sevCount.medium { color: var(--sev-medium); }
.sevCount.low { color: var(--sev-low); }
.sevCount.info { color: var(--sev-info); }
.statTable { display: grid; border-top: 1px solid var(--line-soft); margin-bottom: 4px; }
.statRow {
  display: grid;
  grid-template-columns: 104px 64px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 5px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}
.statRow.link { cursor: pointer; }
.statRow.link:hover { background: var(--bg-2); }
.statLabel { color: var(--ink-faint); }
.statValue { font-family: var(--mono); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.statValue.order.explosive { color: var(--sev-critical); }
.statValue.order.polynomial { color: var(--sev-high); }
.statNote { color: var(--ink-dim); min-width: 0; }

/* the baseline line, in the Overview */
.baselineBox {
  margin: 18px 0 16px;
  padding: 10px 12px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-1);
}
.baselineBox .sectionTitle { margin: 0 0 6px; }
.baselineLead { font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.baselineNote { font-size: 12px; line-height: 1.65; color: var(--ink-dim); margin-top: 5px; }
/* Only the states that ask something of the reader are coloured. "Same" stays
   ink: matching a snapshot nobody re-saved is not an achievement, and green
   would read as one. */
.baselineBox.differs .baselineLead { color: var(--warn); }
.baselineBox.unknown .baselineLead { color: var(--ink-faint); }
.baselineActions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.baselineBox .findingWhy { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-faint); }
/* The change review belongs to the line above it: same claim, read in detail. The
   rail on the hiding and rule-toggle lines is deliberate — those are the two a
   reader otherwise reads as "it got better", so they get the colour the rest of the
   app uses for "look at this", and nothing in the review is ever green. */
.baselineReview { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
.baselineReviewHead { font-size: 12px; line-height: 1.5; color: var(--ink); }
.baselineReviewLine {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  margin-top: 4px;
  padding-left: 9px;
  border-left: 2px solid var(--line-soft);
}
.baselineReviewLine[data-kind="hidden"],
.baselineReviewLine[data-kind="rules-off"],
.baselineReviewLine[data-kind="rules-on"] { border-left-color: var(--warn); }
.baselineReviewNote { font-size: 11.5px; line-height: 1.6; color: var(--ink-faint); margin-top: 6px; }

.sectionTitle {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin: 20px 0 8px;
}
.sectionTitle:first-child { margin-top: 0; }

/* finding cards */
.finding { border-bottom: 1px solid var(--line-soft); }
.finding.open { background: var(--bg-2); }

.findingHead {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 4px;
  cursor: pointer;
}
.findingHead:hover { background: var(--bg-2); }
.sevTag { flex: 0 0 52px; font-size: 11px; font-weight: 600; color: var(--sev-info); }
.finding.critical .sevTag { color: var(--sev-critical); }
.finding.high .sevTag { color: var(--sev-high); }
.finding.medium .sevTag { color: var(--sev-medium); }
.finding.low .sevTag { color: var(--sev-low); }

.findingMain { flex: 1; min-width: 0; }
.findingTitle { font-size: 12.5px; font-weight: 500; line-height: 1.45; color: var(--ink); }
.findingTitle code { font-family: var(--mono); font-size: 11.5px; background: var(--bg-3); padding: 0 3px; border-radius: 3px; color: var(--ink); }
.findingLoc {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 3px;
}
.findingLoc a { color: var(--accent); text-decoration: none; cursor: pointer; }
.findingLoc a:hover { text-decoration: underline; }
.findingChevron { flex: 0 0 auto; color: var(--ink-faint); font-size: 10px; margin-top: 3px; transition: transform .15s; }
.finding.open .findingChevron { transform: rotate(90deg); }

.findingBody { display: none; padding: 0 8px 12px 66px; }
.finding.open .findingBody { display: block; }
.findingWhy { font-size: 12px; line-height: 1.65; color: var(--ink-dim); margin-bottom: 8px; }
.findingFix {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
  padding-left: 9px;
  border-left: 2px solid var(--ok);
  margin-bottom: 9px;
}
/* Tags, rule id, CWE: plain facts, so plain text separated by dots. */
.findingMeta { display: flex; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--ink-faint); }
.chip { font-size: 11px; color: var(--ink-faint); }
.findingMeta .chip + .chip::before { content: "·"; margin: 0 6px; }

/* before / after */
.beforeAfter { display: grid; gap: 8px; }
.baBlock { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.baLabel {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  background: var(--bg-3);
  color: var(--ink-faint);
}
.baBlock.before .baLabel { color: var(--danger); }
.baBlock.after .baLabel { color: var(--ok); }
.baCode {
  margin: 0;
  padding: 8px 10px;
  background: var(--bg-0);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  color: #cbd5e1;
}

.codeBlock {
  margin: 6px 0;
  padding: 8px 10px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
  color: #cbd5e1;
}

.copyRow { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* ---- big-O badges ---- */
.oBadge { display: inline-flex; align-items: baseline; gap: 5px; flex: 0 0 auto; }
.oValue { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.oCaption { font-size: 11px; color: var(--ink-faint); }

.oBadge.constant .oValue { color: var(--ok); }
.oBadge.log .oValue { color: var(--ok); }
.oBadge.linear .oValue { color: #7dd3fc; }
.oBadge.polynomial .oValue { color: var(--sev-high); }
.oBadge.explosive .oValue { color: var(--sev-critical); }
.oBadge.unknown .oValue { color: var(--ink-faint); }


.oRow { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }

.costList { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.costRow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--bg-0);
  cursor: pointer;
  font-size: 11.5px;
}
.costRow:hover { background: var(--bg-3); }
.costLine { font-family: var(--mono); font-size: 10.5px; color: var(--accent); flex: 0 0 auto; }
.costWhat { flex: 1; color: var(--ink-dim); min-width: 0; }
.costOrder { font-family: var(--mono); font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.costOrder.constant, .costOrder.log { color: var(--ok); }
.costOrder.linear { color: #7dd3fc; }
.costOrder.polynomial { color: var(--sev-high); }
.costOrder.explosive { color: var(--sev-critical); }

.gainChip { display: inline-block; margin-top: 4px; font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--ok); }

/* variables table */
.varTable { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.varTable th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  padding: 5px 6px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: -10px;
  background: var(--bg-1);
}
.varTable td { padding: 5px 6px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.varTable tr:hover td { background: var(--bg-2); }
.varName { font-family: var(--mono); color: var(--accent-2); cursor: pointer; }
.varName:hover { text-decoration: underline; }
.varKind { color: var(--ink-faint); font-size: 10.5px; }

/* architecture view — bands are layers, top down; red is a call that closes a ring */
.archLead { font-size: 11.5px; color: var(--ink-dim); line-height: 1.55; margin-bottom: 8px; }
.archLegend { display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--ink-faint); margin-bottom: 10px; }
.archLegendSwatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--danger); }
.archBand { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin-bottom: 8px; background: var(--bg-1); }
.archBandHead { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.archBandLabel { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--accent-2); }
.archBandNote { flex: 1 1 240px; font-size: 10.5px; color: var(--ink-faint); line-height: 1.5; }
.archChip { border: 1px solid var(--line-soft); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; background: var(--bg-2); cursor: pointer; }
.archChip:last-child { margin-bottom: 0; }
.archChip:hover { border-color: var(--accent); }
.archChip.inCycle { border-color: var(--danger); }
.archPath { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.archChip.inCycle .archPath { color: var(--danger); }
.archCoupling { display: block; margin-top: 2px; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); }
.archEdges { list-style: none; margin: 5px 0 0; padding: 0; }
.archEdge { position: relative; padding-left: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); }
.archEdge::before { content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 1px; background: var(--line); }
.archEdge.onCycle { color: var(--danger); }
.archEdge.onCycle::before { background: var(--danger); }
.archEdge.unknown { color: var(--ink-faint); font-style: italic; }
/* the workspace's own layer name for this file, from `.flowlens.json` — never the band's label */
.archDeclared { display: block; margin-top: 2px; font-size: 10px; color: var(--ink-dim); }

/* The main-sequence plot (backlog item 10). Red stays the ring's colour on this tab, so an
   off-line module is amber here and the legend says so beside the plot. */
.archSeqLead { font-size: 11.5px; color: var(--ink-dim); line-height: 1.55; margin-bottom: 6px; }
.archSeqLegend { font-size: 10.5px; color: var(--ink-faint); line-height: 1.5; margin-bottom: 8px; }
.archSeqRefused { font-size: 11px; color: var(--ink-faint); font-style: italic; line-height: 1.55; }
.archSeqPlot { display: block; width: 100%; max-width: 330px; height: auto; margin-bottom: 8px; overflow: visible; }
.archSeqFrame { fill: var(--bg-1); stroke: var(--line); stroke-width: 1; }
.archSeqBand { fill: var(--ok); fill-opacity: 0.14; stroke: none; }
.archSeqLine { stroke: var(--ok); stroke-width: 1.5; }
.archSeqGap { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 2; }
.archSeqDot.on { fill: var(--accent); }
.archSeqDot.off { fill: var(--warn); stroke: var(--bg-0); stroke-width: 1; }
.archSeqTick { fill: var(--ink-faint); font-family: var(--mono); font-size: 9px; }
.archSeqTitle { fill: var(--ink-dim); font-family: var(--mono); font-size: 9.5px; }
.archSeqCorner { fill: var(--ink-faint); font-family: var(--mono); font-size: 9px; font-style: italic; }
.archSeqRows { list-style: none; margin: 0 0 8px; padding: 0; }
.archSeqRow { position: relative; padding-left: 12px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); cursor: pointer; }
.archSeqRow::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }
.archSeqRow.unplaced::before { background: var(--line); }
.archSeqRow.bad::before { background: none; border: 1px dashed var(--crit); width: 5px; height: 5px; }
.archSeqRow.bad { color: var(--ink-faint); font-style: italic; }
.archSeqRow:hover { color: var(--ink); }
.archSeqMore { padding-left: 12px; font-family: var(--mono); font-size: 10px; color: var(--ink-faint); font-style: italic; }
.fnPill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  margin: 1px 2px 1px 0;
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--ink-dim);
  cursor: pointer;
  border: 1px solid transparent;
}
.fnPill:hover { border-color: var(--accent); color: var(--ink); }
.fnPill.write { background: rgba(251, 191, 36, .12); color: var(--sev-medium); }
.fnPill.read { background: rgba(96, 165, 250, .12); color: var(--sev-low); }

.filterBar { display: flex; gap: 6px; margin-bottom: 10px; }
.filterBar input { flex: 1; }

/* ---- probe ---- */
#dockProbe { padding: 10px 12px; overflow: auto; gap: 12px; }
.probeHead { display: flex; flex-direction: column; gap: 6px; }
.probeSig {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  padding: 6px 8px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-x: auto;
  white-space: pre;
}
.probeArgs { display: flex; flex-direction: column; gap: 6px; }
.probeRow { display: flex; gap: 6px; }
.probeRow input {
  flex: 1;
  font-family: var(--mono);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  outline: none;
}
.mono { font-family: var(--mono); }
.probeSuggest { display: flex; gap: 5px; flex-wrap: wrap; }
.suggestChip {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  cursor: pointer;
}
.suggestChip:hover { border-color: var(--accent); color: var(--ink); }

.probeCases { display: flex; flex-direction: column; gap: 6px; }
.probeCasesHead { display: flex; align-items: center; justify-content: space-between; }
.caseList { display: flex; flex-direction: column; gap: 4px; }
.caseRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 11px;
}
.caseRow .caseArgs { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caseRow .caseOut { color: var(--ink-faint); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caseRow.pass { border-left: 3px solid var(--ok); }
.caseRow.fail { border-left: 3px solid var(--danger); }
.caseRow.fail .caseOut { color: var(--danger); }
.caseRow .iconBtn { flex: 0 0 auto; }
/* A result belongs to the code it ran against. Once the workspace has been
   analysed again the pass/fail colour would be a claim about code that changed,
   so a stale row keeps a dashed edge and the words say what it is. */
.caseRow.stale { border-left: 3px dashed var(--warn); }
.caseRow.stale .caseOut { color: var(--ink-faint); font-style: italic; }
.staleNote { color: var(--ink-faint); font-size: 11px; font-style: italic; }

.probeResult { display: flex; flex-direction: column; gap: 6px; }
.probeOutcome {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-word;
}
.probeOutcome.ok { border-left: 3px solid var(--ok); }
.probeOutcome.err { border-left: 3px solid var(--danger); color: #ffc9c9; }
.probeOutcome .outLabel { color: var(--ink-faint); font-size: 11px; display: block; margin-bottom: 3px; }

.timelineBox { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.timelineControls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.timelineRange { flex: 1; min-width: 120px; accent-color: var(--accent); }
.timelineReadout, .timelineNote { color: var(--ink-faint); font-size: 11px; }
.timelineNote { font-style: italic; }
.traceList { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.traceStep {
  display: flex;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-dim);
  padding: 2px 0;
}
.traceStep.current { color: var(--ink); background: var(--bg-2); }
.traceStep .traceArrow { color: var(--ink-faint); }
.traceStep.current .traceArrow { color: var(--accent); }
.traceStep .traceRet { color: var(--ok); }

/* =========================================================
   OVERLAYS
========================================================= */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 200px;
  max-width: 340px;
  padding: 9px 13px;
  border-radius: 9px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--ink);
  animation: toastIn .18s ease-out;
}
.toast.error { border-left: 3px solid var(--danger); }
.toast.ok { border-left: 3px solid var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.modalBack {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, .68);
  display: grid;
  place-items: center;
  z-index: 100;
}
.modalBack[hidden] { display: none; }
.modal {
  width: min(440px, calc(100vw - 40px));
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modalTitle { padding: 13px 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.modalBody { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.modalBody input, .modalBody select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.modalBody .hint { font-size: 11.5px; color: var(--ink-faint); line-height: 1.5; }
.modalFoot { padding: 12px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }

.ctxMenu {
  position: fixed;
  min-width: 168px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: 95;
  max-height: calc(100vh - 16px);
  max-width: calc(100vw - 8px);
  overflow: auto;
}
.ctxMenu[hidden] { display: none; }
.ctxItem {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-dim);
}
.ctxItem:hover, .ctxItem:focus-visible { background: var(--bg-hover); color: var(--ink); }
.ctxItem.danger { color: var(--danger); }
.ctxItem.danger:hover { background: rgba(248, 113, 113, .14); }
.ctxItem .ctxKey { font-size: 10px; color: var(--ink-faint); font-family: var(--mono); }
.ctxSep { height: 1px; background: var(--line); margin: 4px 2px; }

.bootOverlay {
  position: fixed;
  inset: 0;
  background: var(--bg-0);
  display: grid;
  place-items: center;
  z-index: 120;
  transition: opacity .3s;
}
.bootOverlay.done { opacity: 0; pointer-events: none; }
.bootInner { text-align: center; width: min(340px, 80vw); }
.bootLogo { font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 18px; }
.bootBar { height: 3px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.bootFill {
  height: 100%;
  width: 12%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}
.bootText { margin-top: 12px; font-size: 12.5px; color: var(--ink-dim); }
.bootNote { margin-top: 6px; font-size: 11px; color: var(--ink-faint); }
.bootOverlay.failed .bootText { color: var(--danger); }
.bootActions { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }

/* Project search stays in the sidebar, alongside the file tree. */
.explorerModes { display: flex; gap: 4px; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.explorerModes button { flex: 1; padding: 6px 8px; background: transparent; border: 0; border-radius: 5px; color: var(--ink-dim); font-size: 11.5px; cursor: pointer; }
.explorerModes [aria-selected="true"] { color: var(--accent); background: rgba(124, 156, 255, .1); }
.searchBody { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.searchFields { display: flex; flex-direction: column; gap: 8px; padding: 12px 10px; }
.searchRow { display: flex; align-items: center; gap: 4px; }
.searchRow input { min-width: 0; width: 100%; background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; }
.searchRow input::-webkit-search-cancel-button { display: none; }
.searchSummary { color: var(--ink-dim); padding: 0 10px 10px; font-size: 11px; }
.searchResults { flex: 1; min-height: 0; overflow: auto; padding-bottom: 12px; }
.searchFile { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.searchResult { display: flex; align-items: baseline; gap: 8px; width: 100%; border: 0; background: transparent; text-align: left; padding: 6px 10px; cursor: pointer; font: 11px var(--mono); }
.searchResult:hover, .searchResult:focus-visible { background: var(--bg-hover); }
.searchLine { color: var(--ink-faint); min-width: 22px; text-align: right; }
.searchSnippet { overflow: hidden; white-space: pre; text-overflow: ellipsis; color: var(--ink-dim); }
.searchSnippet mark { color: var(--ink); background: rgba(124, 156, 255, .25); border-radius: 2px; }
.searchEmpty { padding: 14px 12px; color: var(--ink-faint); line-height: 1.7; font-size: 11.5px; }

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1280px) {
  :root { --dock-w: 380px; --explorer-w: 240px; }
  .searchAction kbd { display: none; }
}

@media (max-width: 1000px) {
  .layout, .layout.explorer-hidden {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 5px minmax(120px, var(--dock-h, 42%));
  }
  .explorerPane { position: absolute; top: 0; left: 0; bottom: 0; width: min(300px, calc(100% - 32px)); z-index: 30; box-shadow: var(--shadow); border-right: 1px solid var(--line); }
  .splitter#splitLeft { display: none; }
  .splitter#splitRight { cursor: row-resize; height: 5px; }
  .splitter#splitRight::after { top: 2px; bottom: 2px; left: 0; right: 0; }
  .workspaceActions .actionLabel { display: none; }
  .toolbar select { max-width: 125px; }
}

@media (max-width: 640px) {
  :root { --output-h: 110px; }
  .topbar { display: grid; grid-template-columns: auto auto minmax(0, 1fr); height: auto; gap: 8px; padding: 8px; }
  .toolbar { grid-row: 2; grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .toolbar .btn { justify-content: center; }
  .toolbar .field { min-width: 0; }
  .toolbar .fieldLabel { font-size: 9px; }
  .toolbar select { width: 100%; max-width: none; padding: 5px; }
  .workspaceActions .btn { padding: 5px 8px; }
  .topRight { gap: 5px; min-width: 0; }
  .status { font-size: 10px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .issueSummary { padding: 3px 4px; font-size: 10.5px; }
  .layout, .layout.explorer-hidden {
    grid-template-rows: minmax(0, 1fr) 5px minmax(300px, var(--dock-h, 50%));
  }
  .startGuide { padding: 5px 8px; }
  .flowControls { flex-wrap: wrap; gap: 8px; }
  .graphLegend { font-size: 10px; padding: 4px 8px; }
  .graphHint { display: none; }
  .runMeta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
  .editorFoot { font-size: 9px; padding: 4px 6px; }
  .blocksPalette { flex-basis: 105px; }
  .blocksBar { flex-wrap: wrap; }
}
@media (max-width: 360px) { .healthChip { display: none; } }
@media (max-width: 640px) and (max-height: 650px) {
  .layout, .layout.explorer-hidden { grid-template-rows: minmax(0, 1fr) 5px minmax(290px, var(--dock-h, 42%)); }
  :root { --output-h: 34px; }
  .startGuide { padding-block: 1px; }
  .startGuideCopy, #startGraphBtn, #startImportBtn { display: none; }
  .startGuideActions .btn { font-size: 10px; }
  .startGuideActions .iconBtn { width: 22px; height: 22px; }
  .tabstrip { height: 26px; }
  .graphLegend { gap: 6px; }
  .graphLegend span:last-child { display: none; }
  .graphSelection { flex-basis: 58px; }
  .flowControls { padding: 4px 8px; }
  .graphNavigation { padding: 6px 8px; }
  #graphSelectionMeta { margin: 2px 0; }
  .graphSelectionActions { margin-top: 2px; }
}

/* =========================================================
   BLOCK EDITOR
========================================================= */
#dockBlocks { display: none; flex-direction: column; min-height: 0; }
#dockBlocks.active { display: flex; }

.blocksBar {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
}

.blocksMain { flex: 1 1 auto; min-height: 0; display: flex; }

.blocksPalette {
  flex: 0 0 132px;
  overflow-y: auto;
  padding: 8px 6px 14px;
  border-right: 1px solid var(--line);
  background: var(--bg-1);
}

.paletteGroup {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  margin: 10px 0 5px 4px;
}
.paletteGroup:first-child { margin-top: 0; }

.paletteBlock {
  padding: 5px 9px;
  margin-bottom: 4px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: grab;
  border: 1px solid transparent;
  -webkit-user-select: none;
  user-select: none;
}
.paletteBlock:hover { filter: brightness(1.25); }
.paletteBlock:active { cursor: grabbing; }

.blocksCanvas {
  flex: 1 1 auto;
  min-width: 0;
  overflow: auto;
  padding: 10px 12px 24px;
  background: var(--bg-0);
}

.blkStack { display: flex; flex-direction: column; }

.blkDrop { height: 6px; border-radius: 3px; transition: height .1s, background .1s; }
.blkDrop.over { height: 22px; background: rgba(124, 156, 255, .35); }

.blk {
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .10);
  margin: 0;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.blk.dragging { opacity: .4; }
.blk.selected { outline: 2px solid var(--accent); outline-offset: 1px; }

.blkHead {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
}

.blkLabel { font-size: 12px; font-weight: 700; white-space: nowrap; }
.blkWord { font-size: 11px; opacity: .75; }

.blkField { display: inline-flex; align-items: center; gap: 5px; }

.blkInput {
  background: rgba(0, 0, 0, .32);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: #fff;
  width: 74px;
  outline: none;
}
.blkInput.wide { width: 130px; }
.blkInput:focus { border-color: #fff; background: rgba(0, 0, 0, .5); }
.blkInput::placeholder { color: rgba(255, 255, 255, .4); }

.blkRemove {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .5);
  cursor: pointer;
  font-size: 11px;
  padding: 0 3px;
  border-radius: 4px;
}
.blkRemove:hover { color: #fff; background: rgba(0, 0, 0, .3); }

.blkBody {
  margin: 0 8px 7px 16px;
  padding-left: 9px;
  border-left: 3px solid rgba(255, 255, 255, .22);
}
.blkBodyLabel {
  font-size: 11px;
  opacity: .6;
  display: block;
  margin-bottom: 3px;
}

/* block colours by category */
.blk-io    { background: #2b4a6f; }
.blk-var   { background: #6b4a2b; }
.blk-ctrl  { background: #5a3a6b; }
.blk-fn    { background: #2b5f4a; }
.blk-list  { background: #5f2b4a; }
.paletteBlock.blk-io   { background: #2b4a6f; }
.paletteBlock.blk-var  { background: #6b4a2b; }
.paletteBlock.blk-ctrl { background: #5a3a6b; }
.paletteBlock.blk-fn   { background: #2b5f4a; }
.paletteBlock.blk-list { background: #5f2b4a; }

.blocksCode {
  flex: 0 0 auto;
  max-height: 34%;
  overflow: auto;
  padding: 8px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
}
.blocksCode .codeBlock { margin-top: 5px; max-height: 190px; overflow: auto; }

/* =========================================================
   SHARED ADDITIONS
========================================================= */
.btn-danger {
  background: #a83246;
  border-color: #c2475a;
  color: #fff;
}
.btn-danger:hover { background: #bb3c51; }
.hint { font-size: 11.5px; color: var(--ink-faint); line-height: 1.5; }
.btn.small.ai:not(.btn-primary) { color: var(--violet); border-color: rgba(167, 139, 250, .35); }
/* One row, always: wrapping would grow the card and squeeze the canvas on short screens. */
.graphSelectionActions { overflow-x: auto; scrollbar-width: none; }
.graphSelectionActions .btn { flex: 0 0 auto; }

/* ---- editor: issue tints and inline messages ---- */
.lineMarks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  font: var(--code-size) var(--mono);
  line-height: var(--code-line);
}
.lineMark {
  position: absolute;
  left: 0;
  right: 0;
  height: var(--code-line);
  background: rgba(96, 165, 250, .06);
  border-left: 2px solid transparent;
}
.lineMark.critical { background: rgba(251, 113, 133, .11); border-left-color: var(--sev-critical); }
.lineMark.high { background: rgba(251, 146, 60, .09); border-left-color: var(--sev-high); }
.lineMark.medium { background: rgba(251, 191, 36, .07); border-left-color: var(--sev-medium); }
.lineMark.low { background: rgba(96, 165, 250, .05); }
.lineMark.info { background: transparent; }
.lineMark.failed { background: rgba(248, 113, 113, .16); border-left-color: var(--danger); }
.lineLens {
  position: absolute;
  height: var(--code-line);
  max-width: 64ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre;
  font-size: var(--code-size);   /* `ch` in `left` must match the code's font */
  font-style: italic;
  color: var(--sev-low);
  opacity: .85;
}
.lineLens > span { font-size: 11.5px; }
.lineLens.critical { color: var(--sev-critical); }
.lineLens.high { color: var(--sev-high); }
.lineLens.medium { color: var(--sev-medium); }
.lineLens.info { color: var(--sev-info); }
.lineLens.failed { color: var(--danger); font-style: normal; font-weight: 700; }
.editorFootRight { display: inline-flex; align-items: center; gap: 10px; }
.footToggle {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.footToggle:hover { color: var(--ink); }
.footToggle[aria-pressed="true"] { color: var(--ink-dim); }

/* ---- insights: data paths and the risk list ---- */
.dataPath {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 2px 0 8px;
  font: 11px var(--mono);
}
.dataHop {
  color: var(--accent-2);
  background: var(--bg-0);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  cursor: pointer;
  text-decoration: none;
}
.dataHop:hover { border-color: var(--accent-2); }
.dataHop:last-child { color: var(--sev-critical); }
.dataArrow { color: var(--ink-faint); }

.riskList { display: grid; border-top: 1px solid var(--line-soft); margin-bottom: 6px; }
.riskRow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.riskRow:hover { background: var(--bg-2); }
.riskRank { font: 600 11px var(--mono); color: var(--ink-faint); width: 14px; text-align: right; }
.riskRow.critical .riskRank { color: var(--sev-critical); }
.riskRow.high .riskRank { color: var(--sev-high); }
.riskMain { flex: 1; min-width: 0; }
.riskName { font: 600 12px var(--mono); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riskWhy { font-size: 11.5px; color: var(--ink-dim); margin-top: 1px; }

/* ---- assistant ---- */
.aiDot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 4px;
  border-radius: 999px;
  vertical-align: middle;
  background: #3f4c63;
}
.aiDot[data-state="ready"] { background: var(--ok); }
.aiDot[data-state="connecting"] { background: var(--warn); }
.aiDot[data-state="down"], .aiDot[data-state="no-models"] { background: var(--danger); }

#dockAssistant { min-height: 0; }
.aiHead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  flex: 0 0 auto;
}
.aiStatus {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--ink-dim);
}
.aiStatus::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 999px;
  background: #3f4c63;
  vertical-align: 1px;
}
.aiStatus[data-state="ready"]::before { background: var(--ok); }
.aiStatus[data-state="connecting"]::before { background: var(--warn); }
.aiStatus[data-state="down"]::before, .aiStatus[data-state="no-models"]::before { background: var(--danger); }
.aiStatus[data-state="remote"]::before { background: var(--sev-high); }
#aiModel { max-width: 46%; font-size: 11px; }

.aiSettings {
  display: grid;
  gap: 7px;
  padding: 9px 10px 11px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  flex: 0 0 auto;
}
.aiSettings code { font-family: var(--mono); font-size: 10.5px; }
.aiSettingsRow { display: grid; grid-template-columns: 1fr 1.2fr; align-items: center; gap: 8px; }
.aiSettingsRow output { font-family: var(--mono); color: var(--ink); margin-left: 4px; }
.aiSettingsRow input[type="range"] { accent-color: var(--accent); width: 100%; }

.aiBanner {
  margin: 8px 10px 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  background: var(--bg-2);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.aiBanner[data-kind="warn"] { border-color: rgba(251, 146, 60, .5); background: rgba(251, 146, 60, .08); color: #fed7aa; }
.aiBanner strong { color: var(--ink); display: block; margin-bottom: 3px; }
.aiBanner[data-kind="warn"] strong { display: inline; }
.aiBanner ol { margin: 4px 0 6px; padding-left: 18px; }
.aiBanner code { font-family: var(--mono); font-size: 11px; background: var(--bg-0); padding: 1px 5px; border-radius: 4px; color: var(--accent-2); }

.aiNote { margin: 0 10px; padding: 6px 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-dim); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.aiNote progress { width: 100%; height: 4px; margin-top: 4px; accent-color: var(--accent); }
.aiAbstain { padding: 6px 8px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
.aiCites { margin: 0 0 8px; padding-left: 18px; font-size: 11.5px; }
.aiCites .hint { color: var(--ink-faint); }
.assistantModes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}
.assistantModes .check:has(input:checked) { color: var(--ink); }
.aiSourcePreview { margin: 8px 0 0; }
.aiSourcePreview pre { max-height: min(260px, 35vh); overflow: auto; white-space: pre; }
.aiSourceCaption { color: var(--ink-dim); font-size: 11px; }
.aiQuick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; flex: 0 0 auto; }

.aiThread { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 2px 10px 12px; }
.aiEmpty { color: var(--ink-faint); font-size: 12px; line-height: 1.6; padding: 6px 2px; }
.aiEmpty p { margin: 0 0 8px; }

.aiTurn { margin: 10px 0 14px; }
.aiAsk {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--bg-3);
  font-size: 12px;
}
.aiAskTitle { flex: 1; min-width: 0; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.linkBtn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 10.5px; cursor: pointer; white-space: nowrap; }
.linkBtn:hover { text-decoration: underline; }
.aiSent {
  margin: 6px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: var(--bg-0);
  color: var(--ink-faint);
  font: 10.5px/1.5 var(--mono);
  white-space: pre-wrap;
}
.aiReply { padding: 8px 2px 2px; font-size: 12.5px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; }
.aiReply p { margin: 0 0 8px; }
.aiReply ul { margin: 0 0 8px; padding-left: 18px; }
.aiReply li { margin: 2px 0; }
.aiReply code { font: 11.5px var(--mono); background: var(--bg-0); padding: 1px 4px; border-radius: 4px; color: var(--accent-2); }
.aiReply strong { color: #fff; }
.aiH { font-weight: 600; font-size: 12px; color: var(--ink); margin: 10px 0 4px; }
.aiWaiting, .aiChecking { color: var(--ink-faint); font-size: 11.5px; font-style: italic; }
.aiMeta { font-size: 10px; color: var(--ink-faint); margin-top: 2px; }
.aiTriage { display: grid; gap: 6px; }
.aiHypothesis, .aiProbe { display: grid; gap: 3px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg-0); }
.aiProbe code { white-space: pre-wrap; }

.aiCode { margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-0); }
.aiCodeHead { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 9px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.aiLang { flex: 1; font: 10px var(--mono); color: var(--ink-faint); text-transform: lowercase; }
.aiCodePre { margin: 0; padding: 8px 10px; overflow: auto; max-height: 360px; font: 11.5px/1.55 var(--mono); color: #cbd5e1; white-space: pre; }
.aiCheckHost:empty { display: none; }
.aiCheckHost { padding: 8px 9px; border-top: 1px solid var(--line); background: var(--bg-1); }
.aiCheck { display: grid; gap: 7px; }
.aiVerdict { font-weight: 700; font-size: 12px; }
.aiCheck.better .aiVerdict { color: var(--ok); }
.aiCheck.worse .aiVerdict { color: var(--danger); }
.aiCheck.same .aiVerdict { color: var(--ink-dim); }
.aiWarn { font-size: 11.5px; color: var(--warn); }
.aiIssues { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.aiIssue { display: flex; align-items: baseline; gap: 6px; font-size: 11.5px; color: var(--ink-dim); }
.aiIssue .sevTag { flex: 0 0 auto; font-size: 11px; font-weight: 600; color: var(--sev-info); }
.aiIssue.critical .sevTag { color: var(--sev-critical); }
.aiIssue.high .sevTag { color: var(--sev-high); }
.aiIssue.medium .sevTag { color: var(--sev-medium); }
.aiIssue.low .sevTag { color: var(--sev-low); }
.aiMark { font-weight: 800; width: 10px; }
.aiIssue.introduced .aiMark { color: var(--danger); }
.aiIssue.resolved .aiMark { color: var(--ok); }
.aiDiff summary { cursor: pointer; font-size: 11px; color: var(--ink-dim); }
.aiDiff pre { margin: 6px 0 0; max-height: 260px; overflow: auto; padding: 6px 0; background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px; font: 11px/1.5 var(--mono); }
.aiDiff pre div { padding: 0 9px; white-space: pre; }
.diff-add { background: rgba(52, 211, 153, .1); color: #a7f3d0; }
.diff-del { background: rgba(248, 113, 113, .1); color: #fecaca; }

/* The extract-class card. Its left accent is the state the card is in, so a reader can
   tell "nothing to click" from "checked and appliable" without reading the sentences. */
.splitBox {
  display: grid; gap: 6px; margin: 10px 0 0; padding: 9px 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--ink-faint);
  border-radius: 8px; background: var(--bg-1);
}
.splitHead { font-weight: 700; font-size: 12px; color: var(--ink); }
.splitLine { font-size: 11.5px; line-height: 1.5; color: var(--ink-dim); }
.splitHost:empty { display: none; }
.splitCode {
  margin: 0; padding: 8px 10px; max-height: 300px; overflow: auto;
  background: var(--bg-0); border: 1px solid var(--line); border-radius: 6px;
  font: 11px/1.5 var(--mono); color: #cbd5e1; white-space: pre;
}
.split-refused { border-left-color: var(--ink-faint); }
.split-preview { border-left-color: var(--ink-dim); }
.split-same { border-left-color: var(--ink-dim); }
.split-better { border-left-color: var(--ok); }
.split-worse { border-left-color: var(--danger); }
.split-blocked { border-left-color: var(--danger); }
.split-applied { border-left-color: var(--ok); }
.split-better .splitHead, .split-applied .splitHead { color: var(--ok); }
.split-worse .splitHead, .split-blocked .splitHead { color: var(--danger); }
.diff-same { color: var(--ink-faint); }

.aiComposer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  /* Keep Send and Stop clear of the fixed Guide at the lower right. */
  padding: 8px 84px 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--bg-1);
  flex: 0 0 auto;
}
#aiInput {
  flex: 1;
  min-height: 38px;
  max-height: 140px;
  resize: vertical;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-0);
  font-size: 12.5px;
  line-height: 1.45;
  outline: none;
}
#aiInput:focus { border-color: var(--accent); }

@media (max-width: 640px) {
  .lineLens { display: none; }
  #aiModel { max-width: 40%; }
  .aiQuick .btn { flex: 1 1 auto; justify-content: center; }
}

/* =========================================================
   Data panel — one function as a white box
   Lanes stay neutral; colour means something: inputs are blue,
   object state is violet, the selected variable is amber, and
   severities keep their own colours.
========================================================= */
:root {
  --lane: #3a4860;
  --lane-mark: #8796ae;
  --lane-param: #7dd3fc;
  --lane-attr: #c4b5fd;
  --lane-sel: #fbbf24;
  --lane-sel-bg: rgba(251, 191, 36, .13);
}

.dataHead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.dataHead select { flex: 1; min-width: 0; width: 0; font-size: 11.5px; }
.dataScroll { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 16px; }
#dataIntro { padding-top: 10px; }

.dataSig { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.dataSigText { font-family: var(--mono); font-size: 12.5px; color: var(--ink); overflow-wrap: anywhere; }
.dataLoc { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-faint); cursor: pointer; white-space: nowrap; }
.dataLoc:hover { color: var(--accent); }

.dataSummary { list-style: none; margin: 0 0 12px; padding: 0; font-size: 12px; line-height: 1.65; color: var(--ink-dim); }
.dataSummary code { font-family: var(--mono); font-size: 11.5px; color: var(--ink); }

.varRef {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ink);
  background: var(--bg-3);
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0 3px;
  cursor: pointer;
}
.varRef:hover { border-color: var(--line); }
.varRef.param { color: var(--lane-param); }
.varRef.attr { color: var(--lane-attr); }
.varRef.quiet { background: none; padding: 0; border: 0; text-decoration: underline dotted var(--ink-faint); text-underline-offset: 3px; }
.varRef.sel, .varRef.quiet.sel { background: var(--lane-sel-bg); color: var(--lane-sel); border-color: transparent; text-decoration: none; padding: 0 3px; }

.dataRun { display: grid; gap: 5px; margin: 0 0 12px; }
.dataRunLabel { font-size: 11px; color: var(--ink-faint); }
.dataRunStatus { min-height: 1.2em; font-family: var(--mono); font-size: 11px; color: var(--ink-dim); overflow-wrap: anywhere; }
.dataRunStatus[data-state="failed"] { color: var(--danger); }
.dataRunStatus[data-state="busy"] { color: var(--warn); }

/* ---- the step grid ---- */
.flowGrid { font-size: 12px; outline: none; }
.flowGrid:focus-visible { box-shadow: 0 0 0 1px var(--accent); }
.flowRow {
  --row-bg: var(--bg-1);
  display: grid;
  grid-template-columns: var(--flow-cols);
  align-items: center;
  height: 24px;
  background: var(--row-bg);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  position: relative;
}
.flowRow:hover { --row-bg: var(--bg-2); }
.flowRow.sel { --row-bg: var(--bg-3); }
.flowHeader {
  height: auto;
  align-items: end;
  cursor: default;
  border-bottom-color: var(--line);
  position: sticky;
  top: 0;
  z-index: 1;
  padding-top: 6px;
}
.flowHeader:hover { --row-bg: var(--bg-1); }
.flowHeader .flowLine, .flowStepHead, .flowValueHead { font-size: 10.5px; color: var(--ink-faint); padding-bottom: 3px; }
.flowStepHead { padding-left: 6px; }
.flowValueHead { padding-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.laneNames { display: flex; align-items: flex-end; }
.laneName {
  width: 12px;
  max-height: 96px;
  padding: 0 0 3px;
  border: 0;
  background: none;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 12px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.laneName:hover { color: var(--ink); }
.laneName.param { color: var(--lane-param); }
.laneName.attr { color: var(--lane-attr); }
.laneName.sel { color: var(--lane-sel); }

.flowLine {
  position: relative;
  padding-right: 8px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}
.flowRow.atCursor .flowLine { color: var(--ink); font-weight: 700; }
.issueDot { position: absolute; left: 3px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--sev-info); }
.issueDot.critical { background: var(--sev-critical); }
.issueDot.high { background: var(--sev-high); }
.issueDot.medium { background: var(--sev-medium); }
.issueDot.low { background: var(--sev-low); }

.flowRow svg { display: block; overflow: visible; }
.lane line.live { stroke: var(--lane); stroke-width: 1.5; }
.lane .bind, .lane .change { fill: var(--lane-mark); }
.lane .read { fill: var(--row-bg); stroke: var(--lane-mark); stroke-width: 1.4; }
.lane .ring { fill: var(--row-bg); stroke: var(--lane-mark); stroke-width: 1.2; }
.lane.param .bind, .lane.param .change { fill: var(--lane-param); }
.lane.param .read, .lane.param .ring { stroke: var(--lane-param); }
.lane.attr .bind, .lane.attr .change { fill: var(--lane-attr); }
.lane.attr .read, .lane.attr .ring { stroke: var(--lane-attr); }
.lane.sel line.live { stroke: var(--lane-sel); stroke-width: 2; }
.lane.sel .bind, .lane.sel .change { fill: var(--lane-sel); }
.lane.sel .read, .lane.sel .ring { stroke: var(--lane-sel); }
.lane.dim { opacity: .25; }

.flowStep {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  height: 100%;
  padding: 0 8px 0 6px;
  overflow: hidden;
  white-space: nowrap;
}
.flowStep .indent {
  flex: 0 0 auto;
  align-self: stretch;
  background: repeating-linear-gradient(to right, var(--line) 0 1px, transparent 1px 12px);
}
.flowStep .kw { flex: 0 0 auto; color: var(--ink-faint); }
.kind-if .kw, .kind-elif .kw, .kind-for .kw, .kind-while .kw, .kind-try .kw,
.kind-except .kw, .kind-with .kw, .kind-match .kw, .kind-case .kw { color: var(--ink-dim); font-weight: 600; }
.kind-return .kw { color: var(--ok); }
.kind-raise .kw { color: var(--danger); }
.kind-else .kw, .kind-finally .kw { font-style: italic; }
.kind-def .kw { color: var(--ink-dim); }
.flowStep .varRef { flex: 0 0 auto; }
.flowStep .sep { margin-left: -4px; color: var(--ink-faint); }
code.expr { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); font-size: 11.5px; color: var(--ink); }
.exprVar { cursor: pointer; border-radius: 2px; }
.exprVar:hover { text-decoration: underline; }
.exprVar.sel { color: var(--lane-sel); background: var(--lane-sel-bg); }

.flowValue {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  height: 100%;
  padding: 0 8px;
  border-left: 1px solid var(--line-soft);
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-dim);
}
.flowValue .valueText { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.flowValue .hits { flex: 0 0 auto; color: var(--ink-faint); }
.flowValue.notRun { font-family: var(--ui); font-style: italic; color: var(--ink-faint); }
.flowValue.untraced { font-family: var(--ui); font-style: italic; color: var(--ink-faint); }
.flowValue.raised { color: var(--danger); }
.flowValue.returned { color: var(--ok); }

.flowRow.notRun .flowStep, .flowRow.notRun svg { opacity: .38; }
.flowRow.faded .flowStep, .flowRow.faded .flowValue { opacity: .32; }
.flowRow.failed { box-shadow: inset 2px 0 0 var(--danger); }
.flowRow.unreachable .flowStep { opacity: .45; text-decoration: line-through; text-decoration-color: var(--ink-faint); }
.flowRow.job::after { content: ""; position: absolute; right: 0; top: 3px; bottom: 3px; width: 2px; border-radius: 1px; }
.flowRow.job0::after { background: #60a5fa; }
.flowRow.job1::after { background: #f472b6; }
.flowRow.job2::after { background: #34d399; }

.flowLegend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 0 0 34px; font-size: 11px; color: var(--ink-faint); }
.flowLegend span { display: inline-flex; align-items: center; gap: 4px; }
.flowLegend svg { --row-bg: var(--bg-1); }
#dataGrid > .linkBtn { margin: 6px 0 0 34px; font-size: 11px; }

/* ---- what leaves, and what is wrong ---- */
.dataSection { margin: 18px 0 6px; font-size: 12px; font-weight: 600; color: var(--ink); }
.outRow { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 8px; font-size: 12px; line-height: 1.75; color: var(--ink-dim); }
.outLabel { color: var(--ink-faint); }
.dataStdout {
  margin: 0; padding: 8px 10px;
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 7px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 260px; overflow: auto;
}
.lineLink { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); cursor: pointer; white-space: nowrap; }
.lineLink:hover { color: var(--accent); text-decoration: underline; }
.dataIssues { display: grid; }
.dataIssue {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
  padding: 5px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  font: inherit;
  font-size: 12px;
  text-align: left;
  color: var(--ink-dim);
  cursor: pointer;
}
.dataIssue:hover { color: var(--ink); }
.dataIssueTitle code { font-family: var(--mono); font-size: 11.5px; }
.dataIssueLine { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.sevWord { font-size: 11px; font-weight: 600; }
.sevWord.critical { color: var(--sev-critical); }
.sevWord.high { color: var(--sev-high); }
.sevWord.medium { color: var(--sev-medium); }
.sevWord.low { color: var(--sev-low); }
.sevWord.info { color: var(--sev-info); }

/* ---- details for the selection ---- */
.dataDetail {
  flex: 0 0 auto;
  max-height: 45%;
  overflow: auto;
  position: relative;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 12px;
}
.detailClose { position: absolute; top: 6px; right: 6px; }
.detailTitle { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; padding-right: 28px; font-weight: 600; }
.detailCode { font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--ink-dim); overflow-wrap: anywhere; }
.detailRow { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; line-height: 1.75; }
.detailLabel { color: var(--ink-faint); }
.detailValue { min-width: 0; color: var(--ink-dim); overflow-wrap: anywhere; }
.muted { color: var(--ink-faint); }
.warnText { color: var(--warn); }
.callLink { font-family: var(--mono); color: var(--accent); cursor: pointer; }
.callLink:hover { text-decoration: underline; }
.history, .passLine { font-family: var(--mono); font-size: 11px; color: var(--ink); }

/* ---- the editor side of a selection ---- */
.lineMark.flowSlice { background: rgba(251, 191, 36, .06); border-left-color: rgba(251, 191, 36, .5); }
.lineMark.flowCurrent { background: rgba(251, 191, 36, .14); border-left-color: var(--lane-sel); }

/* =========================================================
   Corner guide (ui/copilot.js)
========================================================= */
.copilot {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 88;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.copilotFab {
  height: 30px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-dim);
  font: 600 11.5px var(--ui);
  cursor: pointer;
}
.copilotFab:hover { color: var(--ink); border-color: var(--accent); }

.copilotPanel {
  width: min(360px, calc(100vw - 28px));
  max-height: min(62vh, 480px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* display:flex above is beaten only by the global [hidden] rule at the top of
   this file; keep the two together or the panel stays as an invisible sheet. */
.copilotPanel[hidden] { display: none; }

.copilotHead {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 9px 10px 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.copilotHeadText { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.copilotTitle { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.copilotSub { font-size: 11px; color: var(--ink-faint); }

.copilotBody {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.copilotLog { display: flex; flex-direction: column; gap: 4px; }
.copilotLog:empty { display: none; }
.copilotLine {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-dim);
  border-left: 2px solid var(--line);
  padding-left: 8px;
  overflow-wrap: anywhere;
}
.copilotLine.asked { color: var(--ink); border-left-color: var(--accent); }
.copilotLine.warn { color: var(--warn); border-left-color: var(--warn); }

.copilotSteps { display: flex; flex-direction: column; }
.copilotStep {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
}
.copilotStep:first-child { border-top: 0; padding-top: 0; }
.copilotStepText { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.copilotStepTitle { font-size: 12px; font-weight: 600; color: var(--ink); }
.copilotStepWhy { font-size: 11px; line-height: 1.45; color: var(--ink-faint); overflow-wrap: anywhere; }
.copilotStepBtn { flex: 0 0 auto; white-space: nowrap; }
.copilotStep.done .copilotStepTitle { color: var(--ink-faint); }
.copilotStep.done .copilotStepTitle::after {
  content: " · done";
  color: var(--ok);
  font-weight: 500;
  font-size: 10.5px;
}
.copilotEmpty { margin: 0; font-size: 11.5px; color: var(--ink-faint); }

.copilotAsk { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line-soft); }
.copilotAsk button { flex: 0 0 auto; }
.copilotInput {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-0);
  color: var(--ink);
  font: 12px var(--ui);
}
.copilotInput:focus { outline: none; border-color: var(--accent); }

.copilotSuggest { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 10px 8px; }
.copilotSuggest .chip {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-faint);
  font: 10.5px var(--ui);
  padding: 2px 7px;
  border-radius: 999px;
}
.copilotSuggest .chip:hover { color: var(--ink); border-color: var(--accent); }

.copilotMcp {
  padding: 6px 12px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-faint);
  max-height: 180px;
  overflow: auto;
}
.copilotMcp summary { cursor: pointer; }
.copilotMcp p { margin: 6px 0 2px; }
.copilotMcp pre { margin: 2px 0; padding: 6px; overflow-x: auto; user-select: all; }

.copilotNote {
  margin: 0;
  padding: 7px 12px 9px;
  border-top: 1px solid var(--line-soft);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--ink-faint);
}

/* Toasts announce where hidden findings went, so they keep the corner and the
   guide sits above them: the launcher would otherwise be under a toast. */
/* Toasts share the bottom-right corner: lift them past the pill, and past the
   whole panel when it is open, so a message never lands on the line the guide
   has just written. */
body.hasCopilot .toasts { bottom: 56px; }
body.copilotOpen .toasts { bottom: calc(min(62vh, 480px) + 56px); }

@media (max-width: 700px) {
  .copilotSub, .copilotNote { display: none; }
}

/* ---- change impact (the Impact dock tab) ---- */
.impactHead {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.impactHead select { flex: 1; min-width: 0; width: 0; font-size: 11.5px; }
.impactScroll { flex: 1; min-height: 0; overflow: auto; padding: 0 12px 16px; }
#impactIntro { padding-top: 10px; }
.impactLead { font-size: 12px; line-height: 1.6; color: var(--ink-dim); margin: 0 0 10px; }

.impactTarget {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 9px;
  margin-bottom: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
}
.impactTargetName {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  overflow-wrap: anywhere;
}
.impactTargetName:hover { color: var(--accent); }
.impactTargetFile, .impactTargetFan { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.impactTargetFan { margin-left: auto; white-space: nowrap; }

/* The tally is the sentence that says how much of what is below is inferred. Warn, not
   danger: an inferred caller is a real possibility, not a mistake. */
.impactTally { font-size: 11.5px; line-height: 1.55; color: var(--warn); margin: 0 0 8px; }
.impactTally:empty { display: none; }

.impactDepth {
  font-size: 10.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 12px 0 4px;
}

.impactRow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  margin-bottom: 3px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}
.impactRow:hover { background: var(--bg-2); border-color: var(--line-soft); }
.impactRow.module .impactName { font-style: italic; color: var(--ink-dim); }
.impactName { font-family: var(--mono); font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.impactFile { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); overflow-wrap: anywhere; }
.impactWhere { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.impactFan { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); grid-row: 1; justify-self: end; white-space: nowrap; }
.impactGuess, .impactCut {
  grid-column: 1 / -1;
  font-size: 11px;
  line-height: 1.5;
  color: var(--warn);
  overflow-wrap: anywhere;
}
.impactCut { color: var(--ink-faint); }
.impactRow .impactGuess::before { content: "◦ "; }

#impactLimits, #impactProbes { margin-top: 12px; }
.impactLimit, .impactProbeLine {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  padding-left: 9px;
  border-left: 2px solid var(--line);
  margin-bottom: 5px;
  overflow-wrap: anywhere;
}
.impactCases {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 8px;
  margin-bottom: 4px;
  background: var(--bg-2);
  border-radius: 4px;
}
.impactCasesName {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
}
button.impactCasesName:hover { color: var(--accent); }
.impactCasesArgs { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); overflow-wrap: anywhere; }


.aiTools { margin-top: 6px; font-size: 11px; color: var(--ink-faint); }
.aiTools summary { cursor: pointer; }
.aiTools ul { margin: 4px 0 0; padding-left: 18px; }
.aiTools li { font: 11px var(--mono); margin: 1px 0; overflow-wrap: anywhere; }

.aiSources { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.aiSources h3 { margin: 0 0 6px; font-size: 13px; }
.aiSources ul { margin: 0; padding-left: 18px; }
.aiSources li + li { margin-top: 8px; }
.aiSources p { margin: 3px 0; }
