/* Memory view (#1154, js/views/memory/): the status strip, the toolbar (search, summary, More, zoom), the graph pane
   (one SVG, pan and zoom by a transform) and the side panel (search hits, the selected blob). */
.memory-view {
  --mem-keyword: #58a6ff;
  --mem-phrase: #a371f7;
  --mem-text: #3fb950;
  --mem-endpoint: #f0883e;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.memory-status,
.memory-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  flex: none;
  font-size: 12px;
  color: var(--muted);
}
.memory-lock.held { color: var(--warn); }
.memory-params { position: relative; }
.memory-params summary { cursor: pointer; }
.memory-params-list {
  position: absolute;
  z-index: 5;
  margin: 4px 0 0;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.memory-params-list dt { color: var(--muted); }
.memory-params-list dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; }

.memory-search { display: inline-flex; align-items: center; gap: 6px; }
.memory-search-input { width: 220px; }
.memory-search-btn.running { border-color: var(--warn); color: var(--warn); }
.memory-summary { flex: 1; min-width: 160px; }
.memory-zoom { display: inline-flex; gap: 2px; }
.memory-zoom-btn.active { border-color: var(--accent); color: var(--accent); }

.memory-main { flex: 1; min-height: 0; display: flex; gap: 8px; }
.memory-pane {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: grab;
  touch-action: none;
}
.memory-pane.panning { cursor: grabbing; user-select: none; }
.memory-svg { display: block; width: 100%; height: 100%; }
.memory-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.memory-empty[hidden] { display: none; }

/* links: width and opacity by weight (inline); the selected blob's stand out, the rest fade */
.memory-link { stroke: var(--muted); stroke-linecap: round; }
.memory-view.highlighting .memory-link:not(.hl) { stroke-opacity: 0.08; }
.memory-link.hl { stroke: var(--accent); stroke-opacity: 0.9; }
.memory-link.hover { stroke: var(--text); stroke-opacity: 1; stroke-width: 4px; }
.memory-link.rerouted { stroke: var(--warn); stroke-opacity: 0.95; stroke-dasharray: 6 3; }
.memory-spoke { stroke: var(--mem-endpoint); stroke-width: 1.2; stroke-dasharray: 3 4; stroke-opacity: 0.8; }
.memory-link.flash { animation: memory-flash 1.2s ease-out; }
@keyframes memory-flash {
  0%, 40% { stroke: #fff; stroke-width: 6px; stroke-opacity: 1; }
  100% { stroke: var(--accent); }
}

/* nodes: area by reads (the radius, inline), colour by kind; a ghost is a search hit outside the loaded graph */
.memory-node { cursor: pointer; stroke: var(--bg); stroke-width: 1; }
.memory-node.kind-keyword { fill: var(--mem-keyword); }
.memory-node.kind-phrase { fill: var(--mem-phrase); }
.memory-node.kind-text { fill: var(--mem-text); }
.memory-node.ghost { fill-opacity: 0.25; stroke: var(--text); stroke-dasharray: 2 2; }
.memory-view.highlighting .memory-node:not(.sel):not(.related):not(.hit) { opacity: 0.35; }
.memory-node.related { stroke: var(--accent); stroke-width: 2; }
.memory-node.hit { stroke: var(--warn); stroke-width: 3; }
.memory-node.hover { stroke: var(--text); stroke-width: 3; }
.memory-node.sel { stroke: #fff; stroke-width: 3; }
.memory-label { fill: var(--muted); font-size: 10px; text-anchor: middle; pointer-events: none; }
.memory-hub { cursor: pointer; }
.memory-hub rect { fill: var(--panel); stroke: var(--mem-endpoint); stroke-width: 2; }
.memory-hub text { fill: var(--mem-endpoint); font-size: 11px; font-weight: 600; }
.memory-hub.sel rect { fill: var(--mem-endpoint); }
.memory-hub.sel text { fill: var(--bg); }

/* the side panel */
.memory-side {
  flex: none;
  width: 360px;
  max-width: 45%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
.memory-search-results,
.memory-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 8px 10px;
}
.memory-search-results[hidden] { display: none; }
.memory-search-status { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.memory-search-status[data-state="failed"] { color: var(--danger); }
.memory-hit-list,
.memory-link-list,
.memory-reach-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.memory-hit,
.memory-link-row,
.memory-reach-row {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 4px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.memory-hit:hover,
.memory-link-row:hover,
.memory-link-row:focus-visible,
.memory-reach-row:hover,
.memory-reach-row:focus-visible { background: var(--border-soft); }
.memory-hit-preview,
.memory-link-preview,
.memory-reach-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memory-hit-rank,
.memory-link-weight,
.memory-link-traversals,
.memory-reach-heat { flex: none; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.memory-kind {
  flex: none;
  font-size: 10px;
  padding: 0 5px;
  border-radius: 8px;
  border: 1px solid currentColor;
}
.memory-kind.kind-keyword { color: var(--mem-keyword); }
.memory-kind.kind-phrase { color: var(--mem-phrase); }
.memory-kind.kind-text { color: var(--mem-text); }
.memory-kind.kind-endpoint { color: var(--mem-endpoint); }

.memory-panel-head { display: flex; align-items: center; gap: 8px; }
.memory-panel-title { flex: 1; font-weight: 600; }
.memory-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin: 6px 0; font-size: 12px; }
.memory-crumb { border: 0; background: none; color: var(--accent); padding: 0; font: inherit; cursor: pointer; }
.memory-crumb.current { color: var(--text); cursor: default; }
.memory-crumb-sep { color: var(--muted); }
.memory-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 6px 8px;
  margin: 6px 0;
  max-height: 240px;
  overflow-y: auto;
}
.memory-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; font-size: 12px; }
.memory-meta dt { color: var(--muted); }
.memory-meta dd { margin: 0; overflow-wrap: anywhere; }
.memory-links-head { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.memory-reach-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.memory-reach-status { flex: 1; min-width: 0; }
.memory-panel-actions { margin-top: 8px; text-align: right; }
.memory-notice { color: var(--warn); font-size: 12px; margin-bottom: 6px; }
.memory-hint { color: var(--muted); }

@media (max-width: 760px) {
  .memory-main { flex-direction: column; }
  .memory-side { width: auto; max-width: none; max-height: 45%; }
}
