humemory 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.3] - 2026-08-17
4
+ **Features:**
5
+ - add Streamable HTTP transport and security hardening
6
+
7
+
8
+
3
9
  ## [0.2.2] - 2026-08-15
4
10
  **Features:**
5
11
  - add async multi-agent session capture
@@ -154,10 +154,12 @@ function renderMarkdown(input) {
154
154
  // per-step id of its own.
155
155
  if (desc.escapedMarkers > 0)
156
156
  escapeAttempts.push({ memoryId: script.id, count: desc.escapedMarkers });
157
- lines.push(`> ${oneLine(desc.text)}`);
158
157
  // Same injection rules as traces (6.0.3): human-authored renders bare,
159
- // agent/dreamer-authored stays wrapped.
158
+ // agent/dreamer-authored stays wrapped. The description used to render
159
+ // bare unconditionally while the steps below were correctly gated
160
+ // (SECURITY_AUDIT.md H-03) — both now share the same `bare` check.
160
161
  const bare = script.source === 'human';
162
+ lines.push(`> ${bare ? oneLine(desc.text) : wrapUntrusted(oneLine(desc.text), { source: script.source, agent: script.agent, id: script.id })}`);
161
163
  script.steps.slice(0, SCRIPT_STEP_CAP).forEach((step, i) => {
162
164
  const s = sanitizeTrace(step);
163
165
  if (s.escapedMarkers > 0)
@@ -171,11 +173,20 @@ function renderMarkdown(input) {
171
173
  lines.push(`_… ${script.steps.length - SCRIPT_STEP_CAP} more steps — \`pnpm cli script fire ${script.id.slice(0, 8)}\` for the full drill._`);
172
174
  }
173
175
  }
176
+ // Intentions carry the same provenance shape as memories (6.0.1) but used to
177
+ // render bare unconditionally regardless of it (SECURITY_AUDIT.md H-03).
178
+ // Only a human-verified loop skips the untrusted wrapper now.
179
+ const renderIntentionBody = (i, s) => {
180
+ const bare = i.verified === true && i.verificationReason === 'human';
181
+ return bare
182
+ ? oneLine(s.text)
183
+ : wrapUntrusted(oneLine(s.text), { source: i.source, agent: i.agent, verified: i.verified, id: i.id });
184
+ };
174
185
  if (firedNow.length) {
175
186
  lines.push('', '### ⏰ Deadlines reached', RECALLED_NOTES_PREFACE);
176
187
  for (const i of firedNow) {
177
188
  const s = sanitizeTrace(i.content);
178
- lines.push(`- **[${loopId(i.id)}]** ${oneLine(s.text)}`);
189
+ lines.push(`- **[${loopId(i.id)}]** ${renderIntentionBody(i, s)}`);
179
190
  }
180
191
  }
181
192
  if (openLoops.length) {
@@ -186,7 +197,7 @@ function renderMarkdown(input) {
186
197
  ? ` — due in ${humanizeAge(now, i.expiresAt).replace(' ago', '')}`
187
198
  : '';
188
199
  const s = sanitizeTrace(i.content);
189
- lines.push(`- **[${loopId(i.id)}]** ${oneLine(s.text)} (armed ${age}${deadline})`);
200
+ lines.push(`- **[${loopId(i.id)}]** ${renderIntentionBody(i, s)} (armed ${age}${deadline})`);
190
201
  }
191
202
  lines.push('', `_To close a loop: mention \`Closes ${loopId(openLoops[0].id)}\` in a commit message._`);
192
203
  }
@@ -39,6 +39,7 @@ import { createScriptRoutes } from './scripts-routes.js';
39
39
  import { join, dirname, resolve, sep } from 'path';
40
40
  import { fileURLToPath } from 'url';
41
41
  import { readFileSync } from 'fs';
42
+ import { timingSafeEqual } from 'crypto';
42
43
  const __filename = fileURLToPath(import.meta.url);
43
44
  const __dirname = dirname(__filename);
44
45
  /**
@@ -72,6 +73,35 @@ app.use('*', cors({
72
73
  credentials: true,
73
74
  maxAge: 600,
74
75
  }));
76
+ // === AUTH (SECURITY_AUDIT.md H-01) ===
77
+ // HUMEMORY_API_TOKEN, when set, is required (Bearer or x-humemory-token) on every
78
+ // data/mutation route. Static dashboard assets and /health stay open so the front
79
+ // end can load; the front end then attaches the token to its own API calls.
80
+ const API_TOKEN = process.env.HUMEMORY_API_TOKEN;
81
+ const PUBLIC_PATHS = new Set(['/health']);
82
+ function isPublicPath(path) {
83
+ return PUBLIC_PATHS.has(path) || path === '/' || path === '/app' || path === '/session' || path.startsWith('/app/');
84
+ }
85
+ function tokenMatches(supplied, expected) {
86
+ if (!supplied)
87
+ return false;
88
+ const a = Buffer.from(supplied);
89
+ const b = Buffer.from(expected);
90
+ // Constant-time compare requires equal length; a length check alone leaks
91
+ // little (token lengths aren't secret), and avoids throwing on mismatch.
92
+ return a.length === b.length && timingSafeEqual(a, b);
93
+ }
94
+ app.use('*', async (c, next) => {
95
+ if (!API_TOKEN || isPublicPath(c.req.path))
96
+ return next();
97
+ const header = c.req.header('authorization');
98
+ const bearer = header?.startsWith('Bearer ') ? header.slice(7) : undefined;
99
+ const supplied = bearer ?? c.req.header('x-humemory-token');
100
+ if (!tokenMatches(supplied, API_TOKEN)) {
101
+ return c.json({ error: 'Unauthorized' }, 401);
102
+ }
103
+ return next();
104
+ });
75
105
  // Static files (dashboard)
76
106
  const APP_DIR = join(PUBLIC_DIR, 'app');
77
107
  /**
@@ -151,7 +181,20 @@ export { app };
151
181
  // raise a server or seize the port.
152
182
  if (import.meta.main) {
153
183
  const port = parseInt(process.env.PORT || '3456');
154
- console.log(`🧠 humemory API running on http://localhost:${port}`);
155
- console.log(`📊 Dashboard: http://localhost:${port}/`);
156
- serve({ fetch: app.fetch, port });
184
+ // Default loopback-only (SECURITY_AUDIT.md H-01): the previous code passed no
185
+ // hostname, which node-server forwards straight to server.listen(), binding
186
+ // every interface while the log line still claimed "localhost".
187
+ const hostname = process.env.HUMEMORY_HOST || '127.0.0.1';
188
+ const isLoopback = hostname === '127.0.0.1' || hostname === 'localhost' || hostname === '::1';
189
+ if (!isLoopback && !API_TOKEN) {
190
+ console.error(`Refusing to start: HUMEMORY_HOST=${hostname} exposes the API beyond loopback ` +
191
+ `without HUMEMORY_API_TOKEN set. Set a token or unset HUMEMORY_HOST.`);
192
+ process.exit(1);
193
+ }
194
+ console.log(`🧠 humemory API running on http://${hostname}:${port}`);
195
+ console.log(`📊 Dashboard: http://${hostname}:${port}/`);
196
+ if (!API_TOKEN) {
197
+ console.warn('⚠️ HUMEMORY_API_TOKEN not set — data routes are unauthenticated (loopback only).');
198
+ }
199
+ serve({ fetch: app.fetch, port, hostname });
157
200
  }
@@ -24,7 +24,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
24
24
  import { z } from 'zod';
25
25
  import { SQLiteStore } from '../store/sqlite.js';
26
26
  import { trustScore } from '../core/trust.js';
27
- import { sanitizeTrace } from '../core/sanitize.js';
27
+ import { sanitizeTrace, wrapUntrusted } from '../core/sanitize.js';
28
28
  const store = new SQLiteStore(process.env.HUMEMORY_DB);
29
29
  /**
30
30
  * This process's agent identity. Not overridable per call — see the header.
@@ -120,7 +120,11 @@ server.registerTool('humemory_intent_add', {
120
120
  source: 'agent',
121
121
  agent: callingAgent,
122
122
  }, cues);
123
- return { content: [{ type: 'text', text: `loop armed: ${i.id}\n${i.content}` }] };
123
+ // Echoes the caller's own content back into the tool result, which lands
124
+ // in the agent's context like any other tool output — sanitized the same
125
+ // way a recalled trace would be (SECURITY_AUDIT.md H-03).
126
+ const s = sanitizeTrace(i.content);
127
+ return { content: [{ type: 'text', text: `loop armed: ${i.id}\n${s.text}` }] };
124
128
  });
125
129
  server.registerTool('humemory_intent_close', {
126
130
  description: 'Close an open loop by id (or short loop-XXXX id)',
@@ -144,12 +148,18 @@ server.registerTool('humemory_dreams', {
144
148
  const pending = await store.listDreamProposals({ status: 'pending' });
145
149
  if (!pending.length)
146
150
  return { content: [{ type: 'text', text: 'no dream pending' }] };
151
+ // Dream proposals are synthesized cross-session patterns, never
152
+ // human-verified at this stage — wrapped like any other unverified
153
+ // recalled content (SECURITY_AUDIT.md H-03), not returned raw.
147
154
  return {
148
155
  content: [
149
156
  {
150
157
  type: 'text',
151
158
  text: pending
152
- .map((p) => `[${p.kind}] ${p.id} — confidence ${p.confidence}\n${p.payload.slice(0, 400)}`)
159
+ .map((p) => {
160
+ const s = sanitizeTrace(p.payload.slice(0, 400));
161
+ return `[${p.kind}] ${p.id} — confidence ${p.confidence}\n${wrapUntrusted(s.text, { id: p.id })}`;
162
+ })
153
163
  .join('\n---\n'),
154
164
  },
155
165
  ],
@@ -1276,6 +1276,7 @@ export class SQLiteStore {
1276
1276
  source: intention.source ?? 'agent',
1277
1277
  agent: intention.agent,
1278
1278
  verified: intention.verified ?? false,
1279
+ verificationReason: intention.verificationReason,
1279
1280
  device: intention.device ?? this.deviceId,
1280
1281
  };
1281
1282
  await this.enqueueWriteWithLock(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "humemory",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Memory for AI agents that forgets like a human — decaying traces, inverse search, and prospective loops that resurface on a cue",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -52,13 +52,13 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@anthropic-ai/sdk": "^0.92.0",
55
- "@hono/node-server": "^2.0.0",
55
+ "@hono/node-server": "^2.1.1",
56
56
  "@huggingface/transformers": "^4.2.0",
57
57
  "@modelcontextprotocol/sdk": "^1.30.0",
58
58
  "commander": "^12.0.0",
59
59
  "d3": "^7.9.0",
60
60
  "flexsearch": "^0.7.43",
61
- "hono": "^4.0.0",
61
+ "hono": "^4.13.2",
62
62
  "react": "^19.2.8",
63
63
  "react-dom": "^19.2.8",
64
64
  "three": "^0.184.0",
@@ -74,8 +74,8 @@
74
74
  "@types/react-dom": "^19.2.4",
75
75
  "@types/three": "^0.185.3",
76
76
  "bun-types": "^1.3.13",
77
- "js-yaml": "^5.1.0",
78
- "tsx": "^4.7.0",
77
+ "js-yaml": "^5.3.0",
78
+ "tsx": "^4.23.12",
79
79
  "typescript": "^5.4.0"
80
80
  },
81
81
  "scripts": {
@@ -1,4 +1,4 @@
1
- import{h as J,i as b,j as A,k as B,l as N,m as P,n as U,o as j,s as x}from"./index-epqg22cp.js";import{t as T,u as R,v as V}from"./index-gbfwa9vq.js";import{B as $}from"./index-kvhc17mz.js";function C(_={}){return async function(y){y.innerHTML="";let{memories:D}=await $.listMemories({limit:500}),F=y.clientWidth||1200,G=700,W=J(y).append("svg").attr("width",F).attr("height",G),K=document.createElement("div");K.className="galaxy-legend",K.innerHTML=`
1
+ import{h as J,i as b,j as A,k as B,l as N,m as P,n as U,o as j,s as x}from"./index-epqg22cp.js";import{t as T,u as R,v as V}from"./index-gbfwa9vq.js";import{D as $}from"./index-5kwkpwkp.js";function C(_={}){return async function(y){y.innerHTML="";let{memories:D}=await $.listMemories({limit:500}),F=y.clientWidth||1200,G=700,W=J(y).append("svg").attr("width",F).attr("height",G),K=document.createElement("div");K.className="galaxy-legend",K.innerHTML=`
2
2
  <div style="font-weight:600;margin-bottom:.5rem;">Decay levels</div>
3
3
  ${R.map((f,q)=>`
4
4
  <div class="galaxy-legend-item">
@@ -0,0 +1,2 @@
1
+ var Q=Object.create;var{getPrototypeOf:R,defineProperty:H,getOwnPropertyNames:U}=Object;var V=Object.prototype.hasOwnProperty;function W(j){return this[j]}var X,Z,S=(j,w,z)=>{var C=j!=null&&typeof j==="object";if(C){var D=w?X??=new WeakMap:Z??=new WeakMap,L=D.get(j);if(L)return L}z=j!=null?Q(R(j)):{};let F=w||!j||!j.__esModule?H(z,"default",{value:j,enumerable:!0}):z;for(let G of U(j))if(!V.call(F,G))H(F,G,{get:W.bind(j,G),enumerable:!0});if(C)D.set(j,F);return F};var h=(j,w)=>()=>(w||j((w={exports:{}}).exports,w),w.exports);var $=(j)=>j;function M(j,w){this[j]=$.bind(null,w)}var x=(j,w)=>{for(var z in w)H(j,z,{get:w[z],enumerable:!0,configurable:!0,set:M.bind(w,z)})};var A=(j,w)=>()=>(j&&(w=j(j=0)),w);var N=((j)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(j,{get:(w,z)=>(typeof require<"u"?require:w)[z]}):j)(function(j){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+j+'" is not supported')});class P extends Error{status;constructor(j,w){super(j);this.status=w}}var J="humemory_api_token";function v(){try{return localStorage.getItem(J)??""}catch{return""}}function Y(j){try{if(j)localStorage.setItem(J,j);else localStorage.removeItem(J)}catch{}}async function B(j,w){let z=v(),C=await fetch(j,{...w,headers:{"Content-Type":"application/json",...z?{"x-humemory-token":z}:{},...w?.headers}}),D=await C.json().catch(()=>null);if(!C.ok)throw new P(D?.error??`HTTP ${C.status}`,C.status);return D}var _={listIntentions(j={}){let w=new URLSearchParams;if(j.status)w.set("status",Array.isArray(j.status)?j.status.join(","):j.status);if(j.directory)w.set("directory",j.directory);let z=w.toString()?`?${w}`:"";return B(`/intentions${z}`)},getIntention(j){return B(`/intentions/${j}`)},createIntention(j){return B("/intentions",{method:"POST",body:JSON.stringify(j)})},closeIntention(j,w){return B(`/intentions/${j}/close`,{method:"POST",body:JSON.stringify({commit:w})})},fireIntention(j){return B(`/intentions/${j}/fire`,{method:"POST"})},deleteIntention(j){return B(`/intentions/${j}`,{method:"DELETE"})},addCue(j,w){return B("/cues",{method:"POST",body:JSON.stringify({intentionId:j,triggerSpec:w})})},resolveCues(){return B("/cues/resolve",{method:"POST"})},listMemories(j={}){let w=new URLSearchParams;if(j.limit)w.set("limit",String(j.limit));if(j.level!==void 0)w.set("level",String(j.level));let z=w.toString()?`?${w}`:"";return B(`/memories${z}`)},search(j,w={}){let z=new URLSearchParams({q:j});if(w.limit)z.set("limit",String(w.limit));if(w.maxLevel!==void 0)z.set("maxLevel",String(w.maxLevel));if(w.directory)z.set("directory",w.directory);if(w.type)z.set("type",w.type);if(w.dateFrom)z.set("dateFrom",w.dateFrom);if(w.dateTo)z.set("dateTo",w.dateTo);if(w.minSaillance!==void 0)z.set("minSaillance",String(w.minSaillance));if(w.minRecalls!==void 0)z.set("minRecalls",String(w.minRecalls));return B(`/search?${z}`)},createMemory(j){return B("/memories",{method:"POST",body:JSON.stringify(j)})},getMemory(j){return B(`/memories/${j}`)},recallMemory(j){return B(`/memories/${j}/recall`,{method:"POST"})},deleteMemory(j){return B(`/memories/${j}`,{method:"DELETE"})},setPhotographic(j,w){return B(`/memories/${j}/photo`,{method:"POST",body:JSON.stringify({enable:w})})},findSimilar(j,w={}){let z=new URLSearchParams;if(w.limit)z.set("limit",String(w.limit));if(w.threshold!==void 0)z.set("threshold",String(w.threshold));let C=z.toString()?`?${z}`:"";return B(`/memories/${j}/similar${C}`)},mergeMemories(j,w){return B(`/memories/${j}/merge`,{method:"POST",body:JSON.stringify({targetId:w})})},listSessions(){return B("/sessions")},getSession(j){return B(`/sessions/${encodeURIComponent(j)}`)},status(){return B("/status")}};
2
+ export{S as w,h as x,x as y,A as z,N as A,v as B,Y as C,_ as D};
@@ -0,0 +1 @@
1
+ :root{--bg:#0f1117;--surface:#171a23;--border:#262b38;--text:#e6e8ee;--muted:#8b93a7;--accent:#7c5cff;--armed:#f0b429;--fired:#4c9aff;--closed:#35c46a;--expired:#5a6070}*{box-sizing:border-box}body{background:var(--bg);color:var(--text);margin:0;font:15px/1.55 ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif}.app{max-width:860px;margin:0 auto;padding:2rem 1.25rem 4rem}.app-header{position:relative}.app-header h1{letter-spacing:-.02em;margin:0;font-size:1.6rem}.tagline{color:var(--muted);margin:.25rem 0 2rem}.token-toggle{position:absolute;background:0 0;padding:.25rem .5rem;font-size:1.1rem;top:0;right:0}.token-form{display:flex;gap:.4rem;margin:.5rem 0 1rem}.token-form input{border:1px solid var(--muted);background:var(--bg);color:var(--text);font:inherit;border-radius:6px;flex:1;padding:.4rem .6rem}.section-head{display:flex;justify-content:space-between;align-items:baseline;gap:1rem}.section-head h2{text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-size:1.05rem}button{background:var(--accent);color:#fff;font:inherit;cursor:pointer;border:0;border-radius:6px;padding:.45rem .85rem;font-size:.9rem}button:disabled{opacity:.5;cursor:default}.loop-list{list-style:none;display:grid;gap:.75rem;margin:0;padding:0}.loop{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:.9rem 1rem}.loop-head{display:flex;align-items: center;gap:.75rem}.loop-head code{color:var(--accent);font-size:.85rem}.loop-content{margin:.4rem 0 .2rem}.loop-meta{color:var(--muted);margin:0;font-size:.82rem}.loop-badge{color:var(--muted);font-size:.78rem}.loop-badge[data-status=armed]{color:var(--armed)}.loop-badge[data-status=fired]{color:var(--fired)}.loop-badge[data-status=closed]{color:var(--closed)}.loop-badge[data-status=expired]{color:var(--expired)}.empty,.error{color:var(--muted)}.error{color:#ff6b6b}h2{text-transform:uppercase;letter-spacing:.08em;color:var(--muted);font-size:1.05rem}.new-loop{display:grid;gap:.75rem;margin-bottom:2.5rem}.field{display:grid;gap:.3rem}.field-row{display:grid;grid-template-columns:1fr 1fr;gap:.75rem}.field label{color:var(--muted);font-size:.8rem}input,textarea{background:var(--surface);color:var(--text);border:1px solid var(--border);font:inherit;border-radius:6px;padding:.45rem .6rem;font-size:.9rem}input:focus,textarea:focus{outline:2px solid var(--accent);outline-offset:1px}textarea{resize:vertical;font-family:ui-monospace,Cascadia Code,monospace;font-size:.82rem}.new-loop>button{justify-self:start}.filters{display:flex;flex-wrap:wrap;align-items: center;gap:.75rem;margin:1rem 0}.filter-tabs{display:flex;flex-wrap:wrap;gap:.25rem}.tab{color:var(--muted);border:1px solid var(--border);background:0 0;font-size:.82rem}.tab.active{background:var(--surface);color:var(--text);border-color:var(--accent)}.filter-directory{flex:1;min-width:200px}button.secondary{border:1px solid var(--border);color:var(--muted);background:0 0}button.danger{background:#a3232f}.tension{display:flex;align-items: center;gap:.6rem;margin:.55rem 0}.tension-bar{overflow:hidden;background:#23283a;border-radius:999px;flex:1;height:5px}.tension-fill{display:block;background:var(--armed);height:100%;transition:width .24s}.tension[data-status=fired] .tension-fill{background:var(--fired)}.tension[data-status=closed] .tension-fill,.tension[data-status=expired] .tension-fill{background:var(--expired)}.tension-value{color:var(--muted);font-variant-numeric:tabular-nums;min-width:4.5rem;font-size:.78rem}.tension-pin{color:var(--armed)}.cue-list{list-style:none;display:grid;gap:.25rem;margin:.6rem 0 0;padding:0}.cue{display:flex;align-items:baseline;gap:.6rem;font-size:.8rem}.cue code{color:var(--muted);font-size:.78rem}.cue[data-status=armed] code{color:var(--text)}.cue[data-status=cancelled] code{text-decoration:line-through;opacity:.6}.cue-status{color:var(--muted);font-size:.72rem}.loop-actions{display:flex;flex-wrap:wrap;gap:.4rem;margin-top:.8rem}.loop-actions button{padding:.3rem .65rem;font-size:.8rem}.loop[data-status=closed],.loop[data-status=expired]{opacity:.72}.loop-overdue{color:#ff9f43;font-size:.75rem}.notice{color:var(--closed);font-size:.85rem}.tab-nav{display:flex;border-bottom:1px solid var(--border);flex-wrap:wrap;gap:.3rem;margin-bottom:1.75rem;padding-bottom:.6rem}.zones{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:.6rem;margin-bottom:1.25rem}.zone-card{display:grid;background:var(--surface);border:1px solid var(--border);text-align:left;color:var(--text);border-radius:10px;gap:.2rem;padding:.75rem}.zone-card.active{border-color:var(--accent)}.zone-count{font-variant-numeric:tabular-nums;font-size:1.5rem;font-weight:600}.zone-label{color:var(--muted);font-size:.78rem}.zone-encoding .zone-count{color:#22c55e}.zone-consolidating .zone-count{color:#eab308}.zone-consolidated .zone-count{color:#f97316}.zone-fragile .zone-count{color:#ef4444}.zone-dormant .zone-count{color:#6b7280}.search{width:100%;margin-bottom:1.25rem}.memory-list{list-style:none;display:grid;gap:.6rem;margin:0;padding:0}.memory-item{background:var(--surface);border:1px solid var(--border);border-radius:10px}.memory-item.is-photographic{border-color:var(--accent)}.memory-open{display:flex;text-align:left;color:var(--text);background:0 0;border:0;align-items: flex-start;gap:.85rem;width:100%;padding:.85rem 1rem}.memory-state{background:var(--muted);border-radius:50%;flex-shrink:0;width:9px;height:9px;margin-top:.4rem}.memory-state.encoding{background:#22c55e}.memory-state.consolidating{background:#eab308}.memory-state.consolidated{background:#f97316}.memory-state.fragile{background:#ef4444}.memory-state.dormant{background:#6b7280}.memory-body{display:grid;gap:.4rem}.memory-text{line-height:1.5}.memory-meta{display:flex;color:var(--muted);flex-wrap:wrap;align-items: center;gap:.75rem;font-size:.78rem}.cue-tag{background:#23283a;border-radius:4px;padding:.15rem .4rem;font-size:.72rem}.photo-badge{color:var(--accent);font-size:.75rem}.strength-dots{display:inline-flex;gap:2px}.strength-dot{background:#2c3244;border-radius:50%;width:6px;height:6px}.strength-dot.active{background:var(--accent)}.modal-backdrop{position:fixed;display:grid;z-index:50;background:#000000a6;place-items: center;padding:1.5rem;inset:0}.modal{background:var(--surface);border:1px solid var(--border);overflow:auto;border-radius:12px;width:100%;max-width:620px;max-height:85vh;padding:1.25rem}.modal-head{display:flex;align-items: center;gap:.5rem;margin-bottom:.9rem}.modal-head button{margin-left:auto}.modal-content{line-height:1.6}.modal-meta{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:.5rem 1rem;margin:1rem 0}.modal-meta dt{color:var(--muted);text-transform:uppercase;letter-spacing:.06em;font-size:.72rem}.modal-meta dd{word-break:break-word;margin:0;font-size:.85rem}.levels{border-left:2px solid var(--border);margin:1rem 0;padding-left:.8rem;font-size:.85rem}.levels strong{color:var(--accent);margin-right:.4rem}.decay-canvas{background:#12151d;border-radius:8px;width:100%;max-width:520px}.modal-actions{display:flex;flex-wrap:wrap;gap:.4rem;margin-top:1rem}.imperative-view{position:relative}.imperative-canvas{border:1px solid var(--border);overflow:hidden;position:relative;background:#0d0f16;border-radius:10px;width:100%}.galaxy-legend,.promenade-hud{position:absolute;border:1px solid var(--border);background:#171a23eb;border-radius:8px;padding:.75rem;font-size:.82rem;top:1rem;right:1rem}.galaxy-legend-item{display:flex;align-items: center;gap:.4rem;margin:.15rem 0}.galaxy-legend-dot{border-radius:50%;width:9px;height:9px}.river-controls,.promenade-controls{display:flex;flex-wrap:wrap;align-items: center;gap:.75rem;margin-top:.75rem}.river-controls input[type=range]{flex:1;min-width:180px}.river-tooltip{position:absolute;border:1px solid var(--border);pointer-events:none;z-index:60;background:#171a23f7;border-radius:8px;max-width:280px;padding:.7rem;font-size:.85rem}select{background:var(--surface);color:var(--text);border:1px solid var(--border);font:inherit;border-radius:6px;width:100%;padding:.5rem .6rem;font-size:.9rem}.replay-panes{display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin:1.25rem 0}.replay-panes h3{text-transform:uppercase;letter-spacing:.08em;color:var(--muted);margin:0 0 .6rem;font-size:.8rem}.replay-transcript,.replay-events{background:var(--surface);border:1px solid var(--border);overflow-y:auto;border-radius:10px;max-height:340px;padding:.85rem}.replay-message{border-left:2px solid var(--border);margin-bottom:.7rem;padding-left:.6rem}.replay-message time,.replay-event time{color:var(--muted);font-size:.72rem}.replay-message p{margin:.2rem 0 0;font-size:.85rem}.replay-event{display:flex;border-bottom:1px solid #1e2230;align-items:baseline;gap:.5rem;padding:.25rem 0;font-size:.82rem}.replay-event-label{flex:1}.replay-event.encoded{color:#22c55e}.replay-event.decayed{color:#f97316}.replay-event.recalled{color:#06b6d4}.replay-timeline{display:flex;flex-wrap:wrap;align-items: center;gap:.75rem}.replay-timeline input[type=range]{flex:1;min-width:180px}.replay-position{font-variant-numeric:tabular-nums;color:var(--muted);font-size:.82rem}.replay-counts{display:flex;color:var(--muted);flex-wrap:wrap;gap:1.5rem;margin-top:.8rem;font-size:.82rem}.similar-panel{border-top:1px solid var(--border);margin-top:1rem;padding-top:.9rem}.similar-panel h4{text-transform:uppercase;letter-spacing:.07em;color:var(--muted);margin:0 0 .6rem;font-size:.8rem}.similar-item{display:flex;border-bottom:1px solid #1e2230;align-items: center;gap:.6rem;padding:.5rem 0}.similar-item p{flex:1;margin:0;font-size:.85rem}.score{color:var(--muted);white-space:nowrap;font-size:.72rem}.merge-confirm{background:#1c1420;border:1px solid #4a2436;border-radius:8px;margin-top:.9rem;padding:.85rem}.merge-confirm blockquote{border-left:2px solid var(--accent);margin:.5rem 0;padding-left:.7rem;font-size:.85rem}.merge-warning{color:#ff9f43;font-size:.8rem}@media (max-width:720px){.replay-panes,.field-row{grid-template-columns:1fr}}.new-trace-toggle{margin-bottom:1.25rem}.checkbox{display:flex;color:var(--muted);align-items: center;gap:.5rem;font-size:.85rem}.checkbox input{width:auto}.search-row{display:flex;align-items:stretch;gap:.5rem;margin-bottom:1.25rem}.search-row .search{flex:1;margin-bottom:0}.advanced-filters{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));background:var(--surface);border:1px solid var(--border);border-radius:10px;align-items: end;gap:.7rem;margin-bottom:1.25rem;padding:.9rem}