oculon 0.0.0-stage → 0.1.1

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.
Files changed (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +344 -2
  3. package/dist/agent.d.ts +47 -0
  4. package/dist/agent.js +104 -0
  5. package/dist/cases.d.ts +68 -0
  6. package/dist/cases.js +158 -0
  7. package/dist/cli/main.d.ts +12 -0
  8. package/dist/cli/main.js +1999 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +15 -0
  11. package/dist/core/context.d.ts +19 -0
  12. package/dist/core/context.js +19 -0
  13. package/dist/core/features.d.ts +22 -0
  14. package/dist/core/features.js +28 -0
  15. package/dist/core/graph.d.ts +38 -0
  16. package/dist/core/graph.js +81 -0
  17. package/dist/core/http.d.ts +42 -0
  18. package/dist/core/http.js +266 -0
  19. package/dist/core/keys.d.ts +8 -0
  20. package/dist/core/keys.js +22 -0
  21. package/dist/core/llm.d.ts +93 -0
  22. package/dist/core/llm.js +180 -0
  23. package/dist/core/merkle.d.ts +15 -0
  24. package/dist/core/merkle.js +46 -0
  25. package/dist/core/paths.d.ts +2 -0
  26. package/dist/core/paths.js +6 -0
  27. package/dist/core/png.d.ts +17 -0
  28. package/dist/core/png.js +101 -0
  29. package/dist/core/quota.d.ts +15 -0
  30. package/dist/core/quota.js +90 -0
  31. package/dist/core/stats.d.ts +24 -0
  32. package/dist/core/stats.js +67 -0
  33. package/dist/core/store.d.ts +20 -0
  34. package/dist/core/store.js +213 -0
  35. package/dist/core/text.d.ts +9 -0
  36. package/dist/core/text.js +30 -0
  37. package/dist/core/types.d.ts +38 -0
  38. package/dist/core/types.js +1 -0
  39. package/dist/index.d.ts +346 -0
  40. package/dist/index.js +503 -0
  41. package/dist/live.d.ts +53 -0
  42. package/dist/live.js +236 -0
  43. package/dist/mcp.d.ts +43 -0
  44. package/dist/mcp.js +651 -0
  45. package/dist/modules/airport.d.ts +60 -0
  46. package/dist/modules/airport.js +111 -0
  47. package/dist/modules/audit.d.ts +73 -0
  48. package/dist/modules/audit.js +211 -0
  49. package/dist/modules/bgp.d.ts +147 -0
  50. package/dist/modules/bgp.js +206 -0
  51. package/dist/modules/blackout.d.ts +41 -0
  52. package/dist/modules/blackout.js +98 -0
  53. package/dist/modules/brief.d.ts +26 -0
  54. package/dist/modules/brief.js +99 -0
  55. package/dist/modules/calendar.d.ts +27 -0
  56. package/dist/modules/calendar.js +145 -0
  57. package/dist/modules/calibrate.d.ts +46 -0
  58. package/dist/modules/calibrate.js +92 -0
  59. package/dist/modules/cloud.d.ts +32 -0
  60. package/dist/modules/cloud.js +94 -0
  61. package/dist/modules/condor.d.ts +66 -0
  62. package/dist/modules/condor.js +214 -0
  63. package/dist/modules/connect.d.ts +47 -0
  64. package/dist/modules/connect.js +114 -0
  65. package/dist/modules/contradictions.d.ts +27 -0
  66. package/dist/modules/contradictions.js +76 -0
  67. package/dist/modules/country.d.ts +82 -0
  68. package/dist/modules/country.js +136 -0
  69. package/dist/modules/cricket.d.ts +34 -0
  70. package/dist/modules/cricket.js +166 -0
  71. package/dist/modules/darkships.d.ts +219 -0
  72. package/dist/modules/darkships.js +400 -0
  73. package/dist/modules/defi.d.ts +237 -0
  74. package/dist/modules/defi.js +512 -0
  75. package/dist/modules/emailsec.d.ts +47 -0
  76. package/dist/modules/emailsec.js +146 -0
  77. package/dist/modules/exposure.d.ts +43 -0
  78. package/dist/modules/exposure.js +89 -0
  79. package/dist/modules/factcheck.d.ts +39 -0
  80. package/dist/modules/factcheck.js +127 -0
  81. package/dist/modules/falcon.d.ts +58 -0
  82. package/dist/modules/falcon.js +219 -0
  83. package/dist/modules/feedback.d.ts +24 -0
  84. package/dist/modules/feedback.js +37 -0
  85. package/dist/modules/fence.d.ts +52 -0
  86. package/dist/modules/fence.js +128 -0
  87. package/dist/modules/ferret.d.ts +47 -0
  88. package/dist/modules/ferret.js +220 -0
  89. package/dist/modules/filings.d.ts +86 -0
  90. package/dist/modules/filings.js +166 -0
  91. package/dist/modules/fires.d.ts +56 -0
  92. package/dist/modules/fires.js +150 -0
  93. package/dist/modules/hazards.d.ts +37 -0
  94. package/dist/modules/hazards.js +83 -0
  95. package/dist/modules/health.d.ts +24 -0
  96. package/dist/modules/health.js +82 -0
  97. package/dist/modules/heron.d.ts +68 -0
  98. package/dist/modules/heron.js +184 -0
  99. package/dist/modules/hound.d.ts +100 -0
  100. package/dist/modules/hound.js +301 -0
  101. package/dist/modules/impact.d.ts +39 -0
  102. package/dist/modules/impact.js +63 -0
  103. package/dist/modules/launches.d.ts +24 -0
  104. package/dist/modules/launches.js +61 -0
  105. package/dist/modules/listen.d.ts +48 -0
  106. package/dist/modules/listen.js +125 -0
  107. package/dist/modules/lynx.d.ts +43 -0
  108. package/dist/modules/lynx.js +127 -0
  109. package/dist/modules/magpie.d.ts +70 -0
  110. package/dist/modules/magpie.js +174 -0
  111. package/dist/modules/meerkat.d.ts +42 -0
  112. package/dist/modules/meerkat.js +293 -0
  113. package/dist/modules/monitor.d.ts +27 -0
  114. package/dist/modules/monitor.js +105 -0
  115. package/dist/modules/narratives.d.ts +33 -0
  116. package/dist/modules/narratives.js +136 -0
  117. package/dist/modules/owl.d.ts +71 -0
  118. package/dist/modules/owl.js +290 -0
  119. package/dist/modules/papers.d.ts +46 -0
  120. package/dist/modules/papers.js +135 -0
  121. package/dist/modules/personal.d.ts +54 -0
  122. package/dist/modules/personal.js +153 -0
  123. package/dist/modules/pulse.d.ts +19 -0
  124. package/dist/modules/pulse.js +59 -0
  125. package/dist/modules/raven.d.ts +80 -0
  126. package/dist/modules/raven.js +147 -0
  127. package/dist/modules/recall.d.ts +44 -0
  128. package/dist/modules/recall.js +123 -0
  129. package/dist/modules/regs.d.ts +88 -0
  130. package/dist/modules/regs.js +142 -0
  131. package/dist/modules/rewind.d.ts +22 -0
  132. package/dist/modules/rewind.js +68 -0
  133. package/dist/modules/sanctions.d.ts +62 -0
  134. package/dist/modules/sanctions.js +173 -0
  135. package/dist/modules/scam.d.ts +43 -0
  136. package/dist/modules/scam.js +149 -0
  137. package/dist/modules/scoop.d.ts +31 -0
  138. package/dist/modules/scoop.js +74 -0
  139. package/dist/modules/ships.d.ts +33 -0
  140. package/dist/modules/ships.js +113 -0
  141. package/dist/modules/sky.d.ts +47 -0
  142. package/dist/modules/sky.js +183 -0
  143. package/dist/modules/squawk.d.ts +46 -0
  144. package/dist/modules/squawk.js +106 -0
  145. package/dist/modules/tortoise.d.ts +59 -0
  146. package/dist/modules/tortoise.js +133 -0
  147. package/dist/modules/travel.d.ts +94 -0
  148. package/dist/modules/travel.js +241 -0
  149. package/dist/modules/urlcheck.d.ts +63 -0
  150. package/dist/modules/urlcheck.js +223 -0
  151. package/dist/modules/vulns.d.ts +142 -0
  152. package/dist/modules/vulns.js +276 -0
  153. package/dist/plugins.d.ts +41 -0
  154. package/dist/plugins.js +70 -0
  155. package/dist/report.d.ts +12 -0
  156. package/dist/report.js +90 -0
  157. package/dist/scheduler.d.ts +22 -0
  158. package/dist/scheduler.js +139 -0
  159. package/dist/sources/aircraft.d.ts +76 -0
  160. package/dist/sources/aircraft.js +107 -0
  161. package/dist/sources/airports.d.ts +28 -0
  162. package/dist/sources/airports.js +100 -0
  163. package/dist/sources/ais.d.ts +32 -0
  164. package/dist/sources/ais.js +111 -0
  165. package/dist/sources/apify.d.ts +28 -0
  166. package/dist/sources/apify.js +80 -0
  167. package/dist/sources/arxiv.d.ts +13 -0
  168. package/dist/sources/arxiv.js +27 -0
  169. package/dist/sources/certs.d.ts +12 -0
  170. package/dist/sources/certs.js +23 -0
  171. package/dist/sources/corp.d.ts +46 -0
  172. package/dist/sources/corp.js +60 -0
  173. package/dist/sources/earth.d.ts +39 -0
  174. package/dist/sources/earth.js +76 -0
  175. package/dist/sources/fda.d.ts +77 -0
  176. package/dist/sources/fda.js +121 -0
  177. package/dist/sources/finance.d.ts +181 -0
  178. package/dist/sources/finance.js +270 -0
  179. package/dist/sources/gdelt.d.ts +19 -0
  180. package/dist/sources/gdelt.js +33 -0
  181. package/dist/sources/github.d.ts +17 -0
  182. package/dist/sources/github.js +33 -0
  183. package/dist/sources/hackernews.d.ts +20 -0
  184. package/dist/sources/hackernews.js +37 -0
  185. package/dist/sources/labels.d.ts +21 -0
  186. package/dist/sources/labels.js +87 -0
  187. package/dist/sources/launch.d.ts +16 -0
  188. package/dist/sources/launch.js +41 -0
  189. package/dist/sources/ofac.d.ts +29 -0
  190. package/dist/sources/ofac.js +86 -0
  191. package/dist/sources/onchain.d.ts +77 -0
  192. package/dist/sources/onchain.js +189 -0
  193. package/dist/sources/opentimestamps.d.ts +49 -0
  194. package/dist/sources/opentimestamps.js +145 -0
  195. package/dist/sources/polymarket.d.ts +36 -0
  196. package/dist/sources/polymarket.js +70 -0
  197. package/dist/sources/predict.d.ts +18 -0
  198. package/dist/sources/predict.js +59 -0
  199. package/dist/sources/press.d.ts +30 -0
  200. package/dist/sources/press.js +111 -0
  201. package/dist/sources/resend.d.ts +14 -0
  202. package/dist/sources/resend.js +29 -0
  203. package/dist/sources/robinhood.d.ts +109 -0
  204. package/dist/sources/robinhood.js +129 -0
  205. package/dist/sources/sec.d.ts +67 -0
  206. package/dist/sources/sec.js +129 -0
  207. package/dist/sources/sentinel.d.ts +13 -0
  208. package/dist/sources/sentinel.js +63 -0
  209. package/dist/sources/signatures.d.ts +14 -0
  210. package/dist/sources/signatures.js +103 -0
  211. package/dist/sources/social.d.ts +22 -0
  212. package/dist/sources/social.js +56 -0
  213. package/dist/sources/space.d.ts +160 -0
  214. package/dist/sources/space.js +230 -0
  215. package/dist/sources/usgs.d.ts +17 -0
  216. package/dist/sources/usgs.js +24 -0
  217. package/dist/sources/wayback.d.ts +10 -0
  218. package/dist/sources/wayback.js +28 -0
  219. package/dist/sources/websec.d.ts +19 -0
  220. package/dist/sources/websec.js +40 -0
  221. package/dist/sources/wikidata.d.ts +11 -0
  222. package/dist/sources/wikidata.js +30 -0
  223. package/dist/sources/wikimedia.d.ts +28 -0
  224. package/dist/sources/wikimedia.js +52 -0
  225. package/dist/telegram.d.ts +104 -0
  226. package/dist/telegram.js +927 -0
  227. package/dist/web/assets/favicon-32.png +0 -0
  228. package/dist/web/assets/fx.js +178 -0
  229. package/dist/web/assets/icon-192.png +0 -0
  230. package/dist/web/assets/icon-512.png +0 -0
  231. package/dist/web/assets/icon-maskable-512.png +0 -0
  232. package/dist/web/assets/night-americas.jpg +0 -0
  233. package/dist/web/assets/night-emea.jpg +0 -0
  234. package/dist/web/assets/og.png +0 -0
  235. package/dist/web/assets/redsea-bm.jpg +0 -0
  236. package/dist/web/docs.html +281 -0
  237. package/dist/web/index.html +1828 -0
  238. package/dist/web/insights.d.ts +100 -0
  239. package/dist/web/insights.js +134 -0
  240. package/dist/web/landing.html +1144 -0
  241. package/dist/web/legal.html +176 -0
  242. package/dist/web/manifest.webmanifest +20 -0
  243. package/dist/web/mcp.html +104 -0
  244. package/dist/web/mcphttp.d.ts +10 -0
  245. package/dist/web/mcphttp.js +67 -0
  246. package/dist/web/openapi.d.ts +1 -0
  247. package/dist/web/openapi.js +51 -0
  248. package/dist/web/public.d.ts +45 -0
  249. package/dist/web/public.js +136 -0
  250. package/dist/web/server.d.ts +69 -0
  251. package/dist/web/server.js +764 -0
  252. package/dist/web/share.d.ts +35 -0
  253. package/dist/web/share.js +132 -0
  254. package/dist/web/sw.js +28 -0
  255. package/package.json +60 -4
@@ -0,0 +1,1828 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <link rel="manifest" href="/manifest.webmanifest">
7
+ <meta name="theme-color" content="#000000">
8
+ <link rel="icon" type="image/png" href="/favicon.ico">
9
+ <link rel="apple-touch-icon" href="/assets/icon-192.png">
10
+ <title>Oculon</title>
11
+ <meta property="og:type" content="website"><meta property="og:site_name" content="Oculon"><meta property="og:title" content="Oculon app"><meta property="og:description" content="Investigate, monitor and share: the full Oculon intelligence app."><meta property="og:url" content="https://oculon.live/app"><meta property="og:image" content="https://oculon.live/assets/og.png"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:image" content="https://oculon.live/assets/og.png">
12
+ <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
13
+ <link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
14
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.css">
15
+ <style>
16
+ :root {
17
+ --bg: #000; --panel: #060606; --panel-2: #0e0e0e; --line: #222; --text: #fff; --muted: #9a9a9a;
18
+ --accent: #00f0ff; --accent-2: #e8e8e8; --warn: #00f0ff; --bad: #ff7a6b; --chip: #111;
19
+ --mono: 'Space Mono', ui-monospace, Consolas, monospace;
20
+ --sans: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
21
+ }
22
+ :root[data-theme="light"] {
23
+ --bg: #fff; --panel: #fff; --panel-2: #f4f4f4; --line: #e2e2e2; --text: #000; --muted: #5f5f5f;
24
+ --accent: #000; --accent-2: #000; --warn: #00838f; --bad: #c62828; --chip: #f2f2f2;
25
+ }
26
+ * { box-sizing: border-box; }
27
+ html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
28
+ header { display: flex; align-items: center; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 1000; flex-wrap: wrap; }
29
+ .brand { font-weight: 700; letter-spacing: .08em; font-family: var(--mono); }
30
+ .brand span { color: var(--accent); }
31
+ nav { display: flex; gap: 4px; flex-wrap: wrap; }
32
+ nav button { background: none; border: 1px solid transparent; color: var(--muted); padding: 6px 12px; border-radius: 0; cursor: pointer; font: inherit; }
33
+ nav button[aria-selected="true"] { color: var(--text); border-color: var(--line); background: var(--panel-2); }
34
+ .spacer { flex: 1; }
35
+ .icon-btn { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 0; padding: 6px 10px; cursor: pointer; font: inherit; }
36
+ main { padding: 16px; max-width: 1400px; margin: 0 auto; }
37
+ section[hidden] { display: none !important; }
38
+ .grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
39
+ .card { background: var(--panel); border: 1px solid var(--line); border-radius: 0; padding: 14px 16px; min-width: 0; }
40
+ .card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
41
+ .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
42
+ .sig { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
43
+ .sig:first-child { border-top: 0; }
44
+ .score { font-family: var(--mono); font-weight: 700; font-size: 18px; text-align: center; border-radius: 0; padding: 4px 0; background: var(--chip); }
45
+ .score.hi { color: var(--bad); } .score.mid { color: var(--warn); } .score.lo { color: var(--accent); }
46
+ .title { font-weight: 600; overflow-wrap: anywhere; }
47
+ .meta { color: var(--muted); font-size: 12px; }
48
+ .chip { display: inline-block; font-family: var(--mono); font-size: 11px; background: var(--chip); border: 1px solid var(--line); border-radius: 0; padding: 1px 8px; margin-right: 4px; }
49
+ .ev { margin: 4px 0 0; padding-left: 16px; color: var(--muted); font-size: 12.5px; }
50
+ .ev a { color: var(--accent-2); text-decoration: none; }
51
+ input[type=text] { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 0; padding: 8px 10px; font: inherit; min-width: 0; flex: 1; }
52
+ button.go { background: var(--accent); color: #04130d; border: 0; border-radius: 0; padding: 8px 14px; font-weight: 600; cursor: pointer; font: inherit; }
53
+ button.go:disabled { opacity: .5; cursor: progress; }
54
+ select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 0; padding: 8px; font: inherit; }
55
+ #map { height: 62vh; min-height: 360px; border-radius: 0; border: 1px solid var(--line); }
56
+ .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
57
+ .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
58
+ pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 0; padding: 10px; overflow: auto; font: 12px/1.45 var(--mono); max-height: 50vh; }
59
+ table { width: 100%; border-collapse: collapse; font-size: 13px; }
60
+ th, td { text-align: left; padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: top; }
61
+ th { color: var(--muted); font-weight: 600; font-size: 12px; border-top: 0; }
62
+ td.num { font-family: var(--mono); white-space: nowrap; }
63
+ .kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
64
+ .kpi { background: var(--panel-2); border: 1px solid var(--line); border-radius: 0; padding: 10px 12px; }
65
+ .kpi b { display: block; font: 700 22px var(--mono); }
66
+ .kpi span { color: var(--muted); font-size: 12px; }
67
+ canvas#graph { width: 100%; height: 62vh; min-height: 360px; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 0; }
68
+ .status { font-family: var(--mono); font-size: 12px; color: var(--muted); }
69
+ .err { color: var(--bad); }
70
+ .pill { display: inline-block; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 1px 8px; border: 1px solid currentColor; vertical-align: middle; }
71
+ .pill.ok { color: var(--accent); } .pill.warn { color: var(--accent-2); } .pill.bad { color: var(--bad); }
72
+ .out h3 { margin: 14px 0 6px; font-size: 14px; }
73
+ .spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 28px; vertical-align: middle; }
74
+ .spark i { display: block; width: 6px; background: var(--accent-2); border-radius: 0; }
75
+ img.sat { max-width: 100%; border-radius: 0; border: 1px solid var(--line); }
76
+ .leaflet-container { background: var(--panel-2); }
77
+ .md { color: var(--text); }
78
+ .md h1 { font-size: 16px; margin: 0 0 6px; }
79
+ .md h2 { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--muted); margin: 12px 0 4px; }
80
+ .md ul { margin: 4px 0; padding-left: 18px; }
81
+ .md a, table a, .out a, #case-list a { color: var(--accent-2); text-decoration: none; }
82
+ table a:hover, .out a:hover, #case-list a:hover { text-decoration: underline; }
83
+ code { font-family: var(--mono); font-size: 12px; background: var(--chip); padding: 1px 5px; border-radius: 0; }
84
+ /* Dark basemap from the standard OSM tiles. */
85
+ :root:not([data-theme="light"]) .osm-tiles { filter: invert(1) grayscale(1) brightness(.8) contrast(1.1); }
86
+ @media (max-width: 640px) { main { padding: 12px; } header { padding: 10px 12px; } }
87
+ /* Oculon 06 look */
88
+ header { background: rgba(0,0,0,.86); backdrop-filter: blur(12px); padding: 14px 24px; gap: 28px; }
89
+ :root[data-theme="light"] header { background: rgba(255,255,255,.9); }
90
+ .brand { font: 600 17px var(--sans); letter-spacing: .4em; color: var(--text); text-decoration: none; }
91
+ nav button { font: 500 14px var(--sans); padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; }
92
+ nav button[aria-selected="true"] { background: none; border-color: transparent; border-bottom-color: var(--accent); }
93
+ .toplink { color: var(--muted); text-decoration: none; font-size: 14px; }
94
+ .toplink:hover { color: var(--text); }
95
+ main { padding: 28px 24px 60px; max-width: 1480px; }
96
+ .card { padding: 20px 22px; }
97
+ .card h2 { font: 400 12px var(--mono); letter-spacing: .14em; color: var(--muted); }
98
+ .title { font-weight: 500; }
99
+ .score { font-weight: 700; font-size: 15px; background: none; border: 1px solid var(--line); }
100
+ .score.hi { background: var(--warn); color: #000; border-color: var(--warn); }
101
+ .score.mid { color: var(--warn); border-color: var(--warn); }
102
+ .score.lo { color: var(--muted); }
103
+ button.go { background: var(--accent); color: #000; font: 600 14px var(--sans); padding: 9px 16px; }
104
+ :root[data-theme="light"] button.go { color: #fff; }
105
+ .icon-btn { font: 13px var(--mono); text-decoration: none; display: inline-block; }
106
+ input[type=text], select { font: 14px var(--mono); padding: 10px 12px; }
107
+ input[type=text]:focus, select:focus { outline: 1px solid var(--accent); outline-offset: -1px; }
108
+ .kpi b { font: 300 30px var(--sans); }
109
+ .kpi span { font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
110
+ th { font: 11px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
111
+ .chip { font-size: 11px; }
112
+ .md a, table a, .out a, #case-list a, .ev a { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
113
+ .spark i { background: var(--accent); }
114
+ ::selection { background: var(--accent); color: #000; }
115
+ /* ---------- motion (same language as the landing page) ---------- */
116
+ #bgfx { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
117
+ #liquidbg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; opacity: .32; }
118
+ :root[data-theme="light"] #liquidbg { opacity: .14; }
119
+ .appband { position: relative; z-index: 1; height: 150px; margin-bottom: -96px; overflow: hidden; }
120
+ .appband canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
121
+ .appband-fade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, var(--bg)); pointer-events: none; }
122
+ :root[data-theme="light"] .appband { opacity: .5; }
123
+ input[type=checkbox] { accent-color: var(--accent); }
124
+ header, main { position: relative; z-index: 1; }
125
+ header { position: sticky; z-index: 1000; }
126
+ :root:not([data-theme="light"]) { --panel: rgba(8,8,8,.82); }
127
+ .card { backdrop-filter: blur(6px); }
128
+ header::after { content: ''; position: absolute; left: -30%; bottom: -1px; width: 30%; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: hscan 6s linear infinite; }
129
+ @keyframes hscan { to { left: 100%; } }
130
+ .brand { background: linear-gradient(90deg, var(--text) 40%, var(--accent) 50%, var(--text) 60%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: brand 7s linear infinite; }
131
+ @keyframes brand { from { background-position: 100% 0; } to { background-position: -200% 0; } }
132
+ section:not([hidden]) { animation: secin .6s cubic-bezier(.2,.8,.2,1) both; }
133
+ @keyframes secin { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
134
+ section:not([hidden]) .card { animation: secin .7s cubic-bezier(.2,.8,.2,1) both; }
135
+ section:not([hidden]) .card:nth-child(2) { animation-delay: .08s; } section:not([hidden]) .card:nth-child(3) { animation-delay: .16s; } section:not([hidden]) .card:nth-child(4) { animation-delay: .24s; }
136
+ .card { position: relative; overflow: hidden; isolation: isolate; }
137
+ .card::before { content: ''; position: absolute; width: 520px; height: 520px; left: var(--mx, 10%); top: var(--my, -40%); transform: translate(-50%, -50%); background: radial-gradient(circle, rgba(0,240,255,.07), transparent 60%); z-index: -1; pointer-events: none; animation: drift 16s ease-in-out infinite alternate; animation-delay: calc(var(--i, 0) * -2.3s); transition: left .25s, top .25s; }
138
+ .card:hover::before { animation-play-state: paused; }
139
+ @keyframes drift { 0% { left: -10%; top: -20%; } 50% { left: 110%; top: 50%; } 100% { left: 30%; top: 120%; } }
140
+ .card::after { content: ''; position: absolute; inset: 0; border: 1px solid transparent; background: linear-gradient(120deg, transparent 30%, rgba(0,240,255,.45), transparent 70%) border-box; background-size: 300% 300%; -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0; transition: opacity .3s; animation: sweep 3s linear infinite; pointer-events: none; }
141
+ .card:hover::after { opacity: 1; }
142
+ @keyframes sweep { to { background-position: 300% 0; } }
143
+ .sig { animation: rowin .55s cubic-bezier(.2,.8,.2,1) both; }
144
+ .sig:nth-child(2) { animation-delay: .05s; } .sig:nth-child(3) { animation-delay: .1s; } .sig:nth-child(4) { animation-delay: .15s; } .sig:nth-child(5) { animation-delay: .2s; } .sig:nth-child(6) { animation-delay: .25s; } .sig:nth-child(7) { animation-delay: .3s; } .sig:nth-child(n+8) { animation-delay: .35s; }
145
+ tr, .row + .row { animation: rowin .5s ease both; }
146
+ @keyframes rowin { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
147
+ .score.hi { animation: hot 2.2s ease-in-out infinite; }
148
+ @keyframes hot { 50% { box-shadow: 0 0 0 4px rgba(0,240,255,.18), 0 0 22px rgba(0,240,255,.35); } }
149
+ .kpi { position: relative; overflow: hidden; }
150
+ .kpi::after { content: ''; position: absolute; top: 0; bottom: 0; left: -50%; width: 50%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); animation: shine 6s ease-in-out infinite; }
151
+ @keyframes shine { 0%, 55% { left: -50%; } 100% { left: 120%; } }
152
+ .loading { background: linear-gradient(90deg, var(--muted) 30%, var(--text) 50%, var(--muted) 70%); background-size: 300% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: brand 1.6s linear infinite; }
153
+ button.go, .icon-btn { transition: box-shadow .25s, transform .25s, border-color .25s; }
154
+ button.go:hover { box-shadow: 0 0 26px rgba(0,240,255,.45); transform: translateY(-1px); }
155
+ .icon-btn:hover { border-color: var(--accent); }
156
+ nav button { transition: color .2s, border-color .3s; }
157
+ input[type=text]:focus { box-shadow: 0 0 0 1px var(--accent), 0 0 24px rgba(0,240,255,.18); transition: box-shadow .3s; }
158
+ .status:not(:empty)::before { content: '●'; color: #3fd16b; margin-right: 6px; animation: blink 1.6s steps(1) infinite; }
159
+ .status.err::before { color: var(--bad); }
160
+ @keyframes blink { 50% { opacity: .2; } }
161
+ .mk-pulse { animation: mkpulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
162
+ @keyframes mkpulse { 0%, 100% { stroke-opacity: 1; stroke-width: 2px; } 50% { stroke-opacity: .25; stroke-width: 9px; } }
163
+ .mk-blink { animation: mkblink 2s ease-in-out infinite; }
164
+ @keyframes mkblink { 50% { fill-opacity: .25; stroke-opacity: .3; } }
165
+ .mk-fence { stroke-dasharray: 8 6; animation: dash 1.2s linear infinite; }
166
+ @keyframes dash { to { stroke-dashoffset: -28; } }
167
+ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
168
+ /* ---------- overview tab ---------- */
169
+ .ov-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 10px 0 22px; flex-wrap: wrap; }
170
+ .ov-k { font: 12px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
171
+ .ov-h { margin: 10px 0 0; font-size: clamp(30px, 3.4vw, 46px); font-weight: 300; letter-spacing: -.03em; line-height: 1.05; }
172
+ .ov-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 16px; }
173
+ .ov-kpi { background: var(--panel); padding: 16px 18px; position: relative; overflow: hidden; backdrop-filter: blur(6px); }
174
+ .ov-kpi span { display: block; font: 10.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
175
+ .ov-kpi b { display: block; font: 300 32px var(--sans); margin-top: 6px; letter-spacing: -.02em; }
176
+ .ov-kpi::after { content: ''; position: absolute; top: 0; bottom: 0; left: -50%; width: 50%; background: linear-gradient(90deg, transparent, rgba(0,240,255,.06), transparent); animation: shine 6s ease-in-out infinite; animation-delay: calc(var(--i, 0) * .9s); }
177
+ .ov-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
178
+ .ov { position: relative; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(6px); padding: 18px 20px 14px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; isolation: isolate; transition: border-color .3s, transform .35s; animation: secin .7s cubic-bezier(.2,.8,.2,1) both; }
179
+ .ov:hover { border-color: rgba(0,240,255,.5); transform: translateY(-3px); }
180
+ .ov::before { content: ''; position: absolute; inset: -1px; padding: 1px; background: conic-gradient(from var(--ova, 0deg), transparent 0 80%, rgba(0,240,255,.6) 90%, transparent 100%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0; transition: opacity .3s; animation: ovspin 5s linear infinite; z-index: -1; pointer-events: none; }
181
+ .ov:hover::before { opacity: 1; }
182
+ @property --ova { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
183
+ @keyframes ovspin { to { --ova: 360deg; } }
184
+ .ov.w2 { grid-column: span 2; } .ov.w4 { grid-column: 1 / -1; } .ov.w4 .ov-qgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
185
+ .ov .ovh { display: flex; justify-content: space-between; gap: 12px; font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
186
+ .ov .ovh a { color: var(--accent); text-decoration: none; cursor: pointer; letter-spacing: .06em; }
187
+ .ov .ovh a:hover { text-shadow: 0 0 12px var(--accent); }
188
+ .ovb { flex: 1; margin-top: 14px; }
189
+ .ov .ovf { margin-top: 12px; font: 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); opacity: .7; }
190
+ .ov-sk { height: 110px; background: linear-gradient(90deg, var(--panel-2) 30%, rgba(0,240,255,.08) 50%, var(--panel-2) 70%); background-size: 300% 100%; animation: brand 1.4s linear infinite; }
191
+ .ov-big { font: 300 40px var(--sans); letter-spacing: -.03em; line-height: 1; }
192
+ .ov-big small { font-size: 14px; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
193
+ .ov-kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
194
+ .ov-kv span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
195
+ .ov-kv span:last-child { font-family: var(--mono); font-size: 12.5px; flex: none; }
196
+ .ov-kev { display: grid; grid-template-columns: minmax(0, 1fr) 110px 80px; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
197
+ .ov-kev b { font: 600 12.5px var(--mono); color: var(--accent); }
198
+ .ov-kev > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
199
+ .ov-meter { height: 5px; background: var(--panel-2); position: relative; overflow: hidden; }
200
+ .ov-meter i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); box-shadow: 0 0 10px var(--accent); transition: width 1.4s cubic-bezier(.2,.8,.2,1); }
201
+ .ov-due { font: 11.5px var(--mono); text-align: right; color: var(--muted); }
202
+ .ov-due.hot { color: var(--bad); }
203
+ .ov-bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin-top: 12px; }
204
+ .ov-bars i { flex: 1; min-height: 2px; background: linear-gradient(180deg, var(--accent), rgba(0,240,255,.15)); transform-origin: bottom; animation: ovgrow 1s cubic-bezier(.2,.8,.2,1) both; }
205
+ .ov-bars i.hot { background: linear-gradient(180deg, var(--bad), rgba(255,107,107,.15)); }
206
+ @keyframes ovgrow { from { transform: scaleY(0); } }
207
+ .ov-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 8px; background: #3fd16b; box-shadow: 0 0 8px #3fd16b; vertical-align: 1px; }
208
+ .ov-dot.warn { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: blink 1.4s ease-in-out infinite; }
209
+ .ov-dot.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); animation: blink 1s ease-in-out infinite; }
210
+ .ov-out { padding: 9px 0; border-bottom: 1px solid var(--line); }
211
+ .ov-out .t { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
212
+ .ov-out .t span:last-child { font: 11.5px var(--mono); color: var(--muted); flex: none; }
213
+ .ov-out p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
214
+ .ov-pool { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font: 12.5px var(--mono); }
215
+ .ov-pool .f { color: var(--accent); }
216
+ .ov-pool .f.bad { color: var(--bad); }
217
+ .ov-chain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 10px; }
218
+ .ov-chain div { background: var(--panel-2); padding: 10px 12px; font: 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
219
+ .ov-chain b { display: block; font: 500 17px var(--mono); color: var(--text); letter-spacing: 0; margin-top: 4px; }
220
+ .ov-cal { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
221
+ .ov-cal .d { font: 11.5px var(--mono); color: var(--accent); text-transform: uppercase; }
222
+ .ov-cal .ti { font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
223
+ .ov-cal .k { font: 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
224
+ .ov-narr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
225
+ .ov-n { border: 1px solid var(--line); padding: 12px 14px; background: var(--panel-2); }
226
+ .ov-n .ph { font: 10px var(--mono); letter-spacing: .1em; color: var(--accent); border: 1px solid var(--accent); padding: 1px 6px; }
227
+ .ov-n h4 { margin: 10px 0 0; font-size: 15px; font-weight: 500; line-height: 1.3; }
228
+ .ov-n .ov-bars { height: 34px; }
229
+ .ov-n .m { font: 11px var(--mono); color: var(--muted); margin-top: 6px; }
230
+ .ov-prob { display: grid; grid-template-columns: 80px minmax(0, 1fr) 46px; gap: 12px; align-items: center; padding: 6px 0; font: 12.5px var(--mono); }
231
+ .ov-prob .ov-meter { height: 8px; }
232
+ .ov-prob.mk .ov-meter i { background: var(--muted); box-shadow: none; }
233
+ .ov-ver { display: inline-flex; gap: 8px; align-items: center; margin-top: 12px; border: 1px solid var(--accent); color: var(--accent); padding: 6px 12px; font: 600 11.5px var(--mono); letter-spacing: .1em; box-shadow: 0 0 20px rgba(0,240,255,.2); }
234
+ .ov-chip { display: inline-block; font: 11px var(--mono); border: 1px solid var(--line); padding: 2px 8px; margin: 0 6px 6px 0; color: var(--muted); }
235
+ .ov-q { padding: 7px 0; }
236
+ .ov-q .t { display: flex; justify-content: space-between; font: 12px var(--mono); }
237
+ .ov-q .t span:last-child { color: var(--muted); }
238
+ .ov-q .ov-meter { margin-top: 6px; height: 4px; }
239
+ .ov-qgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
240
+ @media (max-width: 1200px) { .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ov-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
241
+ @media (max-width: 720px) { .ov-grid { grid-template-columns: minmax(0, 1fr); } .ov.w2 { grid-column: auto; } .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ov-narr, .ov-qgrid, .ov.w4 .ov-qgrid { grid-template-columns: minmax(0, 1fr); } .ov-kev { grid-template-columns: minmax(0, 1fr) 70px; } .ov-kev .ov-due { display: none; } }
242
+ /* ---------- nav scrolls instead of wrapping ---------- */
243
+ header { flex-wrap: nowrap; }
244
+ nav { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 92%, transparent); }
245
+ header .spacer { display: none; }
246
+ header .status { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
247
+ @media (max-width: 1300px) { header .status { display: none; } }
248
+ @media (max-width: 720px) { header { flex-wrap: wrap; row-gap: 8px; } header nav { order: 5; flex-basis: 100%; } #pal-btn .kbd { display: none; } header .brand { margin-right: auto; } .ov-kpi b { font-size: 22px; overflow-wrap: anywhere; } .ov-kpi { padding: 12px 14px; } }
249
+ .pal input { color: var(--text) !important; }
250
+ #pal-btn { white-space: nowrap; flex: none; }
251
+ .ib .ev2 a { color: var(--text); text-decoration: underline; text-decoration-color: rgba(0,240,255,.4); text-underline-offset: 3px; }
252
+ .ib .acts { display: grid; grid-template-columns: repeat(2, auto); gap: 6px; align-content: start; }
253
+ input[type=range] { accent-color: var(--accent); }
254
+ nav::-webkit-scrollbar { display: none; }
255
+ nav button { white-space: nowrap; }
256
+ .kbd { font: 11px var(--mono); border: 1px solid var(--line); padding: 2px 6px; color: var(--muted); }
257
+ .icon-btn.on { border-color: var(--accent); color: var(--accent); }
258
+ /* ---------- command palette ---------- */
259
+ .pal-bg { position: fixed; inset: 0; z-index: 3000; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fadein .2s ease both; }
260
+ .pal-bg[hidden] { display: none; }
261
+ .pal { width: min(720px, 92vw); background: rgba(6,10,11,.96); border: 1px solid rgba(0,240,255,.45); box-shadow: 0 30px 120px rgba(0,0,0,.8), 0 0 60px rgba(0,240,255,.12); animation: palin .25s cubic-bezier(.2,.8,.2,1) both; }
262
+ :root[data-theme="light"] .pal { background: rgba(255,255,255,.97); }
263
+ @keyframes palin { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
264
+ @keyframes fadein { from { opacity: 0; } }
265
+ .pal input { width: 100%; border: 0 !important; border-bottom: 1px solid var(--line) !important; background: transparent !important; font: 17px var(--sans) !important; padding: 18px 20px !important; outline: none !important; box-shadow: none !important; }
266
+ .pal-list { max-height: 56vh; overflow-y: auto; padding: 6px; }
267
+ .pal-sec { font: 10.5px var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 10px 12px 4px; }
268
+ .pal-it { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer; border-left: 2px solid transparent; }
269
+ .pal-it .i { font: 12px var(--mono); color: var(--accent); text-align: center; }
270
+ .pal-it .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
271
+ .pal-it .t small { color: var(--muted); margin-left: 8px; }
272
+ .pal-it .k { font: 11px var(--mono); color: var(--muted); }
273
+ .pal-it.on { background: rgba(0,240,255,.08); border-left-color: var(--accent); }
274
+ .pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--muted); }
275
+ /* ---------- toasts ---------- */
276
+ .toasts { position: fixed; right: 18px; bottom: 18px; z-index: 2500; display: flex; flex-direction: column; gap: 10px; width: min(380px, 90vw); }
277
+ .toast { background: rgba(6,10,11,.95); border: 1px solid rgba(0,240,255,.45); padding: 12px 14px; box-shadow: 0 10px 40px rgba(0,0,0,.6), 0 0 30px rgba(0,240,255,.12); animation: toastin .4s cubic-bezier(.2,.8,.2,1) both; cursor: pointer; }
278
+ :root[data-theme="light"] .toast { background: #fff; }
279
+ @keyframes toastin { from { opacity: 0; transform: translateX(30px); } }
280
+ .toast .k { font: 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
281
+ .toast .t { margin-top: 4px; font-size: 14px; line-height: 1.4; }
282
+ /* ---------- inbox ---------- */
283
+ .ib-bar { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
284
+ .ib-chips { display: flex; flex-wrap: wrap; gap: 6px; }
285
+ .ib-chips button { background: none; border: 1px solid var(--line); color: var(--muted); font: 12px var(--mono); padding: 5px 10px; cursor: pointer; }
286
+ .ib-chips button.on { border-color: var(--accent); color: var(--accent); background: rgba(0,240,255,.06); }
287
+ .ib { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); background: var(--panel); margin-bottom: 8px; position: relative; animation: rowin .4s ease both; }
288
+ .ib.unread::before { content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
289
+ .ib.new { animation: ibnew 1.6s ease both; }
290
+ @keyframes ibnew { 0% { background: rgba(0,240,255,.25); } 100% { background: var(--panel); } }
291
+ .sc2 { font: 700 15px var(--mono); text-align: center; border: 1px solid var(--line); padding: 6px 0; align-self: start; }
292
+ .sc2.hi { background: var(--accent); color: #001418; border-color: var(--accent); }
293
+ .sc2.mid { color: var(--accent); border-color: var(--accent); }
294
+ .ib h4 { margin: 0; font-size: 15.5px; font-weight: 500; line-height: 1.35; cursor: pointer; }
295
+ .ib .m { font: 11.5px var(--mono); color: var(--muted); margin-top: 4px; }
296
+ .ib .ev2 { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
297
+ .ib .ev2 b { font: 500 11px var(--mono); color: var(--accent); margin-right: 6px; }
298
+ .ib .acts { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
299
+ .ib .acts button { background: none; border: 1px solid var(--line); color: var(--muted); font: 11.5px var(--mono); padding: 5px 10px; cursor: pointer; white-space: nowrap; }
300
+ .ib .acts button:hover { color: var(--text); border-color: var(--accent); }
301
+ .ib .acts button.voted { color: var(--accent); border-color: var(--accent); }
302
+ /* ---------- timeline ---------- */
303
+ #tl-chart { width: 100%; display: block; }
304
+ #tl-range { accent-color: var(--accent); margin-top: 8px; }
305
+ .tl-it { display: grid; grid-template-columns: 120px 46px minmax(0, 1fr); gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; animation: rowin .35s ease both; }
306
+ .tl-it .d { font: 12px var(--mono); color: var(--muted); }
307
+ .tl-it .s { font: 700 12.5px var(--mono); color: var(--accent); }
308
+ /* ---------- sources + accuracy ---------- */
309
+ .hosts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 24px; }
310
+ .host { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font: 12.5px var(--mono); }
311
+ .host .st { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
312
+ .host .st.fresh { background: #3fd16b; box-shadow: 0 0 8px #3fd16b; animation: blink 2.4s ease-in-out infinite; }
313
+ .host .st.today { background: var(--accent); }
314
+ .host span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
315
+ .host span:last-child { color: var(--muted); font-size: 11px; }
316
+ .keyrow { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
317
+ .keyrow small { display: block; font: 11px var(--mono); color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
318
+ .keyrow b { font: 600 12.5px var(--mono); text-align: right; }
319
+ .keyrow b.full { color: #3fd16b; } .keyrow b.part { color: var(--accent); } .keyrow b.none { color: var(--muted); }
320
+ .cal-t { width: 100%; border-collapse: collapse; font: 12.5px var(--mono); }
321
+ .cal-t td, .cal-t th { padding: 6px 4px; border-top: 1px solid var(--line); text-align: right; }
322
+ .cal-t td:first-child, .cal-t th:first-child { text-align: left; }
323
+ .cal-t tr.best td { color: var(--accent); }
324
+ /* ---------- entity profile ---------- */
325
+ .ent-h { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-end; margin: 10px 0 18px; }
326
+ .ent-h .kind { display: inline-block; font: 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; border: 1px solid var(--accent); color: var(--accent); padding: 2px 8px; }
327
+ .ent-h h1 { margin: 10px 0 0; font-size: clamp(30px, 4vw, 52px); font-weight: 300; letter-spacing: -.03em; line-height: 1.05; word-break: break-word; }
328
+ .ent-h .id { font: 12px var(--mono); color: var(--muted); margin-top: 8px; word-break: break-all; }
329
+ .nb { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; cursor: pointer; }
330
+ .nb:hover { color: var(--accent); }
331
+ .nb span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
332
+ .nb span:last-child { font: 11px var(--mono); color: var(--muted); flex: none; }
333
+ .attr { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
334
+ .attr span:first-child { font: 11.5px var(--mono); color: var(--muted); }
335
+ .attr span:last-child { word-break: break-word; }
336
+ .elink { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: rgba(0,240,255,.35); text-underline-offset: 3px; }
337
+ /* ---------- overview layout editing ---------- */
338
+ .ov[draggable="true"] { cursor: grab; }
339
+ .ov.dragging { opacity: .4; }
340
+ .ov.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
341
+ .ov .pin { background: none; border: 0; color: var(--muted); cursor: pointer; font: 13px var(--mono); padding: 0 0 0 10px; }
342
+ .ov .pin:hover { color: var(--accent); }
343
+ .ov-hidden { margin-top: 12px; font: 12px var(--mono); color: var(--muted); }
344
+ .ov-hidden button { background: none; border: 1px solid var(--line); color: var(--muted); font: 11.5px var(--mono); padding: 3px 8px; margin: 0 6px 6px 0; cursor: pointer; }
345
+ @media (max-width: 1100px) { .hosts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
346
+ @media (max-width: 720px) { .hosts { grid-template-columns: minmax(0, 1fr); } .ib { grid-template-columns: 44px minmax(0, 1fr); } .ib .acts { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; } .tl-it { grid-template-columns: 90px 40px minmax(0, 1fr); } }
347
+ </style>
348
+ </head>
349
+ <body>
350
+ <header>
351
+ <a class="brand" href="/">OCULON</a>
352
+ <nav role="tablist">
353
+ <button role="tab" data-tab="overview" aria-selected="true">Overview</button>
354
+ <!--onchain--> <button role="tab" data-tab="robinhood" aria-selected="false">Robinhood</button><!--/onchain-->
355
+ <button role="tab" data-tab="inbox" aria-selected="false">Inbox</button>
356
+ <button role="tab" data-tab="signals" aria-selected="false">Signals</button>
357
+ <button role="tab" data-tab="map">Map</button>
358
+ <button role="tab" data-tab="investigate">Investigate</button>
359
+ <button role="tab" data-tab="cases">Cases</button>
360
+ <button role="tab" data-tab="watch">Watch</button>
361
+ <button role="tab" data-tab="forecasts">Forecasts</button>
362
+ <button role="tab" data-tab="world">World</button>
363
+ <button role="tab" data-tab="calendar">Calendar</button>
364
+ <button role="tab" data-tab="live">Live</button>
365
+ <button role="tab" data-tab="graph">Graph</button>
366
+ <button role="tab" data-tab="timeline">Timeline</button>
367
+ <button role="tab" data-tab="sources">Sources</button>
368
+ <button role="tab" data-tab="accuracy">Accuracy</button>
369
+ </nav>
370
+ <div class="spacer"></div>
371
+ <a class="toplink" href="/docs">Docs</a>
372
+ <span class="status" id="status"></span>
373
+ <button class="icon-btn" id="theme" title="Toggle theme" aria-label="Toggle theme">◐</button>
374
+ </header>
375
+ <main>
376
+ <section id="tab-overview">
377
+ <div class="ov-head">
378
+ <div><div class="ov-k">Overview · <span id="ov-time">live</span></div><h1 class="ov-h">Everything this install is watching.</h1></div>
379
+ <button class="go" id="ov-refresh">Refresh all</button>
380
+ </div>
381
+ <div class="ov-kpis">
382
+ <div class="ov-kpi"><span>Signals · 24h</span><b id="ok-sig">—</b></div>
383
+ <div class="ov-kpi"><span>BGP hijacks · 48h</span><b id="ok-bgp">—</b></div>
384
+ <div class="ov-kpi"><span>Exploited CVEs · 7d</span><b id="ok-kev">—</b></div>
385
+ <!--onchain--> <div class="ov-kpi"><span>Robinhood Chain txs today</span><b id="ok-rh">—</b></div><!--/onchain-->
386
+ <!--offchain--> <div class="ov-kpi"><span>Hosts answered · 24h</span><b id="ok-hosts">—</b></div><!--/offchain-->
387
+ <div class="ov-kpi"><span>Military aircraft now</span><b id="ok-mil">—</b></div>
388
+ <div class="ov-kpi"><span>MCP tools</span><b id="ok-mcp">—</b></div>
389
+ </div>
390
+ <div class="ov-grid">
391
+ <article class="ov w2"><div class="ovh"><span>Exploited in the wild</span><a data-go="world">World →</a></div><div id="ov-kev" class="ovb"><div class="ov-sk"></div></div><div class="ovf">CISA KEV · EPSS</div></article>
392
+ <article class="ov"><div class="ovh"><span>Space weather</span><a data-go="investigate" data-kind="space">Open →</a></div><div id="ov-space" class="ovb"><div class="ov-sk"></div></div><div class="ovf">NOAA SWPC</div></article>
393
+ <article class="ov"><div class="ovh"><span>Cloud and services</span><a data-go="world">World →</a></div><div id="ov-cloud" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Official status pages</div></article>
394
+ <!--onchain--> <article class="ov w2"><div class="ovh"><span>Robinhood Chain · newest pools</span><a data-go="investigate" data-kind="robinhood">Investigate →</a></div><div id="ov-rh" class="ovb"><div class="ov-sk"></div></div><div class="ovf">GeckoTerminal · Blockscout</div></article><!--/onchain-->
395
+ <article class="ov w2"><div class="ovh"><span>Internet outages · 48h</span><a data-go="world">World →</a></div><div id="ov-out" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Cloudflare Radar · IODA</div></article>
396
+ <!--onchain--> <article class="ov"><div class="ovh"><span>DeFi pulse</span><a href="/docs#what-it-does">Docs →</a></div><div id="ov-defi" class="ovb"><div class="ov-sk"></div></div><div class="ovf">DefiLlama</div></article><!--/onchain-->
397
+ <!--offchain--> <article class="ov"><div class="ovh"><span>Disaster alerts</span><a data-go="world">World →</a></div><div id="ov-haz" class="ovb"><div class="ov-sk"></div></div><div class="ovf">GDACS · tsunami.gov</div></article><!--/offchain-->
398
+ <article class="ov"><div class="ovh"><span>Catalysts · 14 days</span><a data-go="calendar">Calendar →</a></div><div id="ov-cal" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Finnhub · FRED · Federal Register</div></article>
399
+ <article class="ov w2"><div class="ovh"><span>Narratives</span><a data-go="signals">Signals →</a></div><div id="ov-narr" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Storylines across days</div></article>
400
+ <article class="ov w2"><div class="ovh"><span>Forecast and proof</span><a data-go="forecasts">Forecasts →</a></div><div id="ov-fc" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Raven · Tortoise · OpenTimestamps</div></article>
401
+ <article class="ov"><div class="ovh"><span>Watchlist</span><a data-go="watch">Watch →</a></div><div id="ov-watch" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Meerkat</div></article>
402
+ <article class="ov"><div class="ovh"><span>Case files</span><a data-go="cases">Cases →</a></div><div id="ov-cases" class="ovb"><div class="ov-sk"></div></div><div class="ovf">Sourced investigations</div></article>
403
+ <article class="ov w4"><div class="ovh"><span>Free-tier budgets today</span><a href="/docs#configuration">Docs →</a></div><div id="ov-quota" class="ovb"><div class="ov-sk"></div></div><div class="ovf">oculon quota</div></article>
404
+ </div>
405
+ </section>
406
+ <!--onchain--> <section id="tab-robinhood" hidden>
407
+ <div class="ov-head"><div><div class="ov-k">Robinhood Chain · Heron · <span id="rh-upd">live</span></div><h1 class="ov-h">Every launch, traced to a wallet.</h1></div>
408
+ <div class="row"><label class="meta"><input type="checkbox" id="rh-auto" checked> auto refresh 60s</label><button class="go" id="rh-refresh">Refresh</button></div></div>
409
+ <div class="ov-kpis" id="rh-kpis">
410
+ <div class="ov-kpi"><span>Block height</span><b id="rk-block">—</b></div>
411
+ <div class="ov-kpi"><span>Transactions today</span><b id="rk-txs">—</b></div>
412
+ <div class="ov-kpi"><span>Addresses</span><b id="rk-addr">—</b></div>
413
+ <div class="ov-kpi"><span>Average gas</span><b id="rk-gas">—</b></div>
414
+ <div class="ov-kpi"><span>New pools flagged</span><b id="rk-flag">—</b></div>
415
+ <div class="ov-kpi"><span>Deployers profiled</span><b id="rk-dep">—</b></div>
416
+ </div>
417
+ <div class="ov-grid">
418
+ <article class="ov w2"><div class="ovh"><span>New pools · newest first</span><span class="meta" id="rh-poolsn"></span></div><div class="ovb" id="rh-pools"><div class="ov-sk"></div></div><div class="ovf">GeckoTerminal · click a pool to check its token</div></article>
419
+ <article class="ov w2"><div class="ovh"><span>Token check</span><a id="rh-share" hidden>Share card →</a></div><div class="ovb">
420
+ <div class="row"><input type="text" id="rh-addr" placeholder="0x… Robinhood Chain token address" aria-label="Token address"><button class="go" id="rh-check">Check</button></div>
421
+ <div id="rh-verdict" style="margin-top:14px"><p class="meta">Pick a pool on the left or paste an address. Oculon reads verification, holders and pool behavior, then the deployer's history.</p></div></div><div class="ovf">Blockscout · GeckoTerminal · heuristics, not an audit</div></article>
422
+ <article class="ov w2"><div class="ovh"><span>Trending pools · 24h</span></div><div class="ovb" id="rh-trend"><div class="ov-sk"></div></div><div class="ovf">GeckoTerminal</div></article>
423
+ <article class="ov w2"><div class="ovh"><span>Deployer board · most tokens launched</span><span class="meta">dead counts appear after a deployer is re-checked</span></div><div class="ovb" id="rh-deps"><div class="ov-sk"></div></div><div class="ovf">Heron deployer memory · click to open</div></article>
424
+ <article class="ov w2"><div class="ovh"><span>Watched Robinhood Chain tokens</span><a data-go="watch">Watch →</a></div><div class="ovb" id="rh-watch"><div class="ov-sk"></div></div><div class="ovf">oculon watch add token 0x…@robinhood</div></article>
425
+ <article class="ov w2"><div class="ovh"><span>Recent Heron signals</span><span class="meta">these reach Telegram when they pass the alert bar</span></div><div class="ovb" id="rh-sigs"><div class="ov-sk"></div></div><div class="ovf">Signals from the schedule</div></article>
426
+ </div>
427
+ </section><!--/onchain-->
428
+
429
+ <section id="tab-inbox" hidden>
430
+ <div class="ov-head"><div><div class="ov-k">Signal inbox · <span id="ib-count">—</span></div><h1 class="ov-h">Read, rate, share.</h1></div>
431
+ <div class="row"><button class="icon-btn" id="ib-allread">Mark all read</button><button class="icon-btn" id="ib-notify">Enable alerts</button></div></div>
432
+ <div class="ib-bar">
433
+ <div class="ib-chips" id="ib-mods"></div>
434
+ <div class="row"><label class="meta">min score <input type="range" id="ib-min" min="0" max="90" step="5" value="0"> <b id="ib-minv">0</b></label><label class="meta"><input type="checkbox" id="ib-unread"> unread only</label><input type="text" id="ib-q" placeholder="filter text" style="max-width:220px" aria-label="Filter"></div>
435
+ </div>
436
+ <div id="ib-list"></div>
437
+ </section>
438
+
439
+ <section id="tab-timeline" hidden>
440
+ <div class="ov-head"><div><div class="ov-k">Timeline · signals stored on this install</div><h1 class="ov-h">Scrub through what Oculon saw.</h1></div>
441
+ <div class="row"><select id="tl-hours" aria-label="Window"><option value="24">24 hours</option><option value="72" selected>3 days</option><option value="168">7 days</option><option value="336">14 days</option></select><button class="icon-btn" id="tl-play">▶ Play</button></div></div>
442
+ <div class="card"><canvas id="tl-chart" height="180"></canvas>
443
+ <input type="range" id="tl-range" min="0" max="100" value="100" style="width:100%" aria-label="Time">
444
+ <div class="row" style="justify-content:space-between"><span class="meta" id="tl-at">—</span><span class="meta" id="tl-win"></span></div></div>
445
+ <div id="tl-list" style="margin-top:16px"></div>
446
+ </section>
447
+
448
+ <section id="tab-sources" hidden>
449
+ <div class="ov-head"><div><div class="ov-k">Sources · health of this install</div><h1 class="ov-h">Who answered, and when.</h1></div><button class="go" id="src-refresh">Refresh</button></div>
450
+ <div class="ov-kpis" id="src-kpis"></div>
451
+ <div class="ov-grid">
452
+ <article class="ov w4"><div class="ovh"><span>Hosts answered · from the response cache</span><span class="meta">fresh = last hour · today = last 24h</span></div><div class="ovb" id="src-hosts"><div class="ov-sk"></div></div></article>
453
+ <article class="ov w2"><div class="ovh"><span>Optional keys</span><a href="/docs#configuration">How to add →</a></div><div class="ovb" id="src-keys"><div class="ov-sk"></div></div><div class="ovf">names only; key values never leave the server</div></article>
454
+ <article class="ov w2"><div class="ovh"><span>Daily budgets</span></div><div class="ovb" id="src-quota"><div class="ov-sk"></div></div><div class="ovf">oculon quota</div></article>
455
+ </div>
456
+ </section>
457
+
458
+ <section id="tab-accuracy" hidden>
459
+ <div class="ov-head"><div><div class="ov-k">Accuracy · measured, not claimed</div><h1 class="ov-h">How good is the radar?</h1></div></div>
460
+ <div class="ov-kpis" id="acc-kpis"></div>
461
+ <div class="ov-grid">
462
+ <article class="ov w2"><div class="ovh"><span>First to know</span><a data-go="signals">Signals →</a></div><div class="ovb" id="acc-scoops"><div class="ov-sk"></div></div><div class="ovf">lead time of Oculon signals vs first media coverage</div></article>
463
+ <article class="ov w2"><div class="ovh"><span>Radar calibration</span></div><div class="ovb" id="acc-cal"><div class="ov-sk"></div></div><div class="ovf">oculon calibrate · replayed past days</div></article>
464
+ <article class="ov w4"><div class="ovh"><span>Forecast scoreboard</span><a data-go="forecasts">Forecasts →</a></div><div class="ovb" id="acc-fc"><div class="ov-sk"></div></div><div class="ovf">Brier scores appear once markets resolve</div></article>
465
+ </div>
466
+ </section>
467
+
468
+ <section id="tab-entity" hidden>
469
+ <div id="ent-body"><div class="ov-sk"></div></div>
470
+ </section>
471
+ <section id="tab-signals" hidden>
472
+ <div class="card" style="margin-bottom:16px">
473
+ <div class="row" style="justify-content:space-between"><h2>Today's brief</h2><button class="icon-btn" id="brief-refresh">Rewrite</button></div>
474
+ <div id="brief" class="md meta">Loading…</div>
475
+ </div>
476
+ <div class="card" style="margin-bottom:16px">
477
+ <h2>Ask Oculon</h2>
478
+ <div class="row">
479
+ <input type="text" id="ask-q" placeholder="Why is Nvidia in the news this week?" aria-label="Question">
480
+ <button class="go" id="ask-go">Ask</button>
481
+ </div>
482
+ <div id="ask-out" class="out"></div>
483
+ </div>
484
+ <div class="grid">
485
+ <div class="card">
486
+ <div class="row" style="justify-content:space-between"><h2>Signal feed</h2><button class="go" id="run-radar">Run radar</button></div>
487
+ <div id="signals"></div>
488
+ </div>
489
+ <div>
490
+ <div class="card" style="margin-bottom:16px">
491
+ <div class="row" style="justify-content:space-between"><h2>Narratives</h2><a class="icon-btn" href="/report" target="_blank" rel="noopener">Weekly report</a></div>
492
+ <div id="narratives" class="meta">Loading…</div>
493
+ </div>
494
+ <div class="card" style="margin-bottom:16px">
495
+ <h2>First to know</h2>
496
+ <div id="scoops" class="meta">Loading…</div>
497
+ </div>
498
+ <div class="card">
499
+ <h2>Radar sources</h2>
500
+ <div id="radar-sources" class="meta">Run the radar to see which sources answered.</div>
501
+ </div>
502
+ </div>
503
+ </div>
504
+ </section>
505
+
506
+ <section id="tab-cases" hidden>
507
+ <div class="card">
508
+ <h2>Open a case</h2>
509
+ <div class="row">
510
+ <!--onchain--> <input type="text" id="case-q" placeholder="Who is behind the token 0x…? / Is company X about to launch Y?" aria-label="Case question"><!--/onchain-->
511
+ <!--offchain--> <input type="text" id="case-q" placeholder="Who is behind example.com? / Is company X about to launch Y?" aria-label="Case question"><!--/offchain-->
512
+ <button class="go" id="case-go">Investigate</button>
513
+ </div>
514
+ <p class="meta">A deeper investigation (1-3 minutes). Every cited source is checked against what the tools really returned.</p>
515
+ </div>
516
+ <div class="grid" style="margin-top:16px">
517
+ <div class="card"><h2>Case files</h2><div id="case-list"></div></div>
518
+ <div class="card"><div id="case-view" class="md meta">Select a case.</div></div>
519
+ </div>
520
+ </section>
521
+
522
+ <section id="tab-map" hidden>
523
+ <div class="card">
524
+ <div class="row" style="justify-content:space-between">
525
+ <h2>Live map</h2>
526
+ <div class="row">
527
+ <label class="meta"><input type="checkbox" data-layer="air" checked> military aircraft</label>
528
+ <label class="meta"><input type="checkbox" data-layer="quakes" checked> earthquakes</label>
529
+ <label class="meta"><input type="checkbox" data-layer="events" checked> natural events</label>
530
+ <label class="meta"><input type="checkbox" data-layer="fences" checked> fences</label>
531
+ <button class="icon-btn" id="draw-fence">Draw fence</button>
532
+ <button class="go" id="load-map">Refresh</button>
533
+ </div>
534
+ </div>
535
+ <div id="map"></div>
536
+ <div class="legend">
537
+ <span><i class="dot" style="background:#00f0ff"></i>notable military role (tanker, AWACS, ISR, bomber…)</span>
538
+ <span><i class="dot" style="background:#ffffff"></i>other military aircraft</span>
539
+ <span><i class="dot" style="background:#8a8a8a"></i>earthquake M4.5+ (24h)</span>
540
+ <span><i class="dot" style="background:#ff9f43"></i>natural event (NASA EONET)</span>
541
+ <span><i class="dot" style="background:#00f0ff;outline:1px solid #00f0ff;background:none"></i>your fences</span>
542
+ </div>
543
+ <div id="map-meta" class="meta" style="margin-top:6px"></div>
544
+ </div>
545
+ </section>
546
+
547
+ <section id="tab-investigate" hidden>
548
+ <div class="card">
549
+ <div class="row">
550
+ <select id="inv-kind" aria-label="What to investigate">
551
+ <optgroup label="Everyday checks">
552
+ <option value="scam">Is this message a scam? (paste it)</option>
553
+ <option value="url">Is this link safe? (URL)</option>
554
+ <option value="factcheck">Fact check (claim or news URL)</option>
555
+ <option value="audit">Dependency audit (package.json or npm:name@version)</option>
556
+ <option value="travel">Travel risk (place)</option>
557
+ <option value="recall">Recall check (VIN, "2018 Honda Accord", or product)</option>
558
+ <option value="emailsec">Email security (domain)</option>
559
+ <option value="airport">Airport status (JFK, EGLL…)</option>
560
+ <option value="country">Country brief</option>
561
+ <option value="papers">Research papers (topic)</option>
562
+ </optgroup>
563
+ <optgroup label="Investigate">
564
+ <option value="dossier">Dossier (company, person)</option>
565
+ <option value="hype">Hype phase (topic)</option>
566
+ <option value="footprint">Pre-release footprint (domain)</option>
567
+ <option value="lights">Night lights (place)</option>
568
+ <option value="aircraft">Aircraft (registration / hex)</option>
569
+ <option value="image">Satellite image (place)</option>
570
+ <!--onchain--> <option value="wallet">Wallet (0x… or Solana address)</option><!--/onchain-->
571
+ <!--onchain--> <option value="token">Token contract (0x…, Ethereum)</option><!--/onchain-->
572
+ <option value="air">Air quality (place)</option>
573
+ <option value="space">Space weather</option>
574
+ <!--onchain--> <option value="robinhood">Robinhood Chain pools</option><!--/onchain-->
575
+ <!--onchain--> <option value="deployer">Robinhood Chain deployer (token or wallet)</option><!--/onchain-->
576
+ <option value="launches">Launch radar (company)</option>
577
+ <option value="markets">Prediction markets cross-check</option>
578
+ <option value="rewind">Time machine (YYYY-MM-DD)</option>
579
+ <!--onchain--> <option value="sanctions">Sanctions screening (wallet, IMO, name)</option><!--/onchain-->
580
+ <!--offchain--> <option value="sanctions">Sanctions screening (IMO or name)</option><!--/offchain-->
581
+ <option value="health">Company health score</option>
582
+ <option value="impact">Disaster impact (place, or empty for current events)</option>
583
+ <option value="contradictions">Contradictions across sources (topic)</option>
584
+ </optgroup>
585
+ </select>
586
+ <input type="text" id="inv-q" placeholder="paypa1-secure-login.top/verify" aria-label="Query">
587
+ <button class="go" id="inv-go">Investigate</button>
588
+ </div>
589
+ <div id="inv-out" class="out"></div>
590
+ </div>
591
+ </section>
592
+
593
+ <section id="tab-watch" hidden>
594
+ <div class="card">
595
+ <h2>Your monitors</h2>
596
+ <p class="meta">Describe what to watch in plain words. Oculon turns it into a rule, re-checks it about every hour and tells you only what changed, with evidence. Your monitors are private to this browser; no account needed.</p>
597
+ <div class="row"><input type="text" id="mon-q" placeholder="Tell me when there is an internet outage in Iran" aria-label="What to watch"><button class="go" id="mon-go">Monitor</button></div>
598
+ <p class="meta" id="mon-ex">Try: <a href="#" data-mon>critical CVEs for nginx</a> · <a href="#" data-mon>earthquakes above 6 near Tokyo</a> · <a href="#" data-mon>news about OpenAI</a> · <a href="#" data-mon>travel risk changes for Bangkok</a> · <a href="#" data-mon>flood or cyclone alerts for the Philippines</a></p>
599
+ <div id="mon-out"></div>
600
+ <div style="overflow-x:auto"><table id="my-mon"></table></div>
601
+ <h3>Email me when something changes</h3>
602
+ <div class="row"><input type="email" id="mail-q" placeholder="you@example.com" aria-label="Email for alerts" autocomplete="email"><button class="go" id="mail-go">Send confirmation</button></div>
603
+ <p class="meta" id="mail-state">One email per check that finds changes. Unsubscribe from any email. Telegram works too: send /monitor to <a href="https://t.me/oculon_radar_bot" id="tg-link" target="_blank" rel="noopener noreferrer">the Oculon bot</a>.</p>
604
+ <h3>Your recent changes</h3>
605
+ <div id="my-alerts"><p class="meta">Nothing yet. The first check of each monitor records a baseline.</p></div>
606
+ </div>
607
+ <div class="card" style="margin-top:16px">
608
+ <h2>Shared watchlist</h2>
609
+ <p class="meta" id="shared-note">What this Oculon install watches for everyone. Managed by the owner.</p>
610
+ <div style="overflow-x:auto"><table id="watch"></table></div>
611
+ </div>
612
+ <div class="card" style="margin-top:16px">
613
+ <h2>Recent watch changes</h2>
614
+ <div id="watch-signals"></div>
615
+ </div>
616
+ <div class="card" style="margin-top:16px">
617
+ <h2>API usage today</h2>
618
+ <div style="overflow-x:auto"><table id="quota"></table></div>
619
+ </div>
620
+ </section>
621
+
622
+ <section id="tab-forecasts" hidden>
623
+ <div class="card">
624
+ <h2>Track record</h2>
625
+ <div class="kpis" id="kpis"></div>
626
+ </div>
627
+ <div class="card" style="margin-top:16px">
628
+ <h2>Forecasts</h2>
629
+ <div style="overflow-x:auto"><table id="fc"></table></div>
630
+ <div id="proof" class="out"></div>
631
+ </div>
632
+ </section>
633
+
634
+ <section id="tab-world" hidden>
635
+ <div class="grid">
636
+ <div class="card">
637
+ <h2>Internet outages</h2>
638
+ <p class="meta">Cloudflare Radar confirmed outages and anomalies, IODA scores, RIPEstat routing.</p>
639
+ <div id="w-blackout" class="meta">Loading…</div>
640
+ </div>
641
+ <div>
642
+ <div class="card" style="margin-bottom:16px">
643
+ <h2>Disaster alerts</h2>
644
+ <p class="meta">GDACS orange and red alerts, tsunami bulletins, extreme US weather.</p>
645
+ <div id="w-hazards" class="meta">Loading…</div>
646
+ </div>
647
+ <div class="card">
648
+ <h2>Cloud and services</h2>
649
+ <p class="meta">Official status pages: AWS, Azure, Google Cloud, GitHub, Cloudflare, OpenAI and more.</p>
650
+ <div id="w-cloud" class="meta">Loading…</div>
651
+ </div>
652
+ </div>
653
+ </div>
654
+ </section>
655
+
656
+ <section id="tab-calendar" hidden>
657
+ <div class="card">
658
+ <div class="row" style="justify-content:space-between"><h2>Catalyst calendar</h2><span class="meta" id="cal-meta"></span></div>
659
+ <p class="meta">Earnings (watched companies first, then the largest), key US macro releases, and high-volume prediction markets closing. ★ marks a watched company or an open Oculon forecast.</p>
660
+ <div id="calendar" class="meta">Loading…</div>
661
+ </div>
662
+ </section>
663
+
664
+ <section id="tab-live" hidden>
665
+ <div class="card">
666
+ <h2>Live streams</h2>
667
+ <p class="meta">Wikipedia articles suddenly edited by several people, and names or hashtags surging in English Bluesky posts. Runs with <code>oculon serve --live</code>.</p>
668
+ <div id="live"></div>
669
+ </div>
670
+ </section>
671
+
672
+ <section id="tab-graph" hidden>
673
+ <div class="card" style="margin-bottom:16px">
674
+ <h2>How are they connected?</h2>
675
+ <div class="row">
676
+ <input type="text" id="con-a" placeholder="Nvidia" aria-label="First thing">
677
+ <input type="text" id="con-b" placeholder="Jensen Huang" aria-label="Second thing">
678
+ <button class="go" id="con-go">Find path</button>
679
+ </div>
680
+ <div id="con-out" class="out"></div>
681
+ </div>
682
+ <div class="card">
683
+ <div class="row" style="justify-content:space-between"><h2>Entity graph</h2><span class="meta" id="graph-meta"></span></div>
684
+ <canvas id="graph"></canvas>
685
+ <div class="meta" id="graph-hover" style="margin-top:6px">Hover a node to see it; click to open its neighbors.</div>
686
+ </div>
687
+ </section>
688
+ </main>
689
+
690
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.min.js"></script>
691
+ <script src="/assets/fx.js"></script>
692
+ <script>
693
+ 'use strict';
694
+ const $ = (s) => document.querySelector(s);
695
+ const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
696
+ const safeUrl = (u) => (/^https?:\/\//i.test(u || '') ? esc(u) : '#');
697
+ const status = (t, bad) => { const el = $('#status'); el.textContent = t; el.className = 'status' + (bad ? ' err' : ''); };
698
+
699
+ async function api(path) {
700
+ status('loading ' + path.split('?')[0] + '…');
701
+ const t0 = performance.now();
702
+ const res = await fetch(path);
703
+ const body = await res.json().catch(() => ({ error: 'bad response' }));
704
+ if (!res.ok) { status(body.error || res.statusText, true); throw new Error(body.error || res.statusText); }
705
+ status(path.split('?')[0] + ' ' + Math.round(performance.now() - t0) + 'ms');
706
+ return body;
707
+ }
708
+
709
+ /* theme */
710
+ try { const t = localStorage.getItem('oculon-theme'); if (t) document.documentElement.dataset.theme = t; } catch {}
711
+ $('#theme').onclick = () => {
712
+ const cur = document.documentElement.dataset.theme || 'dark';
713
+ const next = cur === 'dark' ? 'light' : 'dark';
714
+ document.documentElement.dataset.theme = next;
715
+ try { localStorage.setItem('oculon-theme', next); } catch {}
716
+ if (graphState) drawGraph();
717
+ };
718
+
719
+ /* tabs */
720
+ const loaded = {};
721
+ document.querySelectorAll('nav button').forEach((b) => b.onclick = () => {
722
+ document.querySelectorAll('nav button').forEach((x) => x.setAttribute('aria-selected', x === b));
723
+ document.querySelectorAll('main > section').forEach((s) => s.hidden = s.id !== 'tab-' + b.dataset.tab);
724
+ const t = b.dataset.tab;
725
+ if (!loaded[t]) { loaded[t] = true; ({ /*onchain*/robinhood: loadRobinhood, /*/onchain*/inbox: loadInbox, timeline: loadTimeline, sources: loadSources, accuracy: loadAccuracy, overview: loadOverview, map: loadMap, forecasts: loadForecasts, graph: loadGraph, watch: loadWatch, cases: loadCases, calendar: loadCalendar, live: loadLive, world: loadWorld })[t]?.(); }
726
+ if (t === 'map' && map) setTimeout(() => map.invalidateSize(), 50);
727
+ if (t === 'graph' && graphState) drawGraph();
728
+ });
729
+
730
+
731
+ /* overview: live preview cards, each linking to the tab with the full view */
732
+ const ovAgo = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'just now' : m < 60 ? `${m} min ago` : `${Math.round(m / 60)} h ago`; };
733
+ const ovFail = (id) => () => { const el = document.getElementById(id); if (el) el.innerHTML = '<p class="meta">Unavailable right now.</p>'; };
734
+ const ovMeters = (root) => setTimeout(() => root.querySelectorAll('[data-w]').forEach((i) => { i.style.width = `${i.dataset.w}%`; }), 80);
735
+ const ovSet = (id, v) => { const el = document.getElementById(id); el.textContent = v; delete el.dataset.counted; };
736
+ function ovCount(id, n) { const el = document.getElementById(id); el.textContent = Number(n).toLocaleString('en-US'); }
737
+ document.querySelectorAll('.ov-kpi').forEach((el, i) => el.style.setProperty('--i', i));
738
+ document.querySelectorAll('#tab-overview [data-go]').forEach((a) => a.addEventListener('click', () => {
739
+ document.querySelector(`nav button[data-tab="${a.dataset.go}"]`)?.click();
740
+ if (a.dataset.kind) { const s = document.getElementById('inv-kind'); if (s) { s.value = a.dataset.kind; s.dispatchEvent(new Event('change')); } }
741
+ scrollTo({ top: 0, behavior: 'smooth' });
742
+ }));
743
+ async function loadOverview() {
744
+ document.getElementById('ov-time').textContent = new Date().toUTCString().slice(17, 22) + ' UTC';
745
+ api('/api/meta').then((m) => ovCount('ok-mcp', m.mcpTools)).catch(() => ovSet('ok-mcp', 'n/a'));
746
+ api('/api/signals?limit=200').then((s) => { const n = s.filter((x) => Date.now() - Date.parse(x.createdAt) < 864e5).length; if (n >= 200) ovSet('ok-sig', '200+'); else ovCount('ok-sig', n); }).catch(() => ovSet('ok-sig', 'n/a'));
747
+ api('/api/bgp').then((b) => ovCount('ok-bgp', b.result.incidents.hijacks.length)).catch(() => ovSet('ok-bgp', 'n/a'));
748
+ api('/api/military').then((m) => ovCount('ok-mil', m.result.withPosition ?? m.aircraft.length)).catch(() => ovSet('ok-mil', 'n/a'));
749
+ api('/api/vulns').then((r) => {
750
+ ovCount('ok-kev', r.result.kev.length);
751
+ const rows = r.result.kev.slice(0, 5).map((k) => { const d = k.dueDate ? Math.round((Date.parse(k.dueDate) - Date.now()) / 864e5) : null; return `<div class="ov-kev"><div><b>${esc(k.cveID)}</b> ${esc(k.vendorProject)} ${esc(k.product)}</div><div class="ov-meter" title="EPSS ${k.epss ?? 'n/a'}"><i data-w="${k.epss == null ? 0 : Math.max(3, k.epss * 100).toFixed(1)}"></i></div><div class="ov-due ${d != null && d <= 3 ? 'hot' : ''}">${d == null ? '' : d >= 0 ? `due ${d}d` : `${-d}d over`}</div></div>`; }).join('');
752
+ const el = document.getElementById('ov-kev');
753
+ el.innerHTML = `<div style="display:flex;gap:28px;align-items:baseline;margin-bottom:6px"><div class="ov-big">${r.result.kev.length}<small>newly exploited</small></div><div class="ov-big" style="font-size:26px">${r.result.criticalCves?.length ?? 0}<small>critical CVEs</small></div></div>${rows}<div class="meta" style="margin-top:8px">bar = EPSS · ${esc(ovAgo(r.generatedAt))}</div>`;
754
+ ovMeters(el);
755
+ }).catch(ovFail('ov-kev'));
756
+ api('/api/space').then((r) => {
757
+ const s = r.result, kp = (s.kp || []).slice(-24);
758
+ document.getElementById('ov-space').innerHTML = `<div class="ov-big">Kp ${esc(s.kpNow)}<small>max ${esc(s.kpMax24h)} · 24h</small></div><div class="ov-kv" style="margin-top:10px"><span>Storm level</span><span>${esc(s.stormLevel || 'none')}</span></div><div class="ov-kv"><span>Strongest flare</span><span>${esc(s.strongestFlare?.maxClass || '—')}</span></div><div class="ov-bars">${kp.map((k, i) => `<i class="${k.kp >= 5 ? 'hot' : ''}" style="height:${Math.max(3, (k.kp / 9) * 100)}%;animation-delay:${i * 25}ms"></i>`).join('')}</div>`;
759
+ }).catch(ovFail('ov-space'));
760
+ api('/api/cloud').then((r) => {
761
+ const s = r.result, deg = s.degraded || [];
762
+ document.getElementById('ov-cloud').innerHTML = `<div class="ov-big">${s.checked - deg.length}<small>of ${s.checked} up</small></div><div style="margin-top:10px">${deg.slice(0, 5).map((d) => `<div class="ov-kv"><span><i class="ov-dot ${/major|critical/.test(d.indicator) ? 'bad' : 'warn'}"></i>${esc(d.service)}</span><span>${esc(d.indicator)}</span></div>`).join('') || '<div class="ov-kv"><span><i class="ov-dot"></i>All operational</span><span>ok</span></div>'}</div>`;
763
+ }).catch(ovFail('ov-cloud'));
764
+ /*onchain*/ api('/api/robinhood').then((r) => {
765
+ const st = r.result.stats, fresh = r.result.fresh.slice(0, 6);
766
+ if (st) ovCount('ok-rh', st.transactionsToday);
767
+ document.getElementById('ov-rh').innerHTML = (st ? `<div class="ov-chain"><div>Block<b>${Number(st.blocks).toLocaleString('en-US')}</b></div><div>Addresses<b>${Number(st.addresses).toLocaleString('en-US')}</b></div><div>Gas<b>${esc(st.gasAverage)} gwei</b></div></div>` : '') +
768
+ fresh.map((p) => `<div class="ov-pool"><span>${esc(p.pool.name)} <span class="meta">· ${p.ageHours.toFixed(1)}h</span></span><span class="f ${p.flags.length ? 'bad' : ''}">${esc(p.flags[0] || `${p.pool.buys24h}/${p.pool.sells24h} buys/sells`)}</span></div>`).join('');
769
+ }).catch((e) => { ovFail('ov-rh')(e); ovSet('ok-rh', 'n/a'); });/*/onchain*//*offchain*/
770
+ api('/api/sources').then((sh) => ovCount('ok-hosts', sh.hosts.filter((h) => h.state !== 'stale').length)).catch(() => ovSet('ok-hosts', 'n/a'));/*/offchain*/
771
+ api('/api/blackout').then((r) => {
772
+ const o = (r.result.outages || []).slice(0, 4);
773
+ document.getElementById('ov-out').innerHTML = o.map((x) => `<div class="ov-out"><div class="t"><span><i class="ov-dot ${x.end ? '' : 'bad'}"></i>${esc(x.country || x.countryCode || 'Unknown')}${x.network ? ` · ${esc(x.network)}` : ''}</span><span>${x.end ? 'ended' : 'ongoing'} · ${esc((x.start || '').slice(5, 16).replace('T', ' '))}</span></div>${x.description ? `<p>${esc(x.description)}</p>` : ''}</div>`).join('') || '<p class="meta">No confirmed outages in the window.</p>';
774
+ }).catch(ovFail('ov-out'));
775
+ /*onchain*/ api('/api/defi').then((r) => {
776
+ const t = r.result.totals, drop = r.result.tvlDrops?.[0], dep = r.result.depegs?.[0];
777
+ document.getElementById('ov-defi').innerHTML = `<div class="ov-big">$${(t.defiTvl / 1e9).toFixed(1)}B<small>TVL</small></div><div class="ov-kv" style="margin-top:10px"><span>7 day change</span><span style="color:${t.defiTvlChange7d < 0 ? 'var(--bad)' : '#3fd16b'}">${t.defiTvlChange7d > 0 ? '+' : ''}${t.defiTvlChange7d.toFixed(2)}%</span></div>${drop ? `<div class="ov-kv"><span>Drop · ${esc(drop.name)}</span><span>${drop.change1d.toFixed(0)}% 1d</span></div>` : ''}${dep ? `<div class="ov-kv"><span>Off peg · ${esc(dep.symbol)}</span><span>${dep.offPct.toFixed(1)}%</span></div>` : ''}<div class="ov-kv"><span>DEX volume 24h</span><span>$${(t.dexVolume24h / 1e9).toFixed(2)}B</span></div>`;
778
+ }).catch(ovFail('ov-defi'));/*/onchain*//*offchain*/
779
+ api('/api/hazards').then((r) => {
780
+ const alerts = (r.result || []).slice(0, 4), bulls = (r.bulletins || []).slice(0, 2);
781
+ document.getElementById('ov-haz').innerHTML = `<div class="ov-big">${(r.result || []).length}<small>alerts</small></div><div style="margin-top:10px">${alerts.map((a) => `<div class="ov-kv"><span><i class="ov-dot ${/red/i.test(a.level) ? 'bad' : 'warn'}"></i>${esc(a.type)} · ${esc(a.name)}</span><span>${esc(a.level)}</span></div>`).join('')}${bulls.map((b) => `<div class="ov-kv"><span>tsunami · ${esc(b.area)}</span><span>${esc(b.category)}</span></div>`).join('')}</div>`;
782
+ }).catch(ovFail('ov-haz'));/*/offchain*/
783
+ api('/api/calendar?days=14').then((r) => {
784
+ const today = new Date().toISOString().slice(0, 10);
785
+ const items = (r.result.items || []).filter((i) => i.date >= today && i.kind !== 'market').slice(0, 5);
786
+ document.getElementById('ov-cal').innerHTML = items.map((i) => `<div class="ov-cal"><div class="d">${esc(new Date(i.date + 'T00:00:00Z').toUTCString().slice(5, 11))}</div><div><div class="k">${esc(i.kind)}</div><div class="ti">${esc(i.title)}</div></div></div>`).join('') || '<p class="meta">Nothing scheduled.</p>';
787
+ }).catch(ovFail('ov-cal'));
788
+ api('/api/narratives').then((list) => {
789
+ document.getElementById('ov-narr').innerHTML = list.length ? `<div class="ov-narr">${list.slice(0, 3).map((n) => { const mx = Math.max(1, ...n.daily); return `<div class="ov-n"><span class="ph">${esc(n.phase)}</span><h4>${esc(n.name)}</h4><div class="ov-bars">${n.daily.map((d, i) => `<i style="height:${Math.max(4, (d / mx) * 100)}%;animation-delay:${i * 60}ms"></i>`).join('')}</div><div class="m">${n.total} items · 7 days</div></div>`; }).join('')}</div>` : '<p class="meta">No storylines yet.</p>';
790
+ }).catch(ovFail('ov-narr'));
791
+ api('/api/forecasts').then(async (r) => {
792
+ const f = r.forecasts[0], el = document.getElementById('ov-fc');
793
+ if (!f) { el.innerHTML = '<p class="meta">No forecasts yet.</p>'; return; }
794
+ el.innerHTML = `<div style="font-size:18px;line-height:1.3">${esc(f.question)}</div><div style="margin-top:12px"><div class="ov-prob"><span>Oculon</span><div class="ov-meter"><i data-w="${(f.pModel * 100).toFixed(1)}"></i></div><span>${Math.round(f.pModel * 100)}%</span></div><div class="ov-prob mk"><span>Market</span><div class="ov-meter"><i data-w="${(f.pMarket * 100).toFixed(1)}"></i></div><span>${Math.round(f.pMarket * 100)}%</span></div></div><div class="meta" style="margin-top:8px">${esc(f.rationale)}</div><div id="ov-ver"></div>`;
795
+ ovMeters(el);
796
+ try { const v = await api(`/api/verify?id=${encodeURIComponent(f.id)}`); document.getElementById('ov-ver').innerHTML = `<div class="ov-ver">● ${esc(v.result.status)}${v.result.bitcoin?.height ? ` · BITCOIN BLOCK ${esc(v.result.bitcoin.height)}` : ''}</div>`; } catch {}
797
+ }).catch(ovFail('ov-fc'));
798
+ api('/api/watch').then((w) => {
799
+ const kinds = {}; w.forEach((x) => { kinds[x.kind] = (kinds[x.kind] || 0) + 1; });
800
+ const last = w.map((x) => x.lastRun).filter(Boolean).sort().pop();
801
+ document.getElementById('ov-watch').innerHTML = `<div class="ov-big">${w.length}<small>targets</small></div><div style="margin-top:12px">${Object.entries(kinds).map(([k, n]) => `<span class="ov-chip">${esc(k)} ${n}</span>`).join('')}</div>${w.slice(0, 3).map((x) => `<div class="ov-kv"><span>${esc(x.label || x.target)}</span><span>${esc(x.kind)}</span></div>`).join('')}<div class="meta" style="margin-top:8px">${last ? `last run ${esc(ovAgo(last))}` : 'not run yet'}</div>`;
802
+ }).catch(ovFail('ov-watch'));
803
+ api('/api/cases').then((c) => {
804
+ document.getElementById('ov-cases').innerHTML = c.length ? `<div class="ov-big">${c.length}<small>cases</small></div><div style="margin-top:10px">${c.slice(0, 3).map((k) => `<div class="ov-kv"><span>${esc(k.question)}</span><span>${esc(k.confidence ?? '—')}</span></div>`).join('')}</div>` : '<p class="meta">No cases yet. Open one in the Cases tab.</p>';
805
+ }).catch(ovFail('ov-cases'));
806
+ api('/api/quota').then((q) => {
807
+ const top = q.filter((x) => x.budget).sort((a, b) => b.used / b.budget - a.used / a.budget).slice(0, 8);
808
+ const el = document.getElementById('ov-quota');
809
+ el.innerHTML = `<div class="ov-qgrid">${top.map((x) => `<div class="ov-q"><div class="t"><span>${esc(x.source)}</span><span>${x.used} / ${x.budget}</span></div><div class="ov-meter"><i data-w="${Math.max(1.5, Math.min(100, (x.used / x.budget) * 100)).toFixed(1)}"></i></div></div>`).join('')}</div>`;
810
+ ovMeters(el);
811
+ }).catch(ovFail('ov-quota'));
812
+ }
813
+ document.getElementById('ov-refresh').onclick = () => { document.querySelectorAll('#tab-overview .ovb').forEach((b) => { b.innerHTML = '<div class="ov-sk"></div>'; }); loadOverview(); };
814
+
815
+ /* signals */
816
+ const scoreClass = (s) => (s >= 75 ? 'hi' : s >= 55 ? 'mid' : 'lo');
817
+ function renderSignal(s) {
818
+ const ev = (s.evidence || []).slice(0, 4).map((e) => `<li><span class="chip">${esc(e.source)}</span>${e.url ? `<a href="${safeUrl(e.url)}" target="_blank" rel="noopener noreferrer">${esc(e.text)}</a>` : esc(e.text)}</li>`).join('');
819
+ return `<div class="sig"><div class="score ${scoreClass(s.score)}">${Math.round(s.score)}</div><div><div class="title">${esc(s.title)}</div><div class="meta"><span class="chip">${esc(s.module)}</span>${esc((s.createdAt || '').replace('T', ' ').slice(0, 16))} UTC</div><ul class="ev">${ev}</ul></div></div>`;
820
+ }
821
+ async function loadSignals() {
822
+ const sigs = await api('/api/signals?limit=60');
823
+ $('#signals').innerHTML = sigs.length ? sigs.map(renderSignal).join('') : '<p class="meta">No signals yet. Run the radar.</p>';
824
+ }
825
+ function renderSources(p) {
826
+ return Object.entries(p.sources).map(([src, st]) => `<div class="row" style="justify-content:space-between;padding:4px 0;border-top:1px solid var(--line)"><span class="chip">${esc(src)}</span><span class="meta">${Object.entries(st).map(([k, v]) => `${esc(k)} ×${v}`).join(' ')}</span></div>`).join('') + (p.notes.length ? `<ul class="ev">${p.notes.map((n) => `<li>${esc(n)}</li>`).join('')}</ul>` : '');
827
+ }
828
+ $('#run-radar').onclick = async (e) => {
829
+ e.target.disabled = true;
830
+ try { const r = await api('/api/radar'); $('#radar-sources').innerHTML = renderSources(r.provenance); await loadSignals(); }
831
+ catch (err) { $('#radar-sources').innerHTML = `<p class="err">${esc(err.message)}</p>`; }
832
+ finally { e.target.disabled = false; }
833
+ };
834
+ loadSignals().catch(() => {});
835
+
836
+ /* map: layers + fences */
837
+ let map;
838
+ const layers = {};
839
+ async function post(path, body) {
840
+ const res = await fetch(path, { method: 'POST', headers: { 'content-type': 'application/json', 'x-oculon': '1' }, body: JSON.stringify(body) });
841
+ const out = await res.json().catch(() => ({ error: 'bad response' }));
842
+ if (!res.ok) throw new Error(out.error || res.statusText);
843
+ return out;
844
+ }
845
+ function syncLayers() {
846
+ document.querySelectorAll('[data-layer]').forEach((cb) => { const l = layers[cb.dataset.layer]; if (!l) return; if (cb.checked) l.addTo(map); else l.remove(); });
847
+ }
848
+ document.querySelectorAll('[data-layer]').forEach((cb) => (cb.onchange = syncLayers));
849
+ async function loadFences() {
850
+ layers.fences.clearLayers();
851
+ const fences = await api('/api/fences');
852
+ for (const f of fences) {
853
+ const [s, w, n, e] = f.box;
854
+ const now = f.now ? `<br>${f.now.milAircraft.length} mil aircraft, ${f.now.milVessels.length} mil vessels, ${f.now.quakes.length} quakes, ${f.now.events.length} events` : '<br><i>not checked yet</i>';
855
+ const rect = L.rectangle([[s, w], [n, e]], { color: '#00f0ff', weight: 2, fillOpacity: .06, className: 'mk-fence' })
856
+ .bindPopup(`<b>${esc(f.name)}</b> (#${f.id})<br>${esc(f.kinds.join(', '))}${now}<br><button class="icon-btn" data-del-fence="${f.id}">Delete fence</button>`);
857
+ rect.on('popupopen', () => document.querySelector(`[data-del-fence="${f.id}"]`)?.addEventListener('click', async () => { await post('/api/fences/delete', { id: f.id }); loadFences(); }));
858
+ rect.addTo(layers.fences);
859
+ }
860
+ return fences.length;
861
+ }
862
+ async function loadMap() {
863
+ if (!window.L) { $('#map-meta').innerHTML = '<span class="err">Map library could not load (offline?).</span>'; return; }
864
+ if (!map) {
865
+ map = L.map('map', { worldCopyJump: true }).setView([25, 10], 2);
866
+ L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noopener">OpenStreetMap</a> contributors', maxZoom: 12, className: 'osm-tiles' }).addTo(map);
867
+ for (const k of ['air', 'quakes', 'events', 'fences']) layers[k] = L.layerGroup();
868
+ }
869
+ for (const k in layers) layers[k].clearLayers();
870
+ $('#load-map').disabled = true;
871
+ try {
872
+ const [mil, ev, quakes, nf] = await Promise.all([api('/api/military'), api('/api/events'), api('/api/quakes'), loadFences()]);
873
+ const notable = new Set(mil.result.regions.flatMap((r) => r.notable.map((n) => n.hex)));
874
+ for (const a of mil.aircraft) {
875
+ const hot = notable.has(a.hex);
876
+ L.circleMarker([a.lat, a.lon], { radius: hot ? 7 : 4, color: hot ? '#00f0ff' : '#ffffff', weight: 1, fillOpacity: .8, className: hot ? 'mk-pulse' : 'mk-blink' })
877
+ .bindPopup(`<b>${esc(a.callsign || a.reg || a.hex)}</b><br>${esc(a.type || '?')} · ${esc(a.reg || '')}<br>alt ${esc(a.alt)}<br><a href="https://globe.adsb.lol/?icao=${esc(a.hex)}" target="_blank" rel="noopener noreferrer">live track</a>`)
878
+ .addTo(layers.air);
879
+ }
880
+ for (const q of quakes.filter((x) => x.lat !== null)) {
881
+ L.circleMarker([q.lat, q.lon], { radius: Math.max(4, (q.mag - 3) * 3), color: '#8a8a8a', weight: 2, fillOpacity: .35, className: 'mk-pulse' })
882
+ .bindPopup(`<b>M${esc(q.mag.toFixed(1))}</b> ${esc(q.place)}<br>${esc(new Date(q.time).toISOString().slice(0, 16))}Z<br><a href="${safeUrl(q.url)}" target="_blank" rel="noopener noreferrer">USGS</a>`)
883
+ .addTo(layers.quakes);
884
+ }
885
+ for (const e of ev.result.events.filter((x) => x.lat !== null)) {
886
+ L.circleMarker([e.lat, e.lon], { radius: e.severity ? 9 : 5, color: '#ff9f43', weight: 2, fillOpacity: .35, className: 'mk-pulse' })
887
+ .bindPopup(`<b>${esc(e.title)}</b><br>${esc(e.category)}${e.why ? ' · ' + esc(e.why) : ''}<br>${esc(e.date.slice(0, 16))}Z`)
888
+ .addTo(layers.events);
889
+ }
890
+ syncLayers();
891
+ $('#map-meta').textContent = `${mil.aircraft.length} military aircraft · ${quakes.length} earthquakes (24h) · ${ev.result.events.length} natural events · ${nf} fence(s)`;
892
+ } catch (err) { $('#map-meta').innerHTML = `<span class="err">${esc(err.message)}</span>`; }
893
+ finally { $('#load-map').disabled = false; }
894
+ }
895
+ $('#load-map').onclick = loadMap;
896
+
897
+ /* draw a fence: click two opposite corners */
898
+ let drawing = null;
899
+ $('#draw-fence').onclick = () => {
900
+ if (!map) return;
901
+ drawing = [];
902
+ $('#map-meta').textContent = 'Click the first corner of the fence on the map…';
903
+ map.getContainer().style.cursor = 'crosshair';
904
+ };
905
+ function handleMapClick(e) {
906
+ if (!drawing) return;
907
+ drawing.push(e.latlng);
908
+ if (drawing.length === 1) { $('#map-meta').textContent = 'Now click the opposite corner…'; return; }
909
+ const [a, b] = drawing;
910
+ drawing = null;
911
+ map.getContainer().style.cursor = '';
912
+ const box = [Math.min(a.lat, b.lat), Math.min(a.lng, b.lng), Math.max(a.lat, b.lat), Math.max(a.lng, b.lng)].map((v) => Math.round(v * 1000) / 1000);
913
+ const name = (prompt('Fence name?', 'my-fence') || '').trim();
914
+ if (!name) { $('#map-meta').textContent = 'Fence cancelled.'; return; }
915
+ post('/api/fences', { name, box })
916
+ .then((f) => { $('#map-meta').textContent = `Fence #${f.id} "${f.name}" saved. It is checked every scan; the first check records a baseline.`; return loadFences(); })
917
+ .catch((err) => { $('#map-meta').innerHTML = `<span class="err">${esc(err.message)}</span>`; });
918
+ }
919
+ const waitMap = setInterval(() => { if (map) { map.on('click', handleMapClick); clearInterval(waitMap); } }, 300);
920
+
921
+ /* investigate */
922
+ const placeholders = { scam: 'USPS: your package is on hold, pay the $1.99 fee within 24 hours at usps-redelivery-help.top/track', recall: '2018 Honda Accord', emailsec: 'example.com', airport: 'JFK', country: 'Argentina', papers: 'solid-state battery', url: 'paypa1-secure-login.top/verify', factcheck: 'The Great Wall of China is visible from space', audit: 'npm:lodash@4.17.15 npm:request pypi:requests==2.19.0', travel: 'Lisbon', dossier: 'Nvidia', hype: 'ai agent', footprint: 'openai.com', lights: 'Gaza Strip', aircraft: 'N628TS', image: 'Kyoto', /*onchain*/wallet: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', token: '0xdac17f958d2ee523a2206206994597c13d831ec7', /*/onchain*/air: 'New Delhi', space: '(no input needed)', /*onchain*/robinhood: '(no input needed)', deployer: '0x… token or deployer', /*/onchain*/launches: 'OpenAI', markets: '(no input needed)', rewind: '2026-11-12', sanctions: 'IMO 1234567 or 0x… or exact name', health: 'Nvidia', impact: '(empty = current quakes and storms)', contradictions: 'Anthropic IPO' };
923
+ const usd = (x) => (x == null ? '?' : '$' + Math.round(x).toLocaleString('en-US'));
924
+
925
+ /* brief: tiny, safe Markdown renderer (escape first, then headings, bold, links, bullets) */
926
+ function renderMd(md) {
927
+ const lines = esc(md).split('\n');
928
+ let html = '', inList = false;
929
+ for (const raw of lines) {
930
+ // Italic only for a whole line ("_Written by ..._"): inline underscores appear in URLs.
931
+ let l = raw.replace(/^_(.+)_$/, '<i>$1</i>').replace(/\*\*(.+?)\*\*/g, '<b>$1</b>')
932
+ .replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, (_m, t, u) => `<a href="${u}" target="_blank" rel="noopener noreferrer">${t}</a>`);
933
+ const h = /^(#{1,3})\s+(.*)$/.exec(l);
934
+ const li = /^\s*[-*]\s+(.*)$/.exec(l);
935
+ if (li) { if (!inList) { html += '<ul>'; inList = true; } html += `<li>${li[1]}</li>`; continue; }
936
+ if (inList) { html += '</ul>'; inList = false; }
937
+ if (h) html += `<h${h[1].length}>${h[2]}</h${h[1].length}>`;
938
+ else if (l.trim()) html += `<p>${l}</p>`;
939
+ }
940
+ return html + (inList ? '</ul>' : '');
941
+ }
942
+ async function loadBrief(refresh) {
943
+ $('#brief').textContent = refresh ? 'Rewriting…' : 'Loading…';
944
+ try { const b = await api('/api/brief' + (refresh ? '?refresh=1' : '')); $('#brief').innerHTML = renderMd(b.markdown); $('#brief').className = 'md'; }
945
+ catch (err) { $('#brief').innerHTML = `<span class="err">${esc(err.message)}</span>`; }
946
+ }
947
+ $('#brief-refresh').onclick = () => loadBrief(true);
948
+ loadBrief(false);
949
+
950
+ /* watch */
951
+ let isOwner = false;
952
+ async function loadMy() {
953
+ try {
954
+ const m = await api('/api/my');
955
+ isOwner = Boolean(m.owner);
956
+ const when = (t) => (t ? t.slice(0, 16).replace('T', ' ') + ' UTC' : 'not yet');
957
+ $('#my-mon').innerHTML = m.monitors.length
958
+ ? '<tr><th>#</th><th>monitor</th><th>last check</th><th></th></tr>' + m.monitors.map((x) => `<tr><td class="num">${x.id}</td><td>${esc(x.description)}<div class="meta">${esc(x.kind)} · ${esc(x.target)}${x.lastChange ? ' · changed ' + esc(when(x.lastChange)) : ''}</div></td><td class="meta">${esc(when(x.lastRun))}</td><td><button class="icon-btn" data-unmy="${x.id}">remove</button></td></tr>`).join('')
959
+ : '';
960
+ document.querySelectorAll('[data-unmy]').forEach((b) => (b.onclick = async () => { b.disabled = true; try { await post('/api/my/monitors/delete', { id: Number(b.dataset.unmy) }); loadMy(); } catch { b.disabled = false; } }));
961
+ $('#my-alerts').innerHTML = m.alerts.length
962
+ ? `<ul class="ev">${m.alerts.map((a) => `<li>${esc(a.text).replace(/https?:\/\/[^\s<]+/g, (u) => `<a href="${u}" target="_blank" rel="noopener noreferrer">link</a>`)} <span class="meta">#${a.monitorId} · ${esc(when(a.createdAt))}</span></li>`).join('')}</ul>`
963
+ : '<p class="meta">Nothing yet. The first check of each monitor records a baseline.</p>';
964
+ if (!m.mail) { $('#mail-q').disabled = true; $('#mail-go').disabled = true; $('#mail-state').textContent = 'Email alerts are not set up on this install yet.'; }
965
+ else if (m.email.email) $('#mail-state').innerHTML = m.email.confirmed ? `Alerts go to <b>${esc(m.email.email)}</b>. <a href="#" id="mail-off">Stop emails</a>` : `Confirmation sent to <b>${esc(m.email.email)}</b>. Click the link in that email (check spam too).`;
966
+ const off = document.getElementById('mail-off');
967
+ if (off) off.onclick = async (e) => { e.preventDefault(); await post('/api/my/email/delete', {}); loadMy(); };
968
+ $('#shared-note').textContent = isOwner ? 'What this install watches for everyone. You are signed in as the owner.' : 'What this Oculon install watches for everyone. Managed by the owner.';
969
+ } catch (err) { $('#my-alerts').innerHTML = `<p class="err">${esc(err.message)}</p>`; }
970
+ }
971
+ $('#mail-go').onclick = async () => {
972
+ const email = $('#mail-q').value.trim();
973
+ if (!email) return;
974
+ $('#mail-go').disabled = true;
975
+ try { await post('/api/my/email', { email }); $('#mail-q').value = ''; loadMy(); }
976
+ catch (err) { $('#mail-state').innerHTML = `<span class="err">${esc(err.message)}</span>`; }
977
+ finally { $('#mail-go').disabled = false; }
978
+ };
979
+ async function loadWatch() {
980
+ loadMy();
981
+ const [list, sigs, quota] = await Promise.all([api('/api/watch'), api('/api/signals?limit=200'), api('/api/quota')]);
982
+ $('#watch').innerHTML = '<tr><th>#</th><th>kind</th><th>target</th><th>last check</th><th></th></tr>' + (list.map((w) => `<tr><td class="num">${w.id}</td><td>${esc(w.kind)}</td><td>${esc(w.label || w.target)}${w.label ? `<div class="meta">${esc(w.target)}</div>` : ''}</td><td class="meta">${esc(w.lastRun ? w.lastRun.slice(0, 16).replace('T', ' ') + ' UTC' : 'not yet')}</td><td>${isOwner ? `<button class="icon-btn" data-unwatch="${w.id}" aria-label="Stop watching">remove</button>` : ''}</td></tr>`).join('') || '<tr><td colspan="5" class="meta">empty</td></tr>');
983
+ document.querySelectorAll('[data-unwatch]').forEach((b) => (b.onclick = async () => { b.disabled = true; try { await post('/api/watch/delete', { id: Number(b.dataset.unwatch) }); loadWatch(); } catch (err) { b.disabled = false; } }));
984
+ const ws = sigs.filter((s) => s.module === 'meerkat');
985
+ $('#watch-signals').innerHTML = ws.length ? ws.slice(0, 30).map(renderSignal).join('') : '<p class="meta">No changes yet. The first check of each target records a baseline.</p>';
986
+ $('#quota').innerHTML = '<tr><th>source</th><th>used</th><th>daily budget</th></tr>' + (quota.map((q) => `<tr><td>${esc(q.source)}</td><td class="num">${q.used}</td><td class="num">${q.budget ?? '—'}</td></tr>`).join('') || '<tr><td colspan="3" class="meta">no metered calls today</td></tr>');
987
+ }
988
+
989
+ $('#mon-go').onclick = async () => {
990
+ const text = $('#mon-q').value.trim() || $('#mon-q').placeholder;
991
+ $('#mon-go').disabled = true;
992
+ $('#mon-out').innerHTML = '<p class="meta">Reading the request…</p>';
993
+ try {
994
+ const r = await post('/api/my/monitors', { text });
995
+ $('#mon-out').innerHTML = `<p><span class="pill ok">monitoring</span> #${r.monitor.id} <b>${esc(r.rule.kind)}</b> · ${esc(r.rule.description)}</p><p class="meta">The first check records a baseline; changes after that appear below and by email if you add one.</p>`;
996
+ $('#mon-q').value = '';
997
+ loadMy();
998
+ } catch (err) { $('#mon-out').innerHTML = `<p class="err">${esc(err.message)}</p>`; }
999
+ finally { $('#mon-go').disabled = false; }
1000
+ };
1001
+ $('#mon-q').addEventListener('keydown', (e) => { if (e.key === 'Enter') $('#mon-go').click(); });
1002
+ document.querySelectorAll('[data-mon]').forEach((a) => (a.onclick = (e) => { e.preventDefault(); $('#mon-q').value = a.textContent; $('#mon-go').click(); }));
1003
+
1004
+ /* first to know */
1005
+ async function loadScoops() {
1006
+ try {
1007
+ const b = await api('/api/scoops');
1008
+ $('#scoops').innerHTML = b.checked
1009
+ ? `<div class="kpis"><div class="kpi"><b>${b.checked}</b><span>signals checked</span></div><div class="kpi"><b>${b.oculonFirst}</b><span>Oculon first</span></div><div class="kpi"><b>${b.mediaFirst}</b><span>media first</span></div><div class="kpi"><b>${b.medianLeadHours == null ? '—' : (b.medianLeadHours > 0 ? '+' : '') + b.medianLeadHours + 'h'}</b><span>median lead</span></div></div>` +
1010
+ (b.best.length ? `<ul class="ev">${b.best.slice(0, 5).map((s) => `<li>+${esc(s.leadHours)}h ${esc(s.subject)} <a href="${safeUrl(s.mediaUrl)}" target="_blank" rel="noopener noreferrer">${esc(s.mediaSource || 'media')}</a></li>`).join('')}</ul>` : '<p class="meta">No scoops yet: so far the media reported first. Signals are checked once they are 6-72 hours old.</p>')
1011
+ : 'No signals checked yet. Signals are compared with Guardian, NYT and GNews once they are 6-72 hours old.';
1012
+ } catch (err) { $('#scoops').innerHTML = `<span class="err">${esc(err.message)}</span>`; }
1013
+ }
1014
+ loadScoops();
1015
+
1016
+ /* narratives */
1017
+ async function loadNarratives() {
1018
+ try {
1019
+ const list = await api('/api/narratives');
1020
+ $('#narratives').innerHTML = list.length
1021
+ ? `<table>${list.slice(0, 8).map((n) => `<tr><td>${spark(n.daily)}</td><td><b>${esc(n.name)}</b><div class="meta">${n.daily[6]} today · ${n.total} total · ${esc(n.phase.toLowerCase())}</div></td></tr>`).join('')}</table>`
1022
+ : 'No narratives yet. They are built every 6 hours while the schedule runs.';
1023
+ $('#narratives').className = '';
1024
+ } catch (err) { $('#narratives').innerHTML = `<span class="err">${esc(err.message)}</span>`; }
1025
+ }
1026
+ loadNarratives();
1027
+
1028
+ /* cases */
1029
+ async function loadCases() {
1030
+ const list = await api('/api/cases');
1031
+ $('#case-list').innerHTML = list.length
1032
+ ? `<table>${list.map((k) => `<tr><td class="num">#${k.id}</td><td><a href="#cases" data-case="${k.id}">${esc(k.question)}</a><div class="meta">${esc(k.confidence || '-')} confidence · ${k.findings} findings · run ${k.runs}${k.watch ? ' · watching' : ''}</div></td></tr>`).join('')}</table>`
1033
+ : '<p class="meta">No cases yet.</p>';
1034
+ document.querySelectorAll('[data-case]').forEach((a) => (a.onclick = async (e) => {
1035
+ e.preventDefault();
1036
+ const k = await api('/api/case?id=' + encodeURIComponent(a.dataset.case));
1037
+ $('#case-view').innerHTML = k && k.markdown ? renderMd(k.markdown) : 'Not found.';
1038
+ $('#case-view').className = 'md';
1039
+ }));
1040
+ }
1041
+ $('#case-go').onclick = async () => {
1042
+ const q = $('#case-q').value.trim();
1043
+ if (q.length < 8) return;
1044
+ $('#case-go').disabled = true;
1045
+ $('#case-view').innerHTML = '<p class="meta">Investigating… 1-3 minutes.</p>';
1046
+ try {
1047
+ const r = await post('/api/cases', { question: q });
1048
+ $('#case-view').innerHTML = renderMd(r.markdown || '');
1049
+ $('#case-view').className = 'md';
1050
+ loadCases();
1051
+ } catch (err) { $('#case-view').innerHTML = `<span class="err">${esc(err.message)}</span>`; }
1052
+ finally { $('#case-go').disabled = false; }
1053
+ };
1054
+
1055
+ /* ask */
1056
+ $('#ask-go').onclick = async () => {
1057
+ const q = $('#ask-q').value.trim() || $('#ask-q').placeholder;
1058
+ const out = $('#ask-out');
1059
+ $('#ask-go').disabled = true;
1060
+ out.innerHTML = '<p class="meta">Thinking and calling tools… this can take 20-60 seconds.</p>';
1061
+ try {
1062
+ const r = await api('/api/ask?q=' + encodeURIComponent(q));
1063
+ const linked = esc(r.answer).replace(/https?:\/\/[^\s<)\]]+/g, (u) => `<a href="${u}" target="_blank" rel="noopener noreferrer">${u}</a>`);
1064
+ out.innerHTML = `<div style="white-space:pre-wrap;margin-top:10px">${linked}</div><p class="meta">${r.steps.map((s) => `<span class="chip">${esc(s.tool)}</span>`).join('')} model: ${esc([...new Set(r.providers)].join(', '))} · AI-written from tool results; check the sources</p>`;
1065
+ } catch (err) { out.innerHTML = `<p class="err">${esc(err.message)}</p>`; }
1066
+ finally { $('#ask-go').disabled = false; }
1067
+ };
1068
+ $('#ask-q').addEventListener('keydown', (e) => { if (e.key === 'Enter') $('#ask-go').click(); });
1069
+ $('#inv-kind').onchange = () => { $('#inv-q').placeholder = placeholders[$('#inv-kind').value]; };
1070
+ const spark = (xs) => { const m = Math.max(...xs, 1e-9); return `<span class="spark">${xs.map((x) => `<i style="height:${Math.max(2, Math.round((x / m) * 28))}px" title="${esc(x)}"></i>`).join('')}</span>`; };
1071
+ const sigList = (s) => (s.length ? `<h3>Signals</h3>${s.map(renderSignal).join('')}` : '');
1072
+ const views = {
1073
+ scam: (r) => {
1074
+ const d = r.result;
1075
+ const tone = d.verdict === 'likely scam' ? 'bad' : d.verdict === 'suspicious' ? 'warn' : 'ok';
1076
+ return `<h3><span class="pill ${tone}">${esc(d.verdict)}</span> <span class="meta">risk ${d.risk}/100</span></h3>${d.explanation ? `<p>${esc(d.explanation)}</p>` : ''}${d.reasons.length ? `<ul class="ev">${d.reasons.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : ''}${d.links.length ? `<h3>Links</h3><ul class="ev">${d.links.map((l) => `<li><code>${esc(l.url)}</code> <span class="pill ${l.verdict === 'malicious' ? 'bad' : l.verdict === 'suspicious' ? 'warn' : 'ok'}">${esc(l.verdict)}</span></li>`).join('')}</ul>` : ''}<h3>What to do</h3><ul class="ev">${d.advice.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>`;
1077
+ },
1078
+ recall: (r) => {
1079
+ const d = r.result;
1080
+ const head = d.vehicle ? `${d.vehicle.year} ${d.vehicle.make} ${d.vehicle.model}` : d.query;
1081
+ const park = d.recalls.some((x) => x.parkIt || x.parkOutside);
1082
+ return `<h3>${esc(head)} <span class="pill ${park ? 'bad' : d.recalls.length ? 'warn' : 'ok'}">${d.recalls.length ? d.recalls.length + ' recall' + (d.recalls.length === 1 ? '' : 's') : 'no recalls found'}</span></h3>${d.recalls.length ? `<ul class="ev">${d.recalls.slice(0, 15).map((x) => `<li>${x.parkIt ? '<b class="err">DO NOT DRIVE</b> ' : x.parkOutside ? '<b class="err">PARK OUTSIDE</b> ' : x.classification === 'Class I' ? '<b class="err">Class I</b> ' : ''}<b>${esc(x.title)}</b> <span class="meta">${esc(x.source)} ${esc(x.id)} · ${esc(x.date || '')}</span><div>${esc(x.hazard)}</div>${x.remedy ? `<div class="meta">${esc(x.remedy)}</div>` : ''}<a href="${safeUrl(x.url)}" target="_blank" rel="noopener noreferrer">details</a></li>`).join('')}</ul>` : ''}${d.note ? `<p class="meta">${esc(d.note)}</p>` : ''}`;
1083
+ },
1084
+ emailsec: (r) => {
1085
+ const d = r.result;
1086
+ const tone = d.verdict === 'protected' ? 'ok' : d.verdict === 'partly protected' ? 'warn' : 'bad';
1087
+ const row = (k, v) => `<tr><td>${k}</td><td>${v}</td></tr>`;
1088
+ return `<h3>${esc(d.domain)} <span class="pill ${tone}">${esc(d.verdict)}</span> <span class="meta">score ${d.score}/100</span></h3><table>${row('SPF', d.spf.record ? `${esc(d.spf.all || 'no all')} · ${d.spf.lookups} lookups<div class="meta">${esc(d.spf.record)}</div>` : '<span class="err">missing</span>')}${row('DMARC', d.dmarc.record ? `p=${esc(d.dmarc.policy || '?')}${d.dmarc.reports ? ' · reports on' : ''}<div class="meta">${esc(d.dmarc.record)}</div>` : '<span class="err">missing</span>')}${row('DKIM', d.dkim.selectorsFound.length ? esc(d.dkim.selectorsFound.join(', ')) : '<span class="meta">no common selector found</span>')}${row('MTA-STS', esc(d.mtaSts.mode || 'off'))}${row('DNSSEC', d.dnssec ? 'on' : 'off')}${row('MX', esc(d.mx.slice(0, 3).join(', ') || 'none'))}</table>${d.fixes.length ? `<h3>Fixes</h3><ol>${d.fixes.map((x) => `<li>${esc(x)}</li>`).join('')}</ol>` : ''}`;
1089
+ },
1090
+ airport: (r) => {
1091
+ const d = r.result;
1092
+ const tone = d.verdict === 'normal' ? 'ok' : d.verdict === 'disrupted' ? 'bad' : 'warn';
1093
+ return `<h3>${esc(d.airport.name)} <span class="pill ${tone}">${esc(d.verdict)}</span></h3><ul class="ev">${d.points.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>${d.metar ? `<p class="meta"><code>${esc(d.metar.raw)}</code></p>` : ''}${d.taf ? `<p class="meta"><code>${esc(d.taf.raw)}</code></p>` : ''}`;
1094
+ },
1095
+ country: (r) => {
1096
+ const d = r.result;
1097
+ const fmtv = (i) => i.value == null ? 'n/a' : i.unit === 'USD' ? (i.value >= 1e12 ? '$' + (i.value / 1e12).toFixed(2) + 'T' : i.value >= 1e9 ? '$' + (i.value / 1e9).toFixed(1) + 'B' : '$' + Math.round(i.value).toLocaleString('en-US')) : i.unit === 'people' ? (i.value / 1e6).toFixed(1) + 'M' : i.value.toFixed(1) + '%';
1098
+ const yrs = Object.keys(d.outlook.growth);
1099
+ return `<h3>${esc(d.name)} <span class="meta">${esc(d.region || '')} · ${esc(d.incomeLevel || '')}</span></h3><p>Head of state <b>${esc(d.leaders.headOfState || 'n/a')}</b>${d.leaders.headOfGovernment && d.leaders.headOfGovernment !== d.leaders.headOfState ? ` · government <b>${esc(d.leaders.headOfGovernment)}</b>` : ''} · capital ${esc(d.capital || 'n/a')}${d.currency.perUsd ? ` · 1 USD = ${d.currency.perUsd.toFixed(2)} ${esc(d.currency.code)}` : ''}</p><div class="kpis">${d.indicators.map((i) => `<div class="kpi"><b>${esc(fmtv(i))}</b><span>${esc(i.name)} ${esc(i.year || '')}</span></div>`).join('')}</div>${yrs.length ? `<p class="meta">IMF outlook: ${yrs.map((y) => `${y} growth ${d.outlook.growth[y]}%, inflation ${d.outlook.inflation[y] ?? '?'}%`).join(' · ')}</p>` : ''}<ul class="ev">${d.advisories.us ? `<li>US advisory level ${d.advisories.us.level}: ${esc(d.advisories.us.text)} <a href="${safeUrl(d.advisories.us.url)}" target="_blank" rel="noopener noreferrer">source</a></li>` : ''}${d.advisories.uk?.alerts.length ? `<li>UK FCDO ${esc(d.advisories.uk.alerts.join('; '))}</li>` : ''}${d.outages.map((x) => `<li>Internet outage: ${esc(x)}</li>`).join('')}${d.hazards.map((h) => `<li>${esc(h.level)} alert: ${esc(h.type)} ${esc(h.name)}</li>`).join('')}</ul>${d.headlines.length ? `<h3>Headlines</h3><ul class="ev">${d.headlines.map((h) => `<li><a href="${safeUrl(h.url)}" target="_blank" rel="noopener noreferrer">${esc(h.title)}</a> <span class="meta">${esc(h.date.slice(0, 10))}</span></li>`).join('')}</ul>` : ''}`;
1100
+ },
1101
+ papers: (r) => {
1102
+ const d = r.result;
1103
+ const all = [...d.mostCited, ...d.newest, ...(d.pubmed?.papers || [])];
1104
+ const linked = d.overview ? esc(d.overview).replace(/\[(\d+)\]/g, (m, n) => { const p = all.find((x) => x.n === Number(n)); return p ? `<a href="${safeUrl(p.openAccessUrl || p.url)}" target="_blank" rel="noopener noreferrer">[${n}]</a>` : m; }) : '';
1105
+ const li = (p) => `<li>[${p.n}] <a href="${safeUrl(p.openAccessUrl || p.url)}" target="_blank" rel="noopener noreferrer">${esc(p.title)}</a> <span class="meta">${esc(String(p.year || ''))} · ${esc(p.venue || '')} · ${p.citations} citations</span>${p.tldr ? `<div class="meta">${esc(p.tldr)}</div>` : ''}</li>`;
1106
+ return `<h3>${esc(d.topic)} <span class="meta">${(d.totalWorks || 0).toLocaleString('en-US')} works${d.trend ? ' · field ' + esc(d.trend) : ''}</span></h3>${d.perYear.length ? `<p>${spark(d.perYear.filter((x) => x.count > 50).map((x) => x.count))} <span class="meta">${esc(d.perYear.filter((x) => x.count > 50).map((x) => x.year).join(' · '))}</span></p>` : ''}${linked ? `<p>${linked}</p><p class="meta">AI-written from the papers below; read them before citing.</p>` : ''}<h3>Most cited</h3><ul class="ev">${d.mostCited.map(li).join('')}</ul>${d.newest.length ? `<h3>Newest</h3><ul class="ev">${d.newest.map(li).join('')}</ul>` : ''}${d.pubmed?.papers.length ? `<h3>PubMed · ${d.pubmed.count.toLocaleString('en-US')} papers in 2 years</h3><ul class="ev">${d.pubmed.papers.map(li).join('')}</ul>` : ''}`;
1107
+ },
1108
+ url: (r) => {
1109
+ const d = r.result;
1110
+ const tone = d.verdict === 'malicious' ? 'bad' : d.verdict === 'suspicious' ? 'warn' : 'ok';
1111
+ return `<h3>${esc(d.host)} <span class="pill ${tone}">${esc(d.verdict)}</span> <span class="meta">risk ${d.risk}/100</span></h3>${d.reasons.length ? `<ul class="ev">${d.reasons.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : ''}${d.domainInfo?.registered ? `<p class="meta">${esc(d.domain)} registered ${esc(d.domainInfo.registered.slice(0, 10))}${d.domainInfo.registrar ? ` via ${esc(d.domainInfo.registrar)}` : ''}</p>` : ''}${d.scans?.count ? `<p class="meta">urlscan.io: ${d.scans.count} scans since ${esc((d.scans.firstSeen || '').slice(0, 10))}${d.scans.countries.length ? `, hosted in ${esc(d.scans.countries.join(', '))}` : ''}${d.scans.latest ? ` · <a href="${safeUrl(d.scans.latest)}" target="_blank" rel="noopener noreferrer">latest scan</a>` : ''}</p>` : ''}${d.verdict === 'no known threats' ? '<p class="meta">No source flags it. That is not a guarantee the page is safe.</p>' : ''}`;
1112
+ },
1113
+ factcheck: (r) => {
1114
+ const d = r.result;
1115
+ const tone = /false|misleading/.test(d.verdict) ? 'bad' : /true/.test(d.verdict) ? 'ok' : 'warn';
1116
+ const all = [...d.factChecks, ...d.web];
1117
+ const linked = esc(d.summary).replace(/\[(\d+)\]/g, (m, n) => { const e = all.find((x) => x.n === Number(n)); return e ? `<a href="${safeUrl(e.url)}" target="_blank" rel="noopener noreferrer">[${n}]</a>` : m; });
1118
+ return `<h3>${esc(d.claim)}</h3><p><span class="pill ${tone}">${esc(d.verdict)}</span> ${d.confidence ? `<span class="meta">confidence ${d.confidence}% · ${esc(d.method)}</span>` : ''}</p><p>${linked}</p>${d.factChecks.length ? `<h3>Published fact checks</h3><ul class="ev">${d.factChecks.map((e) => `<li>[${e.n}] <b>${esc(e.publisher)}</b>${e.rating ? ` rated "${esc(e.rating)}"` : ''}: <a href="${safeUrl(e.url)}" target="_blank" rel="noopener noreferrer">${esc(e.title.slice(0, 140))}</a>${e.date ? ` <span class="meta">${esc(e.date.slice(0, 10))}</span>` : ''}</li>`).join('')}</ul>` : ''}${d.web.length ? `<h3>Reporting</h3><ul class="ev">${d.web.map((e) => `<li>[${e.n}] <a href="${safeUrl(e.url)}" target="_blank" rel="noopener noreferrer">${esc(e.title.slice(0, 140))}</a> <span class="meta">${esc(e.publisher)}</span></li>`).join('')}</ul>` : ''}<p class="meta">AI-weighed from the sources above; read them before sharing.</p>`;
1119
+ },
1120
+ audit: (r) => {
1121
+ const d = r.result, s = d.summary;
1122
+ const row = (p) => `<tr><td class="num">${p.risk}</td><td><b>${esc(p.name)}@${esc(p.version || '?')}</b>${p.dev ? ' <span class="meta">dev</span>' : ''}<div class="meta">latest ${esc(p.latest || '?')}${p.project?.scorecard != null ? ` · scorecard ${p.project.scorecard}` : ''}${p.licenses.length ? ` · ${esc(p.licenses.join(', '))}` : ''}</div></td><td>${p.flags.map((x) => `<div>${esc(x)}</div>`).join('') || '<span class="meta">no flags</span>'}${p.advisories.slice(0, 3).map((a) => `<div class="meta"><a href="${safeUrl(a.url)}" target="_blank" rel="noopener noreferrer">${esc(a.aliases[0] || a.id)}</a>${a.cvss ? ` CVSS ${a.cvss}` : ''}: ${esc(a.title.slice(0, 90))}</div>`).join('')}</td></tr>`;
1123
+ return `<div class="kpis"><div class="kpi"><b>${s.checked}/${s.total}</b><span>checked</span></div><div class="kpi"><b>${s.vulnerable}</b><span>vulnerable</span></div><div class="kpi"><b>${s.advisories}</b><span>advisories</span></div><div class="kpi"><b>${s.deprecated}</b><span>deprecated</span></div><div class="kpi"><b>${s.stale}</b><span>no release in 2y</span></div></div><div style="overflow-x:auto"><table><tr><th>risk</th><th>package</th><th>findings</th></tr>${d.packages.map(row).join('')}</table></div>${d.skipped.length ? `<p class="meta">skipped: ${esc(d.skipped.join(', '))}</p>` : ''}<p class="meta">Paste a whole package.json here too. For requirements.txt use the CLI or MCP: <code>oculon audit requirements.txt</code>.</p>`;
1124
+ },
1125
+ travel: (r) => {
1126
+ const d = r.result;
1127
+ const tone = d.level === 'low' ? 'ok' : d.level === 'moderate' ? 'warn' : 'bad';
1128
+ const w = d.weather;
1129
+ return `<h3>${esc(d.place.name)} <span class="pill ${tone}">${esc(d.level)} risk</span></h3><ul class="ev">${d.points.map((x) => `<li>${esc(x)}</li>`).join('') || '<li>No warnings from the sources checked.</li>'}</ul>${w ? `<div style="overflow-x:auto"><table><tr><th>day</th><th>weather</th><th>°C</th><th>rain</th><th>gusts</th></tr>${w.days.map((x) => `<tr><td>${esc(x.date.slice(5))}</td><td>${esc(x.summary)}</td><td class="num">${Math.round(x.tMin)}–${Math.round(x.tMax)}</td><td class="num">${x.rainMm.toFixed(0)} mm</td><td class="num">${Math.round(x.gustKmh)} km/h</td></tr>`).join('')}</table></div>` : ''}${d.air?.pm25 != null ? `<p class="meta">Air: PM2.5 ${d.air.pm25.toFixed(0)} µg/m³ (${esc(d.air.category)}) from ${d.air.stations} stations</p>` : ''}${d.outbreaks.length ? `<h3>WHO outbreak news</h3><ul class="ev">${d.outbreaks.map((o) => `<li><a href="${safeUrl(o.url)}" target="_blank" rel="noopener noreferrer">${esc(o.title)}</a> <span class="meta">${esc(o.date.slice(0, 10))}</span></li>`).join('')}</ul>` : ''}<p class="meta">${d.advisories.us ? `<a href="${safeUrl(d.advisories.us.url)}" target="_blank" rel="noopener noreferrer">US advisory</a>` : ''}${d.advisories.uk ? ` · <a href="${safeUrl(d.advisories.uk.url)}" target="_blank" rel="noopener noreferrer">UK travel advice</a>` : ''}</p>`;
1130
+ },
1131
+ dossier: (r) => {
1132
+ const d = r.result;
1133
+ return `${d.wikipedia ? `<h3>${esc(d.wikipedia.title)}</h3><p class="meta">${esc(d.wikipedia.description || '')}${d.wikipedia.spike ? ` · readers ${d.wikipedia.spike.toFixed(1)}× usual` : ''}</p>` : ''}
1134
+ ${d.markets.length ? `<h3>Prediction markets</h3><table>${d.markets.map((m) => `<tr><td><a href="${safeUrl(m.url)}" target="_blank" rel="noopener noreferrer">${esc(m.question)}</a></td><td class="num">${Math.round((m.prices[0] || 0) * 100)}%</td></tr>`).join('')}</table>` : ''}
1135
+ <h3>Timeline</h3><table>${d.timeline.slice(0, 30).map((t) => `<tr><td class="num">${esc(t.date.slice(0, 10))}</td><td><span class="chip">${esc(t.source)}</span>${t.url ? `<a href="${safeUrl(t.url)}" target="_blank" rel="noopener noreferrer">${esc(t.text)}</a>` : esc(t.text)}</td></tr>`).join('') || '<tr><td class="meta">nothing in the window</td></tr>'}</table>${sigList(r.signals)}`;
1136
+ },
1137
+ hype: (r) => {
1138
+ const d = r.result;
1139
+ return `<h3>${esc(d.topic)}: ${esc(d.phase)}</h3><p class="meta">${esc(d.summary)}</p><table><tr><th>channel</th><th>source</th><th>phase</th><th>8 weeks</th></tr>${d.channels.map((c) => `<tr><td>${esc(c.channel)}</td><td>${esc(c.source)}</td><td>${esc(c.trend?.phase || 'n/a')}</td><td>${c.weekly.length ? spark(c.weekly) : '<span class="meta">no data</span>'}</td></tr>`).join('')}</table>${sigList(r.signals)}`;
1140
+ },
1141
+ footprint: (r) => {
1142
+ const d = r.result;
1143
+ return `<p class="meta">${d.counts.subdomain} subdomains · ${d.counts.page} pages · ${d.counts.repo} repos in ${d.windowDays} days</p><table>${d.findings.slice(0, 40).map((f) => `<tr><td class="num">${f.score}</td><td><span class="chip">${esc(f.kind)}</span><a href="${safeUrl(f.url)}" target="_blank" rel="noopener noreferrer">${esc(f.value)}</a><div class="meta">${esc(f.reasons.join('; '))}</div></td><td class="num">${esc(f.firstSeen.slice(0, 10))}</td></tr>`).join('') || '<tr><td class="meta">no new footprints</td></tr>'}</table>${sigList(r.signals)}`;
1144
+ },
1145
+ lights: (r) => {
1146
+ const d = r.result;
1147
+ return `<h3>${esc(d.place.name)}: ${esc(d.verdict)}${d.ratio ? ` (${d.ratio >= 1 ? '+' : ''}${Math.round((d.ratio - 1) * 100)}%)` : ''}</h3><p class="meta">recent ${d.recent.length} nights vs baseline ${d.baseline.length} nights · newest ${esc(d.latestDate || 'n/a')}</p><p>recent ${spark(d.recent.map((x) => x.mean).reverse())} &nbsp; baseline ${spark(d.baseline.map((x) => x.mean).reverse())}</p>${sigList(r.signals)}`;
1148
+ },
1149
+ /*onchain*/ wallet: (r) => {
1150
+ const w = r.result;
1151
+ return `<h3>${esc(w.address)}</h3>${w.portfolio ? `<p><b>${usd(w.portfolio.totalUsd)}</b> <span class="meta">portfolio (Zerion)</span></p><table>${w.portfolio.top.slice(0, 8).map((t) => `<tr><td>${esc(t.symbol)}</td><td class="num">${usd(t.valueUsd)}</td><td class="meta">${esc(t.chain)}</td></tr>`).join('')}</table><p class="meta">Values as reported by Zerion; airdropped tokens can carry inflated prices.</p>` : ''}
1152
+ ${w.solana ? `<p>${w.solana.sol.toFixed(3)} SOL · ${w.solana.tokens} token accounts</p>` : ''}
1153
+ ${w.firstSeen ? `<p class="meta">first transaction ${esc(w.firstSeen.slice(0, 10))} (${w.ageDays} days ago)</p>` : ''}
1154
+ ${w.robinhood ? `<p>Robinhood Chain: ${w.robinhood.balanceEth.toFixed(4)} ETH, ${w.robinhood.txCount} txs</p>` : ''}
1155
+ <p>risk: ${w.labels.length ? `<span class="err">${esc(w.labels.join(', '))}</span>` : 'no GoPlus labels'}${w.riskScore != null ? ` · Webacy ${esc(w.riskScore)}` : ''}</p>${sigList(r.signals)}`;
1156
+ },
1157
+ token: (r) => {
1158
+ const t = r.result;
1159
+ return `<h3>${esc(t.security?.symbol || t.market?.symbol || t.address)}: ${esc(t.verdict)}</h3><ul class="ev">${t.reasons.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>${t.market ? `<p>price ${esc(t.market.priceUsd)} · mcap ${usd(t.market.marketCapUsd)}</p>` : ''}<table>${t.pairs.slice(0, 6).map((p) => `<tr><td>${esc(p.dex)}</td><td>${esc(p.pair)}</td><td class="num">liq ${usd(p.liquidityUsd)}</td><td class="num">vol ${usd(p.volume24h)}</td></tr>`).join('')}</table>${sigList(r.signals)}`;
1160
+ },
1161
+ /*/onchain*/ air: (r) => {
1162
+ const d = r.result;
1163
+ return `<h3>${esc(d.place.name)}: ${d.median != null ? `PM2.5 ${d.median.toFixed(0)} µg/m³ · ${esc(d.category)}` : 'no fresh stations within 25 km'}</h3><table>${d.stations.map((s) => `<tr><td>${esc(s.name)}</td><td class="num">${esc(s.value)} ${esc(s.unit)}</td><td class="meta">${esc(s.category)}</td></tr>`).join('')}</table>${sigList(r.signals)}`;
1164
+ },
1165
+ space: (r) => {
1166
+ const s = r.result;
1167
+ return `<h3>Space weather: ${esc(s.stormLevel)}</h3><p>Kp now ${esc(s.kpNow)}, max 24h ${esc(s.kpMax24h)} ${spark(s.kp.map((k) => k.kp))}</p>${s.strongestFlare ? `<p>strongest flare (7 days) ${esc(s.strongestFlare.maxClass)} at ${esc(s.strongestFlare.maxTime.slice(0, 16))}Z · ${s.flares7d} flares</p>` : ''}${sigList(r.signals)}`;
1168
+ },
1169
+ /*onchain*/ deployer: (r) => {
1170
+ const d = r.result;
1171
+ return `<h3>Deployer ${esc(d.deployer)}: ${esc(d.verdict)}</h3><p class="meta">${esc(d.reasons.join('; '))} · ${d.contracts} contract(s) launched</p><table><tr><th>token</th><th>liquidity</th><th>status</th><th>created</th></tr>${d.tokens.map((t) => `<tr><td>${esc(t.symbol || '?')}<div class="meta">${esc(t.address)}</div></td><td class="num">${usd(t.reserveUsd)}</td><td>${t.dead ? '<span class="err">dead</span>' : 'alive'}</td><td class="meta">${esc(t.createdAt.slice(0, 10))}</td></tr>`).join('')}</table>${sigList(r.signals)}`;
1172
+ },
1173
+ /*/onchain*/ launches: (r) => {
1174
+ const d = r.result;
1175
+ return `<h3>${esc(d.company)}: ${d.items.length} item(s) in ${d.windowDays} days</h3><table>${d.items.slice(0, 40).map((i) => `<tr><td class="num">${esc(i.date.slice(0, 10))}</td><td><span class="chip">${esc(i.kind)}</span><a href="${safeUrl(i.url)}" target="_blank" rel="noopener noreferrer">${esc(i.title)}</a>${i.detail ? `<div class="meta">${esc(i.detail)}</div>` : ''}</td></tr>`).join('') || '<tr><td class="meta">nothing new</td></tr>'}</table>${sigList(r.signals)}`;
1176
+ },
1177
+ markets: (r) => {
1178
+ const d = r.result;
1179
+ if (!d.comparisons.length) return `<p class="meta">Checked ${d.checked} Polymarket markets: no market on Kalshi or Manifold asks exactly the same question right now.</p>`;
1180
+ return `<table><tr><th>gap</th><th>Polymarket</th><th>other venue</th></tr>${d.comparisons.map((x) => `<tr><td class="num">${x.gapPp >= 15 ? `<span class="err">${x.gapPp}pp</span>` : `${x.gapPp}pp`}</td><td><a href="${safeUrl(x.polymarket.url)}" target="_blank" rel="noopener noreferrer">${esc(x.polymarket.question)}</a> <b>${Math.round(x.polymarket.probability * 100)}%</b></td><td><a href="${safeUrl(x.other.url)}" target="_blank" rel="noopener noreferrer">${esc(x.other.question)}</a> <b>${Math.round(x.other.probability * 100)}%</b> <span class="chip">${esc(x.other.venue)}</span></td></tr>`).join('')}</table>${sigList(r.signals)}`;
1181
+ },
1182
+ sanctions: (r) => {
1183
+ const d = r.result;
1184
+ return `<h3>${esc(d.query)}: ${d.verdict === 'CLEAR' ? esc(d.verdict) : `<span class="err">${esc(d.verdict)}</span>`}</h3><p class="meta">OFAC SDN list, ${esc(d.listSize.toLocaleString('en-US'))} entries${d.listDate ? `, fetched ${esc(d.listDate.slice(0, 10))}` : ''}. Exact matches only; not legal advice.</p><ul class="ev">${d.hits.map((h) => `<li><span class="chip">${esc(h.kind)}</span>${esc(h.entry.name)} [${esc(h.entry.program)}]${h.detail ? ` — ${esc(h.detail)}` : ''}</li>`).join('')}</ul>`;
1185
+ },
1186
+ health: (r) => {
1187
+ const d = r.result;
1188
+ return `<h3>${esc(d.company)}: ${d.score}/100${d.change !== null ? ` <span class="meta">(${d.change >= 0 ? '+' : ''}${d.change} vs 7-day average)</span>` : ''}</h3><table>${d.parts.map((p) => `<tr><td class="num">${p.points > 0 ? '+' : ''}${p.points}</td><td>${esc(p.name)}</td><td class="meta">${esc(p.why)}</td></tr>`).join('')}</table>${d.history.length > 1 ? `<p>history ${spark(d.history.map((h) => h.score))}</p>` : ''}${sigList(r.signals)}`;
1189
+ },
1190
+ impact: (r) => {
1191
+ const d = r.result;
1192
+ if (!d.impacts.length) return '<p class="meta">No M6+ earthquakes or severe storms right now. Enter a place to estimate exposure around it.</p>';
1193
+ return d.impacts.map((i) => `<h3>${esc(i.event)}</h3><p>${esc(i.exposedPopulation.toLocaleString('en-US'))} people in listed places within ${i.radiusKm} km${i.settlements.length ? '' : ' (open sea or remote area)'}${i.lights ? ` · night lights ${esc(i.lights.verdict)}` : ''}</p><table>${i.settlements.slice(0, 8).map((s) => `<tr><td>${esc(s.name)}</td><td class="num">${esc(s.population.toLocaleString('en-US'))}</td><td class="meta">${s.distanceKm} km</td></tr>`).join('')}</table>`).join('') + '<p class="meta">Exposure estimate from Wikidata settlement populations (places can overlap); not a casualty estimate.</p>' + sigList(r.signals);
1194
+ },
1195
+ contradictions: (r) => {
1196
+ const d = r.result;
1197
+ return `<h3>${esc(d.topic)}: ${d.contradictions.length} contradiction(s) across ${d.sourcesRead.length} sources</h3>${d.contradictions.map((x) => `<div class="sig"><div class="score ${x.severity === 'major' ? 'hi' : 'mid'}">${esc(x.severity)}</div><div><div class="title">${esc(x.about)}</div><ul class="ev"><li>A: ${esc(x.claimA)} <a href="${safeUrl(x.sourceA)}" target="_blank" rel="noopener noreferrer">source</a></li><li>B: ${esc(x.claimB)} <a href="${safeUrl(x.sourceB)}" target="_blank" rel="noopener noreferrer">source</a></li></ul></div></div>`).join('') || '<p class="meta">The sources agree on the facts they share.</p>'}<p class="meta">Read: ${d.sourcesRead.map((s) => `<a href="${safeUrl(s.url)}" target="_blank" rel="noopener noreferrer">${esc(new URL(s.url).hostname.replace(/^www\./, ''))}</a>`).join(', ')}</p>`;
1198
+ },
1199
+ rewind: (r) => {
1200
+ const d = r.result;
1201
+ const main = d.fused.filter((f) => f.sources.some((s) => s !== 'guardian')).slice(0, 15);
1202
+ return `<h3>${esc(d.date)}</h3><table>${main.map((f) => `<tr><td class="num">${f.score}</td><td>${esc(f.title)} ${f.sources.map((s) => `<span class="chip">${esc(s)}</span>`).join('')}<div class="meta">${f.blips.slice(0, 2).map((b) => esc(b.detail)).join(' · ')}</div></td></tr>`).join('')}</table><h3>That day in the Guardian</h3><ul class="ev">${d.headlines.slice(0, 10).map((h) => `<li>${esc(h.time.slice(11, 16))} <a href="${safeUrl(h.url)}" target="_blank" rel="noopener noreferrer">${esc(h.title)}</a></li>`).join('')}</ul><p class="meta">Oculon recorded ${d.oculonSignals.length} signal(s) that day.</p>`;
1203
+ },
1204
+ /*onchain*/ robinhood: (r) => {
1205
+ const d = r.result;
1206
+ const row = (p) => `<tr><td>${esc(p.pool.name)}</td><td class="num">${usd(p.pool.liquidityUsd)}</td><td class="num">${p.pool.change24h != null ? esc(p.pool.change24h.toFixed(0)) + '%' : '?'}</td><td class="num">${p.pool.buys24h}/${p.pool.sells24h}</td><td>${p.flags.length ? `<span class="err">${esc(p.flags.join('; '))}</span>` : ''}</td></tr>`;
1207
+ const head = '<tr><th>pool</th><th>liquidity</th><th>24h</th><th>buys/sells</th><th>flags</th></tr>';
1208
+ return `${d.stats ? `<p>${d.stats.transactionsToday.toLocaleString('en-US')} transactions today · ${d.stats.addresses.toLocaleString('en-US')} addresses</p>` : ''}<h3>Trending pools</h3><table>${head}${d.trending.map(row).join('')}</table><h3>New pools</h3><table>${head}${d.fresh.map(row).join('')}</table>${sigList(r.signals)}`;
1209
+ },
1210
+ /*/onchain*/ aircraft: (r) => {
1211
+ const t = r.result;
1212
+ return `<h3>${esc(t.info?.registration || t.query)} · ${esc(t.status)}</h3><p class="meta">${esc([t.info?.manufacturer, t.info?.type].filter(Boolean).join(' '))}${t.info?.owner ? ' · owner ' + esc(t.info.owner) : ''}</p>${t.place ? `<p>${esc(t.place.relation)} ${esc(t.place.airport)} (${t.place.km} km)</p>` : ''}${t.change ? `<p><b>${esc(t.change)}</b></p>` : ''}${sigList(r.signals)}`;
1213
+ },
1214
+ };
1215
+ $('#inv-go').onclick = async () => {
1216
+ const kind = $('#inv-kind').value;
1217
+ let q = $('#inv-q').value.trim() || placeholders[kind];
1218
+ // Placeholders in parentheses are hints, not input.
1219
+ if (q.startsWith('(')) q = '';
1220
+ const out = $('#inv-out');
1221
+ if (kind === 'image') { out.innerHTML = `<p class="meta">Loading satellite image of ${esc(q)}…</p><img class="sat" alt="Satellite image of ${esc(q)}" src="/api/image?place=${encodeURIComponent(q)}">`; return; }
1222
+ const param = { scam: 'message', recall: 'q', emailsec: 'domain', airport: 'code', country: 'name', papers: 'topic', url: 'url', factcheck: 'claim', audit: 'packages', travel: 'place', dossier: 'name', hype: 'topic', footprint: 'domain', lights: 'place', aircraft: 'q', /*onchain*/wallet: 'address', token: 'address', /*/onchain*/air: 'place', space: 'x', /*onchain*/robinhood: 'x', deployer: 'address', /*/onchain*/launches: 'company', markets: 'x', rewind: 'date', sanctions: 'q', health: 'company', impact: 'place', contradictions: 'topic' }[kind];
1223
+ $('#inv-go').disabled = true;
1224
+ out.innerHTML = '<p class="meta">Working… some sources are rate-limited and take a while.</p>';
1225
+ try {
1226
+ const r = kind === 'audit' && /^[{]/.test(q) ? await post('/api/audit', { manifest: q }) : await api(`/api/${kind}?${param}=${encodeURIComponent(q)}`);
1227
+ const shareable = ['url', 'factcheck', 'travel', 'audit', 'recall', 'emailsec', 'papers', 'country', 'airport'].includes(kind) && !(kind === 'audit' && /^[{]/.test(q));
1228
+ out.innerHTML = views[kind](r) + (shareable ? '<p class="row" style="margin-top:14px"><button class="icon-btn" id="inv-share">Share result</button><span class="meta" id="inv-share-out"></span></p>' : '') + `<h3>Sources</h3>${renderSources(r.provenance)}`;
1229
+ if (shareable) $('#inv-share').onclick = async () => {
1230
+ const b = $('#inv-share');
1231
+ b.disabled = true;
1232
+ $('#inv-share-out').textContent = ' creating link…';
1233
+ try {
1234
+ const sh = await post('/api/share', { kind, q });
1235
+ const link = (location.hostname.startsWith('app.') ? location.origin.replace('//app.', '//') : location.origin) + sh.path;
1236
+ $('#inv-share-out').innerHTML = ` <a href="${safeUrl(link)}" target="_blank" rel="noopener noreferrer">${esc(link)}</a> <button class="icon-btn" id="inv-copy">copy</button>`;
1237
+ $('#inv-copy').onclick = () => { try { navigator.clipboard.writeText(link); $('#inv-copy').textContent = 'copied'; } catch {} };
1238
+ } catch (err) { $('#inv-share-out').innerHTML = ` <span class="err">${esc(err.message)}</span>`; b.disabled = false; }
1239
+ };
1240
+ } catch (err) { out.innerHTML = `<p class="err">${esc(err.message)}</p>`; }
1241
+ finally { $('#inv-go').disabled = false; }
1242
+ };
1243
+ $('#inv-q').addEventListener('keydown', (e) => { if (e.key === 'Enter') $('#inv-go').click(); });
1244
+
1245
+ /* forecasts */
1246
+ async function loadForecasts() {
1247
+ const { scoreboard: s, forecasts } = await api('/api/forecasts');
1248
+ const fmt = (x) => (x == null ? '—' : x.toFixed(3));
1249
+ $('#kpis').innerHTML = [
1250
+ ['forecasts', s.total], ['open', s.open], ['resolved', s.resolved],
1251
+ ['Brier model', fmt(s.brierModel)], ['Brier market', fmt(s.brierMarket)],
1252
+ ['skill vs market', s.skill == null ? '—' : Math.round(s.skill * 100) + '%'],
1253
+ ].map(([k, v]) => `<div class="kpi"><b>${esc(v)}</b><span>${esc(k)}</span></div>`).join('');
1254
+ $('#fc').innerHTML = '<tr><th>question</th><th>model</th><th>market</th><th>method</th><th>status</th><th>proof</th></tr>' + forecasts.map((p) =>
1255
+ `<tr><td>${esc(p.question)}<div class="meta">${esc(p.createdAt.slice(0, 16).replace('T', ' '))} · ${esc(p.rationale)}</div></td><td class="num">${Math.round(p.pModel * 100)}%</td><td class="num">${Math.round(p.pMarket * 100)}%</td><td>${esc(p.method)}</td><td>${p.result == null ? 'open' : 'resolved ' + (p.result ? 'YES' : 'NO')}</td><td>${p.batchId ? `<button class="icon-btn" data-verify="${esc(p.id)}">verify</button>` : '<span class="meta">unstamped</span>'}</td></tr>`).join('');
1256
+ document.querySelectorAll('[data-verify]').forEach((b) => b.onclick = async () => {
1257
+ b.disabled = true;
1258
+ try {
1259
+ const r = await api('/api/verify?id=' + encodeURIComponent(b.dataset.verify));
1260
+ $('#proof').innerHTML = `<h3>${esc(r.result.predictionId)}: ${esc(r.result.status)}</h3><ul class="ev">${r.result.steps.map((s) => `<li>${esc(s)}</li>`).join('')}</ul>`;
1261
+ } catch (err) { $('#proof').innerHTML = `<p class="err">${esc(err.message)}</p>`; }
1262
+ finally { b.disabled = false; }
1263
+ });
1264
+ }
1265
+
1266
+ /* graph: small force-directed layout on canvas */
1267
+ let graphState = null;
1268
+ const KIND_COLORS = { domain: '#6ee7b7', subdomain: '#34d399', url: '#a7f3d0', repo: '#a78bfa', org: '#60a5fa', company: '#3b82f6', topic: '#f472b6', article: '#00b8d4', story: '#fb923c', market: '#f87171', event: '#7df9ff', aircraft: '#22d3ee' };
1269
+ const wRow = (html) => `<div style="padding:5px 0;border-top:1px solid var(--line)">${html}</div>`;
1270
+ const wLink = (u, t) => (u ? `<a href="${safeUrl(u)}" target="_blank" rel="noopener noreferrer">${esc(t)}</a>` : esc(t));
1271
+ async function loadWorld() {
1272
+ api('/api/blackout?days=2').then((r) => {
1273
+ const b = r.result;
1274
+ const rows = b.outages.slice(0, 12).map((o) => wRow(`<span class="chip">${o.verified ? 'confirmed' : 'anomaly'}</span><b>${esc(o.country || '?')}</b>${o.network ? ' · ' + esc(o.network) : ''}${o.cause ? ' · ' + esc(o.cause) : ''}${o.end ? '' : ' · <b>ongoing</b>'}<br>${wLink(o.url, o.description)} <span class="meta">${esc(o.start.slice(0, 16).replace('T', ' '))} UTC</span>`));
1275
+ const routing = (b.routing || []).map((x) => wRow(`routing ${esc(x.country)}: ${x.v4Now} IPv4 prefixes vs ${x.v4Baseline} usual (${(x.change * 100).toFixed(1)}%)`));
1276
+ const ioda = b.ioda.length ? wRow('IODA top: ' + b.ioda.slice(0, 8).map((x) => esc(x.name)).join(', ')) : '';
1277
+ $('#w-blackout').innerHTML = (rows.join('') || '<p>No outages reported.</p>') + routing.join('') + ioda;
1278
+ }).catch((e) => ($('#w-blackout').textContent = 'Failed: ' + e.message));
1279
+ api('/api/hazards?days=7').then((r) => {
1280
+ const g = r.result.slice(0, 10).map((h) => wRow(`<span class="chip">${esc(h.level)}</span>${wLink(h.url, h.name)} <span class="meta">${esc(h.countries || '')} ${esc(h.severity || '')}</span>`));
1281
+ const ts = (r.bulletins || []).filter((x) => x.source !== 'NWS').map((x) => wRow(`<span class="chip">tsunami</span>${esc(x.category)}: ${wLink(x.url, x.title)}`));
1282
+ const nws = (r.bulletins || []).filter((x) => x.source === 'NWS').slice(0, 6).map((x) => wRow(`<span class="chip">US ${esc(x.category.toLowerCase())}</span>${wLink(x.url, x.title)} <span class="meta">${esc(x.area.slice(0, 90))}</span>`));
1283
+ $('#w-hazards').innerHTML = [...ts, ...g, ...nws].join('') || '<p>No alerts.</p>';
1284
+ }).catch((e) => ($('#w-hazards').textContent = 'Failed: ' + e.message));
1285
+ api('/api/cloud').then((r) => {
1286
+ const c = r.result;
1287
+ const rows = c.incidents.slice(0, 12).map((i) => wRow(`<span class="chip">${esc(i.impact)}</span><b>${esc(i.service)}</b> ${wLink(i.url, i.title)}`));
1288
+ $('#w-cloud').innerHTML = rows.join('') || '<p>No open incidents on the checked platforms.</p>';
1289
+ }).catch((e) => ($('#w-cloud').textContent = 'Failed: ' + e.message));
1290
+ }
1291
+ async function loadCalendar() {
1292
+ try {
1293
+ const r = await api('/api/calendar?days=14');
1294
+ const items = r.result.items;
1295
+ $('#cal-meta').textContent = `${r.result.from} to ${r.result.to} · ${items.length} items`;
1296
+ let day = '', html = '';
1297
+ for (const i of items) {
1298
+ if (i.date !== day) { html += `<h3 style="margin:14px 0 4px">${esc(i.date)}</h3>`; day = i.date; }
1299
+ const t = i.url ? `<a href="${safeUrl(i.url)}" target="_blank" rel="noopener noreferrer">${esc(i.title)}</a>` : esc(i.title);
1300
+ html += `<div style="padding:3px 0">${i.watched ? '★ ' : ''}<span class="chip">${esc(i.kind)}</span>${t} <span class="meta">${esc(i.detail)}</span></div>`;
1301
+ }
1302
+ $('#calendar').innerHTML = html || 'Nothing scheduled in the window.';
1303
+ } catch (e) { $('#calendar').textContent = 'Calendar failed: ' + e.message; }
1304
+ }
1305
+ async function loadLive() {
1306
+ const s = await api('/api/live');
1307
+ $('#live').innerHTML = s.length ? s.map(renderSignal).join('') : '<p class="meta">Nothing flagged yet. Bluesky surges need about 20 minutes of history after the server starts.</p>';
1308
+ }
1309
+ $('#con-go').onclick = async () => {
1310
+ const a = $('#con-a').value.trim(), b = $('#con-b').value.trim();
1311
+ if (!a || !b) return;
1312
+ $('#con-out').textContent = 'Searching…';
1313
+ try {
1314
+ const r = await api(`/api/connect?a=${encodeURIComponent(a)}&b=${encodeURIComponent(b)}`);
1315
+ if (!r.path) { $('#con-out').textContent = r.note || 'No path.'; return; }
1316
+ $('#con-out').innerHTML = `<b>${r.path.length - 1} hop(s)</b><ol class="ev">${r.path.map((p) => `<li>${p.via ? `<span class="meta">${p.via.direction === 'out' ? '→' : '←'} ${esc(p.via.rel)}</span> ` : ''}<b>${esc(p.name)}</b> <span class="chip">${esc(p.kind)}</span></li>`).join('')}</ol>`;
1317
+ } catch (e) { $('#con-out').textContent = 'Failed: ' + e.message; }
1318
+ };
1319
+ async function loadGraph() {
1320
+ const g = await api('/api/graph?limit=180');
1321
+ const deg = {};
1322
+ g.edges.forEach((e) => { deg[e.src] = (deg[e.src] || 0) + 1; deg[e.dst] = (deg[e.dst] || 0) + 1; });
1323
+ const nodes = g.nodes.filter((n) => deg[n.id]).map((n, i) => ({ ...n, x: Math.cos(i) * 200 + Math.random() * 40, y: Math.sin(i) * 200 + Math.random() * 40, vx: 0, vy: 0, deg: deg[n.id] }));
1324
+ const idx = Object.fromEntries(nodes.map((n, i) => [n.id, i]));
1325
+ const edges = g.edges.filter((e) => idx[e.src] !== undefined && idx[e.dst] !== undefined).map((e) => ({ ...e, a: idx[e.src], b: idx[e.dst] }));
1326
+ $('#graph-meta').textContent = `${nodes.length} connected entities · ${edges.length} links`;
1327
+ for (let it = 0; it < 300; it++) {
1328
+ for (let i = 0; i < nodes.length; i++) for (let j = i + 1; j < nodes.length; j++) {
1329
+ const a = nodes[i], b = nodes[j]; let dx = a.x - b.x, dy = a.y - b.y; const d2 = dx * dx + dy * dy + .01; const f = 900 / d2;
1330
+ a.vx += dx * f; a.vy += dy * f; b.vx -= dx * f; b.vy -= dy * f;
1331
+ }
1332
+ for (const e of edges) { const a = nodes[e.a], b = nodes[e.b]; const dx = b.x - a.x, dy = b.y - a.y; a.vx += dx * .02; a.vy += dy * .02; b.vx -= dx * .02; b.vy -= dy * .02; }
1333
+ for (const n of nodes) { n.vx -= n.x * .004; n.vy -= n.y * .004; n.x += n.vx * .5; n.y += n.vy * .5; n.vx *= .6; n.vy *= .6; }
1334
+ }
1335
+ graphState = { nodes, edges, hover: -1 };
1336
+ drawGraph();
1337
+ }
1338
+ function drawGraph() {
1339
+ const c = $('#graph'); const dpr = devicePixelRatio || 1;
1340
+ const w = c.clientWidth, h = c.clientHeight; c.width = w * dpr; c.height = h * dpr;
1341
+ const ctx = c.getContext('2d'); ctx.setTransform(dpr, 0, 0, dpr, 0, 0); ctx.clearRect(0, 0, w, h);
1342
+ const { nodes, edges, hover } = graphState;
1343
+ if (!nodes.length) { ctx.fillStyle = getComputedStyle(document.body).color; ctx.fillText('No linked entities yet. Run a dossier or footprint scan.', 16, 24); return; }
1344
+ const xs = nodes.map((n) => n.x), ys = nodes.map((n) => n.y);
1345
+ const minX = Math.min(...xs), maxX = Math.max(...xs), minY = Math.min(...ys), maxY = Math.max(...ys);
1346
+ const sx = (w - 160) / (maxX - minX || 1), sy = (h - 60) / (maxY - minY || 1);
1347
+ graphState.tx = (n) => [30 + (n.x - minX) * sx, 30 + (n.y - minY) * sy];
1348
+ const line = getComputedStyle(document.documentElement).getPropertyValue('--line');
1349
+ ctx.strokeStyle = line; ctx.lineWidth = 1;
1350
+ for (const e of edges) { const [x1, y1] = graphState.tx(nodes[e.a]); const [x2, y2] = graphState.tx(nodes[e.b]); ctx.beginPath(); ctx.moveTo(x1, y1); ctx.lineTo(x2, y2); ctx.stroke(); }
1351
+ const text = getComputedStyle(document.documentElement).getPropertyValue('--text');
1352
+ nodes.forEach((n, i) => {
1353
+ const [x, y] = graphState.tx(n); const r = 3 + Math.min(9, Math.sqrt(n.deg) * 2);
1354
+ ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2); ctx.fillStyle = KIND_COLORS[n.kind] || '#94a3b8'; ctx.fill();
1355
+ if (i === hover || n.deg >= 4) { ctx.fillStyle = text; ctx.font = '11px system-ui'; ctx.fillText(n.name.slice(0, 40), x + r + 3, y + 4); }
1356
+ });
1357
+ }
1358
+ $('#graph').addEventListener('mousemove', (e) => {
1359
+ if (!graphState?.tx) return;
1360
+ const rect = e.target.getBoundingClientRect(); const mx = e.clientX - rect.left, my = e.clientY - rect.top;
1361
+ let best = -1, bd = 144;
1362
+ graphState.nodes.forEach((n, i) => { const [x, y] = graphState.tx(n); const d = (x - mx) ** 2 + (y - my) ** 2; if (d < bd) { bd = d; best = i; } });
1363
+ if (best !== graphState.hover) { graphState.hover = best; drawGraph(); $('#graph-hover').textContent = best >= 0 ? `${graphState.nodes[best].kind}: ${graphState.nodes[best].name}` : 'Hover a node to see it; click to open its neighbors.'; }
1364
+ });
1365
+ $('#graph').addEventListener('click', async () => {
1366
+ if (!graphState || graphState.hover < 0) return;
1367
+ const n = graphState.nodes[graphState.hover];
1368
+ const r = await api('/api/entity?id=' + encodeURIComponent(n.id));
1369
+ $('#graph-hover').innerHTML = `<b>${esc(n.name)}</b> (${esc(n.kind)}) → ${r.neighbors.slice(0, 12).map((x) => `<span class="chip">${esc(x.rel)}</span>${esc(x.name)}`).join(' · ')}`;
1370
+ });
1371
+ addEventListener('resize', () => { if (graphState && !$('#tab-graph').hidden) drawGraph(); });
1372
+
1373
+ /* deep links: #map, #forecasts, #graph, #investigate */
1374
+
1375
+ /* ================================================================== shared helpers */
1376
+ const store = { get(k, d) { try { const v = localStorage.getItem(k); return v ? JSON.parse(v) : d; } catch { return d; } }, set(k, v) { try { localStorage.setItem(k, JSON.stringify(v)); } catch {} } };
1377
+ const fmtN = (n) => Number(n).toLocaleString('en-US');
1378
+ const ago2 = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'just now' : m < 60 ? `${m}m ago` : m < 1440 ? `${Math.round(m / 60)}h ago` : `${Math.round(m / 1440)}d ago`; };
1379
+ const goTab = (t) => document.querySelector(`nav button[data-tab="${t}"]`)?.click();
1380
+ async function postJson(path, body) {
1381
+ const r = await fetch(path, { method: 'POST', headers: { 'content-type': 'application/json', 'x-oculon': '1' }, body: JSON.stringify(body) });
1382
+ const j = await r.json().catch(() => ({}));
1383
+ if (!r.ok) throw new Error(j.error || r.statusText);
1384
+ return j;
1385
+ }
1386
+ function toast(kicker, text, onClick) {
1387
+ let box = document.querySelector('.toasts');
1388
+ if (!box) { box = document.createElement('div'); box.className = 'toasts'; document.body.appendChild(box); }
1389
+ const t = document.createElement('div'); t.className = 'toast'; t.innerHTML = `<div class="k">${esc(kicker)}</div><div class="t">${esc(text)}</div>`;
1390
+ t.onclick = () => { onClick?.(); t.remove(); };
1391
+ box.prepend(t); while (box.children.length > 4) box.lastChild.remove();
1392
+ setTimeout(() => t.remove(), 9000);
1393
+ }
1394
+ document.querySelectorAll('[data-go]').forEach((a) => { if (!a.dataset.bound) { a.dataset.bound = '1'; a.addEventListener('click', () => { goTab(a.dataset.go); scrollTo({ top: 0, behavior: 'smooth' }); }); } });
1395
+
1396
+ /* ================================================================== share card (PNG for posts) */
1397
+ async function shareCard({ kicker, title, score, lines = [], foot = '' }) {
1398
+ await document.fonts?.ready;
1399
+ const W = 1200, H = 675, c = document.createElement('canvas'); c.width = W; c.height = H; const x = c.getContext('2d');
1400
+ x.fillStyle = '#000'; x.fillRect(0, 0, W, H);
1401
+ const g = x.createRadialGradient(W * .82, H * .1, 10, W * .82, H * .1, 700); g.addColorStop(0, 'rgba(0,240,255,.28)'); g.addColorStop(1, 'rgba(0,240,255,0)'); x.fillStyle = g; x.fillRect(0, 0, W, H);
1402
+ x.strokeStyle = 'rgba(0,240,255,.06)'; x.lineWidth = 1; for (let i = 0; i < W; i += 60) { x.beginPath(); x.moveTo(i, 0); x.lineTo(i, H); x.stroke(); } for (let j = 0; j < H; j += 60) { x.beginPath(); x.moveTo(0, j); x.lineTo(W, j); x.stroke(); }
1403
+ x.strokeStyle = '#00f0ff'; x.lineWidth = 6; x.beginPath(); x.arc(92, 88, 22, 0, 7); x.stroke(); x.fillStyle = '#00f0ff'; x.beginPath(); x.arc(92, 88, 8, 0, 7); x.fill();
1404
+ x.fillStyle = '#fff'; x.font = '600 26px "Space Grotesk", sans-serif'; x.letterSpacing = '10px'; x.fillText('OCULON', 132, 98); x.letterSpacing = '0px';
1405
+ x.fillStyle = '#00f0ff'; x.font = '18px "Space Mono", monospace'; x.fillText(String(kicker).toUpperCase().slice(0, 70), 70, 190);
1406
+ // title: shrink the type until it fits in three lines (four at the smallest size)
1407
+ const maxW = score != null ? 900 : 1060;
1408
+ let size = 56, shown = [];
1409
+ for (; size >= 38; size -= 4) {
1410
+ x.font = `300 ${size}px "Space Grotesk", sans-serif`;
1411
+ const words = String(title).split(/\s+/), out = []; let line = '';
1412
+ for (const w of words) { const t2 = line ? `${line} ${w}` : w; if (x.measureText(t2).width > maxW) { out.push(line); line = w; } else line = t2; }
1413
+ if (line) out.push(line);
1414
+ shown = out;
1415
+ if (out.length <= 3 || (size <= 42 && out.length <= 4)) break;
1416
+ }
1417
+ if (shown.length > 4) { shown = shown.slice(0, 4); shown[3] = shown[3].replace(/\s*\S*$/, '') + '…'; }
1418
+ const lh = Math.round(size * 1.16);
1419
+ x.fillStyle = '#fff';
1420
+ shown.forEach((l, i) => x.fillText(l, 70, 250 + i * lh));
1421
+ if (score != null) { x.fillStyle = score >= 75 ? '#00f0ff' : 'rgba(0,240,255,.15)'; x.fillRect(1010, 160, 120, 120); x.strokeStyle = '#00f0ff'; x.lineWidth = 2; x.strokeRect(1010, 160, 120, 120); x.fillStyle = score >= 75 ? '#001418' : '#00f0ff'; x.font = '700 54px "Space Mono", monospace'; x.textAlign = 'center'; x.fillText(String(Math.round(score)), 1070, 238); x.font = '13px "Space Mono", monospace'; x.fillText('SCORE', 1070, 266); x.textAlign = 'left'; }
1422
+ x.font = '20px "Space Grotesk", sans-serif';
1423
+ let ly = 250 + (shown.length - 1) * lh + 58;
1424
+ for (const l of lines) {
1425
+ if (ly > H - 104) break; // keep clear of the footer rule
1426
+ x.fillStyle = '#00f0ff'; x.fillRect(70, ly - 13, 6, 6); x.fillStyle = '#9fd8e2';
1427
+ let t3 = String(l); while (x.measureText(t3).width > 1040 && t3.length > 10) t3 = t3.slice(0, -2); if (t3 !== String(l)) t3 += '…';
1428
+ x.fillText(t3, 90, ly - 4); ly += 34;
1429
+ }
1430
+ x.strokeStyle = 'rgba(255,255,255,.12)'; x.beginPath(); x.moveTo(70, H - 78); x.lineTo(W - 70, H - 78); x.stroke();
1431
+ x.fillStyle = '#7aa9b0'; x.font = '15px "Space Mono", monospace'; x.fillText((foot || 'public sources · oculon').slice(0, 110), 70, H - 44);
1432
+ const slug = String(title).toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 48).replace(/-$/, '');
1433
+ c.toBlob((b) => { const a = document.createElement('a'); a.href = URL.createObjectURL(b); a.download = `oculon-${slug || 'card'}.png`; a.click(); setTimeout(() => URL.revokeObjectURL(a.href), 4000); });
1434
+ toast('share card', 'PNG saved to your downloads');
1435
+ }
1436
+ const signalCard = (s) => shareCard({ kicker: `${s.module} · ${String(s.createdAt || s.at || '').slice(0, 16).replace('T', ' ')} UTC`, title: s.title, score: s.score, lines: (s.evidence || []).slice(0, 3).map((e) => `${e.source}: ${e.text}`), foot: `sources: ${[...new Set((s.evidence || []).map((e) => e.source))].join(', ') || s.module}` });
1437
+
1438
+ /* ================================================================== entity profile */
1439
+ function openEntity(id) {
1440
+ document.querySelectorAll('nav button').forEach((x) => x.setAttribute('aria-selected', 'false'));
1441
+ document.querySelectorAll('main > section').forEach((s) => { s.hidden = s.id !== 'tab-entity'; });
1442
+ history.replaceState(null, '', '#entity:' + encodeURIComponent(id));
1443
+ scrollTo({ top: 0 });
1444
+ loadEntity(id);
1445
+ }
1446
+ async function loadEntity(id) {
1447
+ const body = document.getElementById('ent-body'); body.innerHTML = '<div class="ov-sk" style="height:300px"></div>';
1448
+ try {
1449
+ const p = await api(`/api/profile?id=${encodeURIComponent(id)}`);
1450
+ const groups = {}; p.neighbors.forEach((n) => { (groups[n.kind] ??= []).push(n); });
1451
+ const attrs = Object.entries(p.attrs || {}).filter(([, v]) => v !== null && v !== '' && typeof v !== 'object');
1452
+ const obsKinds = {}; p.observations.forEach((o2) => { (obsKinds[`${o2.module} · ${o2.kind}`] ??= []).push(o2); });
1453
+ body.innerHTML = `<div class="ent-h"><div><span class="kind">${esc(p.kind)}</span><h1>${esc(p.name)}</h1><div class="id">${esc(p.id)} · first seen ${esc(p.firstSeen.slice(0, 10))} · updated ${esc(ago2(p.lastSeen))}</div></div>
1454
+ <div class="row"><button class="icon-btn" id="ent-back">← Back</button>${/^(company|org)$/.test(p.kind) ? '<button class="icon-btn" id="ent-dossier">Dossier</button>' : ''}<button class="go" id="ent-share">Share card</button></div></div>
1455
+ <div class="ov-kpis"><div class="ov-kpi"><span>Links</span><b>${p.neighbors.length}</b></div><div class="ov-kpi"><span>Signals</span><b>${p.signals.length}</b></div><div class="ov-kpi"><span>Observations</span><b>${p.observations.length}</b></div><div class="ov-kpi"><span>Sources</span><b>${p.sources.length}</b></div><div class="ov-kpi"><span>Strongest signal</span><b>${p.signals.length ? Math.max(...p.signals.map((s) => Math.round(s.score))) : '—'}</b></div><div class="ov-kpi"><span>Linked kinds</span><b>${Object.keys(groups).length}</b></div></div>
1456
+ <div class="ov-grid">
1457
+ <article class="ov w2"><div class="ovh"><span>Signals naming it</span></div><div class="ovb">${p.signals.slice(0, 12).map((s) => `<div class="ov-out"><div class="t"><span>${esc(s.title)}</span><span>${Math.round(s.score)} · ${esc(s.module)}</span></div>${s.evidence[0] ? `<p>${esc(s.evidence[0].source)} · ${esc(s.evidence[0].text)}</p>` : ''}</div>`).join('') || '<p class="meta">No signals mention it yet.</p>'}</div></article>
1458
+ <article class="ov w2"><div class="ovh"><span>Connected to</span><span class="meta">click to open</span></div><div class="ovb">${Object.entries(groups).sort((a, b) => b[1].length - a[1].length).map(([k, list]) => `<div class="pal-sec" style="padding-left:0">${esc(k)} · ${list.length}</div>${list.slice(0, 8).map((n) => `<div class="nb" data-ent="${esc(n.id)}"><span>${esc(n.name)}</span><span>${esc(n.rel)} · ${esc(n.source)}</span></div>`).join('')}`).join('') || '<p class="meta">No links yet.</p>'}</div></article>
1459
+ <article class="ov w2"><div class="ovh"><span>Observations</span></div><div class="ovb">${Object.entries(obsKinds).slice(0, 6).map(([k, list]) => { const vals = list.filter((o2) => o2.value != null).reverse(); const mx = Math.max(1, ...vals.map((o2) => Math.abs(o2.value))); return `<div class="pal-sec" style="padding-left:0">${esc(k)} · ${list.length}</div>${vals.length > 1 ? `<div class="ov-bars" style="height:40px">${vals.slice(-30).map((o2) => `<i style="height:${Math.max(4, Math.abs(o2.value) / mx * 100)}%" title="${esc(o2.at)} ${o2.value}"></i>`).join('')}</div>` : ''}<div class="meta">latest ${esc(list[0].at.slice(0, 16).replace('T', ' '))}${list[0].value != null ? ` · ${list[0].value}` : ''} · ${esc(list[0].source)}</div>`; }).join('') || '<p class="meta">No observations stored.</p>'}</div></article>
1460
+ <article class="ov w2"><div class="ovh"><span>Attributes and sources</span></div><div class="ovb">${attrs.slice(0, 14).map(([k, v]) => `<div class="attr"><span>${esc(k)}</span><span>${esc(String(v))}</span></div>`).join('')}<div style="margin-top:12px">${p.sources.map((s) => `<span class="ov-chip">${esc(s)}</span>`).join('')}</div></div></article>
1461
+ </div>`;
1462
+ body.querySelectorAll('[data-ent]').forEach((el) => el.addEventListener('click', () => openEntity(el.dataset.ent)));
1463
+ document.getElementById('ent-back').onclick = () => history.length > 1 ? history.back() : goTab('overview');
1464
+ document.getElementById('ent-share').onclick = () => shareCard({ kicker: `${p.kind} profile`, title: p.name, lines: [`${p.neighbors.length} links · ${p.signals.length} signals · ${p.observations.length} observations`, ...p.signals.slice(0, 2).map((s) => s.title)], foot: `sources: ${p.sources.slice(0, 8).join(', ')}` });
1465
+ const d = document.getElementById('ent-dossier'); if (d) d.onclick = () => runInvestigate('dossier', p.name);
1466
+ } catch (e) { body.innerHTML = `<p class="err">${esc(e.message)}</p>`; }
1467
+ }
1468
+ addEventListener('hashchange', () => { if (location.hash.startsWith('#entity:')) loadEntity(decodeURIComponent(location.hash.slice(8))); });
1469
+ function runInvestigate(kind, q) {
1470
+ goTab('investigate');
1471
+ const sel = document.getElementById('inv-kind'); sel.value = kind; sel.dispatchEvent(new Event('change'));
1472
+ document.getElementById('inv-q').value = q;
1473
+ document.getElementById('inv-go').click();
1474
+ }
1475
+ async function runConsoleIn(cmd) {
1476
+ goTab('investigate');
1477
+ const out = document.getElementById('inv-out');
1478
+ out.innerHTML = `<p class="meta loading">Running oculon ${esc(cmd)}…</p>`;
1479
+ try { const r = await api(`/api/console?cmd=${encodeURIComponent(cmd)}`); out.innerHTML = `<h3>oculon ${esc(cmd)}</h3><pre>${esc(r.output)}</pre>`; }
1480
+ catch (e) { out.innerHTML = `<p class="err">${esc(e.message)}</p>`; }
1481
+ }
1482
+
1483
+ /* ================================================================== command palette (Ctrl+K) */
1484
+ (function palette() {
1485
+ const bg = document.createElement('div'); bg.className = 'pal-bg'; bg.hidden = true;
1486
+ bg.innerHTML = `<div class="pal" role="dialog" aria-label="Command palette"><input id="pal-q" placeholder="Search entities, run a module, jump to a tab… /*onchain*/(CVE, 0x…, AS123, domain, place, company)/*/onchain*//*offchain*/(CVE, AS123, domain, place, company)/*/offchain*/" autocomplete="off" spellcheck="false"><div class="pal-list" id="pal-list"></div><div class="pal-foot"><span>↑↓ move</span><span>↵ run</span><span>esc close</span></div></div>`;
1487
+ document.body.appendChild(bg);
1488
+ const input = bg.querySelector('#pal-q'), list = bg.querySelector('#pal-list');
1489
+ let items = [], sel = 0, seq = 0;
1490
+ const tabs = [...document.querySelectorAll('nav button')].map((b) => ({ icon: '→', title: b.textContent, hint: 'tab', run: () => b.click() }));
1491
+ const actionsFor = (q) => {
1492
+ const a = [];
1493
+ if (/^CVE-\d{4}-\d{4,7}$/i.test(q)) a.push({ icon: '$', title: `CVE details for ${q.toUpperCase()}`, hint: 'oculon cve', run: () => runConsoleIn(`cve ${q}`) });
1494
+ if (/^0x[0-9a-fA-F]{40}$/.test(q)) a.push(
1495
+ /*onchain*/ { icon: '◎', title: 'Robinhood Chain token check', hint: 'heron', run: () => { goTab('robinhood'); rhCheck(q); } },
1496
+ { icon: '◎', title: 'Robinhood Chain deployer history', hint: 'oculon deployer', run: () => runConsoleIn(`deployer ${q}`) },
1497
+ { icon: '$', title: 'Wallet portfolio and risk', hint: 'magpie', run: () => runInvestigate('wallet', q) },
1498
+ { icon: '$', title: 'Token contract (Ethereum)', hint: 'magpie', run: () => runInvestigate('token', q) },
1499
+ /*/onchain*/ { icon: '!', title: 'Sanctions screening', hint: 'ofac', run: () => runInvestigate('sanctions', q) });
1500
+ if (/^AS\d{1,10}$/i.test(q) || /^[A-Z]{2}$/.test(q)) a.push({ icon: '$', title: `Routing of ${q.toUpperCase()}`, hint: 'oculon bgp', run: () => runConsoleIn(`bgp ${q}`) });
1501
+ if (/^\d{4}-\d\d-\d\d$/.test(q)) a.push({ icon: '⟲', title: `Time machine: ${q}`, hint: 'rewind', run: () => runInvestigate('rewind', q) });
1502
+ if (/^IMO\s?\d{7}$/i.test(q)) a.push({ icon: '!', title: `Sanctions screening ${q}`, hint: 'ofac', run: () => runInvestigate('sanctions', q) });
1503
+ if (/^[a-z0-9-]+(\.[a-z0-9-]+)+$/i.test(q)) a.push({ icon: '$', title: `Pre-release footprint of ${q}`, hint: 'ferret', run: () => runInvestigate('footprint', q) });
1504
+ if (q.length >= 2 && !/^0x/i.test(q)) a.push(
1505
+ { icon: '$', title: `Dossier: ${q}`, hint: 'hound', run: () => runInvestigate('dossier', q) },
1506
+ { icon: '$', title: `Hype phase: ${q}`, hint: 'cricket', run: () => runInvestigate('hype', q) },
1507
+ { icon: '$', title: `Company health: ${q}`, hint: 'health', run: () => runInvestigate('health', q) },
1508
+ { icon: '$', title: `Launch radar: ${q}`, hint: 'launches', run: () => runInvestigate('launches', q) },
1509
+ { icon: '$', title: `Contradictions: ${q}`, hint: 'sources', run: () => runInvestigate('contradictions', q) },
1510
+ { icon: '◐', title: `Night lights: ${q}`, hint: 'condor', run: () => runInvestigate('lights', q) });
1511
+ return a;
1512
+ };
1513
+ const render = () => {
1514
+ let sec = '';
1515
+ list.innerHTML = items.map((it, i) => { const head = it.sec !== sec ? `<div class="pal-sec">${esc((sec = it.sec))}</div>` : ''; return `${head}<div class="pal-it ${i === sel ? 'on' : ''}" data-i="${i}"><span class="i">${esc(it.icon)}</span><span class="t">${esc(it.title)}${it.sub ? `<small>${esc(it.sub)}</small>` : ''}</span><span class="k">${esc(it.hint)}</span></div>`; }).join('') || '<div class="pal-sec">Nothing matches. Try a company, a CVE, a 0x address or a place.</div>';
1516
+ list.querySelectorAll('.pal-it').forEach((el) => { el.onmouseenter = () => { sel = Number(el.dataset.i); list.querySelectorAll('.pal-it').forEach((x, j) => x.classList.toggle('on', j === sel)); }; el.onclick = () => runSel(); });
1517
+ list.querySelector('.pal-it.on')?.scrollIntoView({ block: 'nearest' });
1518
+ };
1519
+ const update = async () => {
1520
+ const q = input.value.trim(), my = ++seq;
1521
+ const ql = q.toLowerCase();
1522
+ items = [...actionsFor(q).map((a) => ({ ...a, sec: 'Run' })), ...tabs.filter((t) => !q || t.title.toLowerCase().includes(ql)).slice(0, q ? 4 : 20).map((t) => ({ ...t, sec: 'Go to' }))];
1523
+ sel = 0; render();
1524
+ if (q.length >= 2) {
1525
+ try {
1526
+ const ents = await (await fetch(`/api/search?q=${encodeURIComponent(q)}&limit=8`)).json();
1527
+ if (my !== seq) return;
1528
+ items = [...ents.map((e) => ({ icon: '●', title: e.name, sub: `${e.kind} · ${e.links} links`, hint: 'open', sec: 'Entities', run: () => openEntity(e.id) })), ...items];
1529
+ render();
1530
+ } catch {}
1531
+ }
1532
+ };
1533
+ const open = () => { bg.hidden = false; input.value = ''; update(); setTimeout(() => input.focus(), 10); };
1534
+ const close = () => { bg.hidden = true; };
1535
+ const runSel = () => { const it = items[sel]; if (!it) return; close(); it.run(); };
1536
+ window.openPalette = open;
1537
+ input.addEventListener('input', () => { clearTimeout(input._t); input._t = setTimeout(update, 120); });
1538
+ input.addEventListener('keydown', (e) => {
1539
+ if (e.key === 'ArrowDown') { sel = Math.min(items.length - 1, sel + 1); render(); e.preventDefault(); }
1540
+ else if (e.key === 'ArrowUp') { sel = Math.max(0, sel - 1); render(); e.preventDefault(); }
1541
+ else if (e.key === 'Enter') { runSel(); e.preventDefault(); }
1542
+ else if (e.key === 'Escape') close();
1543
+ });
1544
+ bg.addEventListener('click', (e) => { if (e.target === bg) close(); });
1545
+ addEventListener('keydown', (e) => {
1546
+ const typing = /^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement?.tagName || '');
1547
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); bg.hidden ? open() : close(); }
1548
+ else if (e.key === '/' && !typing && bg.hidden) { e.preventDefault(); open(); }
1549
+ else if (e.key === 'Escape' && !bg.hidden) close();
1550
+ });
1551
+ const btn = document.createElement('button'); btn.className = 'icon-btn'; btn.id = 'pal-btn'; btn.title = 'Search and run (Ctrl+K)'; btn.innerHTML = '⌕ <span class="kbd">Ctrl K</span>'; btn.onclick = open;
1552
+ document.querySelector('header .toplink')?.before(btn);
1553
+ })();
1554
+
1555
+ /*onchain*//* ================================================================== Robinhood Chain tab */
1556
+ let rhTimer = null;
1557
+ function rhVerdictHtml(t) {
1558
+ const v = t.verdict || 'UNKNOWN';
1559
+ return `<div class="row" style="justify-content:space-between;align-items:baseline"><div style="font-size:30px;font-weight:300">${esc(t.symbol || t.name || (t.address.slice(0, 8) + '…'))}</div><span class="sc2 ${v === 'DANGER' ? 'hi' : v === 'CAUTION' ? 'mid' : ''}" style="padding:4px 12px;font:700 13px var(--mono);border:1px solid var(--line)">${esc(v)}</span></div>
1560
+ <div class="ov-chain" style="margin-top:12px"><div>Holders<b>${t.holders == null ? '?' : fmtN(t.holders)}</b></div><div>Top 10<b>${t.top10Share == null ? '?' : Math.round(t.top10Share * 100) + '%'}</b></div><div>Verified<b>${t.verified == null ? '?' : t.verified ? 'yes' : 'no'}</b></div></div>
1561
+ ${t.reasons.map((r) => `<div class="ov-kv"><span>${esc(r)}</span><span>flag</span></div>`).join('') || '<p class="meta">No risk flags.</p>'}
1562
+ <div class="ov-kv"><span>Deployer <span class="elink" data-dep="${esc(t.deployer.address)}">${esc(t.deployer.address.slice(0, 10))}…</span></span><span>${t.deployer.otherTokens} other · ${t.deployer.dead} dead</span></div>
1563
+ ${(t.pools || []).slice(0, 3).map((p) => `<div class="ov-kv"><span>${esc(p.pool.name)}</span><span>liq $${fmtN(Math.round(p.pool.liquidityUsd))}</span></div>`).join('')}
1564
+ <div class="meta" style="margin-top:8px;word-break:break-all">${esc(t.address)}</div>`;
1565
+ }
1566
+ async function rhCheck(addr) {
1567
+ document.getElementById('rh-addr').value = addr;
1568
+ const box = document.getElementById('rh-verdict'); box.innerHTML = '<div class="ov-sk"></div>';
1569
+ document.getElementById('rh-share').hidden = true;
1570
+ try {
1571
+ const r = await api(`/api/rhtoken?address=${encodeURIComponent(addr)}`);
1572
+ const t = r.result; box.innerHTML = rhVerdictHtml(t);
1573
+ box.querySelectorAll('[data-dep]').forEach((el) => el.onclick = () => runConsoleIn(`deployer ${el.dataset.dep}`));
1574
+ const sh = document.getElementById('rh-share'); sh.hidden = false;
1575
+ sh.onclick = () => shareCard({ kicker: `Robinhood Chain token · ${t.verdict}`, title: `${t.symbol || t.address.slice(0, 10)} on Robinhood Chain: ${t.verdict}`, lines: t.reasons.length ? t.reasons : ['no risk flags'], foot: 'sources: blockscout, geckoterminal · heuristics, not an audit' });
1576
+ } catch (e) { box.innerHTML = `<p class="err">${esc(e.message)}</p>`; }
1577
+ }
1578
+ async function loadRobinhood() {
1579
+ document.getElementById('rh-upd').textContent = new Date().toUTCString().slice(17, 25) + ' UTC';
1580
+ try {
1581
+ const r = await api('/api/robinhood'); const st = r.result.stats;
1582
+ if (st) { document.getElementById('rk-block').textContent = fmtN(st.blocks); document.getElementById('rk-txs').textContent = fmtN(st.transactionsToday); document.getElementById('rk-addr').textContent = fmtN(st.addresses); document.getElementById('rk-gas').textContent = `${st.gasAverage}`; }
1583
+ const fresh = r.result.fresh;
1584
+ document.getElementById('rk-flag').textContent = `${fresh.filter((p) => p.flags.length).length}/${fresh.length}`;
1585
+ document.getElementById('rh-poolsn').textContent = `${fresh.length} pools`;
1586
+ document.getElementById('rh-pools').innerHTML = fresh.slice(0, 14).map((p) => `<div class="ov-pool" data-tok="${esc(p.pool.token)}" style="cursor:pointer"><span>${esc(p.pool.name)} <span class="meta">· ${p.ageHours.toFixed(1)}h · liq $${fmtN(Math.round(p.pool.liquidityUsd))}</span></span><span class="f ${p.flags.length ? 'bad' : ''}">${esc(p.flags[0] || `${p.pool.buys24h}/${p.pool.sells24h} b/s`)}</span></div>`).join('');
1587
+ document.querySelectorAll('#rh-pools [data-tok]').forEach((el) => el.onclick = () => rhCheck(el.dataset.tok));
1588
+ document.getElementById('rh-trend').innerHTML = r.result.trending.slice(0, 10).map((p) => `<div class="ov-pool" data-tok="${esc(p.pool.token)}" style="cursor:pointer"><span>${esc(p.pool.name)}</span><span style="color:${(p.pool.change24h ?? 0) < 0 ? 'var(--bad)' : '#3fd16b'}">${p.pool.change24h == null ? '' : (p.pool.change24h > 0 ? '+' : '') + p.pool.change24h.toFixed(1) + '%'} · $${fmtN(Math.round(p.pool.volume24h || 0))} vol</span></div>`).join('');
1589
+ document.querySelectorAll('#rh-trend [data-tok]').forEach((el) => el.onclick = () => rhCheck(el.dataset.tok));
1590
+ } catch (e) { document.getElementById('rh-pools').innerHTML = `<p class="err">${esc(e.message)}</p>`; }
1591
+ api('/api/rh/deployers?limit=12').then((d) => {
1592
+ document.getElementById('rk-dep').textContent = d.length;
1593
+ document.getElementById('rh-deps').innerHTML = `<table><tr><th>deployer</th><th>tokens</th><th>dead</th><th>verdict</th></tr>${d.map((x) => `<tr data-dep="${esc(x.address)}" style="cursor:pointer"><td class="num">${esc(x.address.slice(0, 10))}…${esc(x.address.slice(-4))}</td><td class="num">${x.tokens}</td><td class="num">${x.dead ?? '—'}</td><td class="num" style="color:${x.verdict === 'DANGER' ? 'var(--bad)' : x.verdict === 'CAUTION' ? 'var(--accent)' : 'inherit'}">${esc(x.verdict)}</td></tr>`).join('')}</table>`;
1594
+ document.querySelectorAll('#rh-deps [data-dep]').forEach((el) => el.onclick = () => runConsoleIn(`deployer ${el.dataset.dep}`));
1595
+ }).catch(() => {});
1596
+ api('/api/watch').then((w) => {
1597
+ const rh = w.filter((x) => /@robinhood$/i.test(x.target));
1598
+ document.getElementById('rh-watch').innerHTML = rh.map((x) => { const a = x.target.split('@')[0]; return `<div class="ov-pool" data-tok="${esc(a)}" style="cursor:pointer"><span>${esc(x.label || a.slice(0, 12) + '…')}</span><span class="meta">${x.lastRun ? 'checked ' + esc(ago2(x.lastRun)) : 'not run yet'}</span></div>`; }).join('') || '<p class="meta">No Robinhood Chain tokens on the watchlist. Add one with oculon watch add token 0x…@robinhood.</p>';
1599
+ document.querySelectorAll('#rh-watch [data-tok]').forEach((el) => el.onclick = () => rhCheck(el.dataset.tok));
1600
+ }).catch(() => {});
1601
+ api('/api/signals?limit=200').then((s) => {
1602
+ const h = s.filter((x) => x.module === 'heron').slice(0, 8);
1603
+ document.getElementById('rh-sigs').innerHTML = h.map((x) => `<div class="ov-out"><div class="t"><span>${esc(x.title)}</span><span>${Math.round(x.score)} · ${esc(ago2(x.createdAt))}</span></div></div>`).join('') || '<p class="meta">No Heron signals yet.</p>';
1604
+ }).catch(() => {});
1605
+ }
1606
+ document.getElementById('rh-refresh').onclick = loadRobinhood;
1607
+ document.getElementById('rh-check').onclick = () => { const v = document.getElementById('rh-addr').value.trim(); if (/^0x[0-9a-fA-F]{40}$/.test(v)) rhCheck(v); else toast('token check', 'Enter a 0x… address with 40 hex characters'); };
1608
+ document.getElementById('rh-addr').addEventListener('keydown', (e) => { if (e.key === 'Enter') document.getElementById('rh-check').click(); });
1609
+ rhTimer = setInterval(() => { if (!document.getElementById('tab-robinhood').hidden && document.getElementById('rh-auto').checked && !document.hidden) loadRobinhood(); }, 60000);/*/onchain*/
1610
+
1611
+ /* ================================================================== signal inbox */
1612
+ let inbox = [], ibMods = new Set();
1613
+ const readSet = new Set(store.get('oculon-read', []));
1614
+ const votes = store.get('oculon-votes', {});
1615
+ const saveRead = () => store.set('oculon-read', [...readSet].slice(-3000));
1616
+ function inboxBadge() {
1617
+ const n = inbox.filter((s) => !readSet.has(s.id)).length;
1618
+ const b = document.querySelector('nav button[data-tab="inbox"]'); if (b) b.textContent = n ? `Inbox · ${n}` : 'Inbox';
1619
+ const c = document.getElementById('ib-count'); if (c) c.textContent = `${inbox.length} signals · ${n} unread`;
1620
+ }
1621
+ function renderInbox() {
1622
+ const min = Number(document.getElementById('ib-min').value), unread = document.getElementById('ib-unread').checked, q = document.getElementById('ib-q').value.trim().toLowerCase();
1623
+ document.getElementById('ib-minv').textContent = min;
1624
+ const mods = [...new Set(inbox.map((s) => s.module))].sort();
1625
+ document.getElementById('ib-mods').innerHTML = mods.map((m) => `<button data-m="${esc(m)}" class="${ibMods.has(m) ? 'on' : ''}">${esc(m)} ${inbox.filter((s) => s.module === m).length}</button>`).join('');
1626
+ document.querySelectorAll('#ib-mods button').forEach((b) => b.onclick = () => { ibMods.has(b.dataset.m) ? ibMods.delete(b.dataset.m) : ibMods.add(b.dataset.m); renderInbox(); });
1627
+ const list = inbox.filter((s) => s.score >= min && (!unread || !readSet.has(s.id)) && (!ibMods.size || ibMods.has(s.module)) && (!q || `${s.title} ${(s.evidence || []).map((e) => e.text).join(' ')}`.toLowerCase().includes(q))).slice(0, 150);
1628
+ document.getElementById('ib-list').innerHTML = list.map((s, i) => { const n = Math.round(s.score); return `<div class="ib ${readSet.has(s.id) ? '' : 'unread'} ${s._new ? 'new' : ''}" data-id="${esc(s.id)}" style="animation-delay:${Math.min(i, 15) * 25}ms"><div class="sc2 ${n >= 75 ? 'hi' : n >= 55 ? 'mid' : ''}">${n}</div><div><h4>${esc(s.title)}</h4><div class="m">${esc(s.module)} · ${esc(ago2(s.createdAt))}${s.entity ? ` · <span class="elink" data-ent="${esc(s.entity)}">open entity</span>` : ''}</div>${(s.evidence || []).slice(0, 2).map((e) => `<div class="ev2"><b>${esc(e.source)}</b>${e.url ? `<a href="${esc(e.url)}" target="_blank" rel="noopener">${esc(e.text)}</a>` : esc(e.text)}</div>`).join('')}</div><div class="acts"><button data-v="useful" class="${votes[s.id] === 'useful' ? 'voted' : ''}">Useful</button><button data-v="noise" class="${votes[s.id] === 'noise' ? 'voted' : ''}">Noise</button><button data-share>Share</button><button data-read>${readSet.has(s.id) ? 'Unread' : 'Read'}</button></div></div>`; }).join('') || '<p class="meta">Nothing matches these filters.</p>';
1629
+ inbox.forEach((s) => { delete s._new; });
1630
+ document.querySelectorAll('#ib-list .ib').forEach((el) => {
1631
+ const s = inbox.find((x) => x.id === el.dataset.id);
1632
+ el.querySelector('h4').onclick = () => { readSet.add(s.id); saveRead(); el.classList.remove('unread'); inboxBadge(); if (s.entity) openEntity(s.entity); };
1633
+ el.querySelector('[data-ent]')?.addEventListener('click', () => openEntity(s.entity));
1634
+ el.querySelector('[data-read]').onclick = () => { readSet.has(s.id) ? readSet.delete(s.id) : readSet.add(s.id); saveRead(); renderInbox(); inboxBadge(); };
1635
+ el.querySelector('[data-share]').onclick = () => signalCard(s);
1636
+ el.querySelectorAll('[data-v]').forEach((b) => b.onclick = async () => {
1637
+ try { await postJson('/api/feedback', { signalId: s.id, verdict: b.dataset.v }); votes[s.id] = b.dataset.v; store.set('oculon-votes', votes); readSet.add(s.id); saveRead(); renderInbox(); inboxBadge(); toast('vote saved', `${b.dataset.v} · moves the ${s.module} alert bar`); }
1638
+ catch (e) { toast('vote failed', e.message); }
1639
+ });
1640
+ });
1641
+ }
1642
+ async function loadInbox() {
1643
+ inbox = (await api('/api/signals?limit=200')).filter((s) => s.module !== 'live');
1644
+ renderInbox(); inboxBadge();
1645
+ }
1646
+ ['ib-min', 'ib-unread', 'ib-q'].forEach((id) => document.getElementById(id).addEventListener('input', renderInbox));
1647
+ document.getElementById('ib-allread').onclick = () => { inbox.forEach((s) => readSet.add(s.id)); saveRead(); renderInbox(); inboxBadge(); };
1648
+
1649
+ /* ================================================================== live stream + browser alerts */
1650
+ const notifyBtn = document.getElementById('ib-notify');
1651
+ const notifyOn = () => store.get('oculon-notify', false) && 'Notification' in window && Notification.permission === 'granted';
1652
+ const syncNotifyBtn = () => { notifyBtn.textContent = notifyOn() ? 'Alerts on' : 'Enable alerts'; notifyBtn.classList.toggle('on', notifyOn()); };
1653
+ notifyBtn.onclick = async () => {
1654
+ if (!('Notification' in window)) return toast('alerts', 'This browser does not support notifications');
1655
+ if (notifyOn()) { store.set('oculon-notify', false); return syncNotifyBtn(); }
1656
+ const p = await Notification.requestPermission();
1657
+ store.set('oculon-notify', p === 'granted'); syncNotifyBtn();
1658
+ if (p === 'granted') toast('alerts on', 'Signals scoring 75+ will notify you while this app is open');
1659
+ };
1660
+ syncNotifyBtn();
1661
+ if ('EventSource' in window) {
1662
+ const es = new EventSource('/api/stream');
1663
+ es.addEventListener('signal', (ev) => {
1664
+ const s = JSON.parse(ev.data);
1665
+ if (s.module === 'live') return;
1666
+ s._new = true; inbox.unshift(s); inboxBadge();
1667
+ if (!document.getElementById('tab-inbox').hidden) renderInbox();
1668
+ if (s.score >= 65) toast(`new signal · ${s.module} · ${Math.round(s.score)}`, s.title, () => { goTab('inbox'); });
1669
+ if (s.score >= 75 && notifyOn() && document.hidden) { try { new Notification(`Oculon · ${s.module} ${Math.round(s.score)}`, { body: s.title, icon: '/assets/icon-192.png', tag: s.id }); } catch {} }
1670
+ });
1671
+ }
1672
+
1673
+ /* ================================================================== timeline */
1674
+ let tlData = [], tlPlay = null;
1675
+ async function loadTimeline() {
1676
+ tlData = await api(`/api/timeline?hours=${document.getElementById('tl-hours').value}`);
1677
+ drawTimeline();
1678
+ }
1679
+ function drawTimeline() {
1680
+ const c = document.getElementById('tl-chart'), dpr = devicePixelRatio || 1, W = c.clientWidth, H = 180;
1681
+ c.width = W * dpr; c.height = H * dpr; const x = c.getContext('2d'); x.scale(dpr, dpr); x.clearRect(0, 0, W, H);
1682
+ const hours = Number(document.getElementById('tl-hours').value), end = Date.now(), start = end - hours * 3600000;
1683
+ const n = Math.min(hours, 168), bucket = (end - start) / n, counts = Array(n).fill(0), maxs = Array(n).fill(0);
1684
+ for (const s of tlData) { const i = Math.min(n - 1, Math.floor((Date.parse(s.at) - start) / bucket)); if (i >= 0) { counts[i]++; maxs[i] = Math.max(maxs[i], s.score); } }
1685
+ const mx = Math.max(1, ...counts), bw = W / n;
1686
+ const accent = getComputedStyle(document.documentElement).getPropertyValue('--accent').trim() || '#00f0ff';
1687
+ counts.forEach((v, i) => { const h = (v / mx) * (H - 30); x.fillStyle = accent; x.globalAlpha = .3 + .7 * (v / mx); x.fillRect(i * bw + 1, H - 20 - h, Math.max(1, bw - 2), h); if (maxs[i] >= 85) { x.globalAlpha = 1; x.fillStyle = '#ff6b6b'; x.fillRect(i * bw + 1, H - 22 - h, Math.max(1, bw - 2), 2); } });
1688
+ x.globalAlpha = 1;
1689
+ const r = Number(document.getElementById('tl-range').value) / 100, t = start + r * (end - start), px = r * W;
1690
+ x.strokeStyle = '#fff'; x.lineWidth = 1.5; x.beginPath(); x.moveTo(px, 0); x.lineTo(px, H - 20); x.stroke();
1691
+ x.fillStyle = getComputedStyle(document.documentElement).getPropertyValue('--muted').trim(); x.font = '11px "Space Mono", monospace';
1692
+ for (let k = 0; k <= 4; k++) { const tt = start + (k / 4) * (end - start); x.textAlign = k === 0 ? 'left' : k === 4 ? 'right' : 'center'; x.fillText(new Date(tt).toUTCString().slice(5, 22), (k / 4) * W, H - 4); }
1693
+ x.textAlign = 'left';
1694
+ const win = Math.max(bucket * 3, 3 * 3600000), inWin = tlData.filter((s) => Math.abs(Date.parse(s.at) - t) <= win / 2).sort((a, b) => b.score - a.score);
1695
+ document.getElementById('tl-at').textContent = `${new Date(t).toUTCString().slice(0, 22)} UTC`;
1696
+ document.getElementById('tl-win').textContent = `${inWin.length} signals within ±${Math.round(win / 7200000)}h · ${tlData.length} in window`;
1697
+ document.getElementById('tl-list').innerHTML = inWin.slice(0, 40).map((s) => `<div class="tl-it"><span class="d">${esc(s.at.slice(5, 16).replace('T', ' '))}</span><span class="s">${Math.round(s.score)}</span><span>${s.entity ? `<span class="elink" data-ent="${esc(s.entity)}">${esc(s.title)}</span>` : esc(s.title)} <span class="meta">· ${esc(s.module)}</span></span></div>`).join('') || '<p class="meta">No signals near this moment.</p>';
1698
+ document.querySelectorAll('#tl-list [data-ent]').forEach((el) => el.onclick = () => openEntity(el.dataset.ent));
1699
+ }
1700
+ document.getElementById('tl-range').addEventListener('input', drawTimeline);
1701
+ document.getElementById('tl-hours').addEventListener('change', loadTimeline);
1702
+ document.getElementById('tl-play').onclick = () => {
1703
+ const b = document.getElementById('tl-play'), r = document.getElementById('tl-range');
1704
+ if (tlPlay) { clearInterval(tlPlay); tlPlay = null; b.textContent = '▶ Play'; return; }
1705
+ if (Number(r.value) >= 100) r.value = 0;
1706
+ b.textContent = '❚❚ Pause';
1707
+ tlPlay = setInterval(() => { r.value = Math.min(100, Number(r.value) + 0.5); drawTimeline(); if (Number(r.value) >= 100) { clearInterval(tlPlay); tlPlay = null; b.textContent = '▶ Play'; } }, 60);
1708
+ };
1709
+ addEventListener('resize', () => { if (!document.getElementById('tab-timeline').hidden) drawTimeline(); });
1710
+
1711
+ /* ================================================================== sources health */
1712
+ async function loadSources() {
1713
+ const s = await api('/api/sources');
1714
+ const fresh = s.hosts.filter((h) => h.state === 'fresh').length, today = s.hosts.filter((h) => h.state !== 'stale').length;
1715
+ const full = s.keys.filter((k) => k.set === k.total).length, none = s.keys.filter((k) => !k.set).length;
1716
+ const near = s.quota.filter((q) => q.budget && q.used / q.budget >= 0.8).length;
1717
+ document.getElementById('src-kpis').innerHTML = `<div class="ov-kpi"><span>Hosts in cache</span><b>${s.hosts.length}</b></div><div class="ov-kpi"><span>Answered · 1h</span><b>${fresh}</b></div><div class="ov-kpi"><span>Answered · 24h</span><b>${today}</b></div><div class="ov-kpi"><span>Key groups complete</span><b>${full}/${s.keys.length}</b></div><div class="ov-kpi"><span>Key groups empty</span><b>${none}</b></div><div class="ov-kpi"><span>Budgets above 80%</span><b>${near}</b></div>`;
1718
+ document.getElementById('src-hosts').innerHTML = `<div class="hosts">${s.hosts.map((h) => `<div class="host" title="${esc(h.cachedResponses)} cached responses"><span class="st ${h.state}"></span><span>${esc(h.host)}</span><span>${esc(ago2(h.lastFetch))}</span></div>`).join('')}</div>`;
1719
+ document.getElementById('src-keys').innerHTML = s.keys.map((k) => `<div class="keyrow"><div>${esc(k.group)}<small>${k.missing.length ? 'missing: ' + esc(k.missing.join(', ')) : 'all set'}</small></div><b class="${k.set === k.total ? 'full' : k.set ? 'part' : 'none'}">${k.set}/${k.total}</b></div>`).join('');
1720
+ const qs = s.quota.filter((q) => q.budget).sort((a, b) => b.used / b.budget - a.used / a.budget);
1721
+ const el = document.getElementById('src-quota');
1722
+ el.innerHTML = `<div class="ov-qgrid">${qs.slice(0, 24).map((x) => `<div class="ov-q"><div class="t"><span>${esc(x.source)}</span><span>${x.used} / ${x.budget}</span></div><div class="ov-meter"><i data-w="${Math.max(1.5, Math.min(100, (x.used / x.budget) * 100)).toFixed(1)}"></i></div></div>`).join('')}</div>`;
1723
+ setTimeout(() => el.querySelectorAll('[data-w]').forEach((i) => { i.style.width = `${i.dataset.w}%`; }), 60);
1724
+ }
1725
+ document.getElementById('src-refresh').onclick = loadSources;
1726
+
1727
+ /* ================================================================== accuracy */
1728
+ async function loadAccuracy() {
1729
+ const [a, f] = await Promise.all([api('/api/accuracy'), api('/api/forecasts')]);
1730
+ const s = a.scoops, cal = a.calibration, sb = a.forecasts;
1731
+ document.getElementById('acc-kpis').innerHTML = `<div class="ov-kpi"><span>Signals checked</span><b>${s.checked}</b></div><div class="ov-kpi"><span>Later in the media</span><b>${s.covered}</b></div><div class="ov-kpi"><span>Oculon first</span><b>${s.oculonFirst}</b></div><div class="ov-kpi"><span>Median lead</span><b>${s.medianLeadHours == null ? '—' : (s.medianLeadHours > 0 ? '+' : '') + s.medianLeadHours + 'h'}</b></div><div class="ov-kpi"><span>Best radar bar</span><b>${cal?.best ? cal.best.threshold : '—'}</b></div><div class="ov-kpi"><span>Forecasts open</span><b>${sb.open}/${sb.total}</b></div>`;
1732
+ document.getElementById('acc-scoops').innerHTML = `<p class="meta" style="margin:0 0 10px">A negative lead means the media covered it before Oculon flagged it. This is measured honestly; most Wikipedia spikes follow the news.</p>${(s.best.length ? s.best : s.pending).slice(0, 8).map((x) => `<div class="ov-kv"><span>${esc(x.subject)}</span><span>${x.leadHours == null ? 'pending' : (x.leadHours > 0 ? '+' : '') + x.leadHours.toFixed(1) + 'h'}</span></div>`).join('')}`;
1733
+ document.getElementById('acc-cal').innerHTML = cal ? `<p class="meta" style="margin:0 0 10px">${cal.samples} radar items over ${cal.days} days, ${cal.materialized} became news. Computed ${esc(ago2(cal.computedAt))}.</p><table class="cal-t"><tr><th>score ≥</th><th>flagged</th><th>hits</th><th>precision</th><th>recall</th><th>F1</th></tr>${cal.rows.map((r) => `<tr class="${cal.best && r.threshold === cal.best.threshold ? 'best' : ''}"><td>${r.threshold}</td><td>${r.flagged}</td><td>${r.hits}</td><td>${r.precision ?? '—'}</td><td>${r.recall ?? '—'}</td><td>${r.f1 ?? '—'}</td></tr>`).join('')}</table>` : '<p class="meta">No calibration yet. Run oculon calibrate.</p>';
1734
+ const el = document.getElementById('acc-fc');
1735
+ el.innerHTML = `<div class="ov-chain"><div>Resolved<b>${sb.resolved}</b></div><div>Brier · Oculon<b>${sb.brierModel ?? '—'}</b></div><div>Brier · market<b>${sb.brierMarket ?? '—'}</b></div></div>${f.forecasts.slice(0, 8).map((x) => `<div style="padding:10px 0;border-bottom:1px solid var(--line)"><div style="font-size:14.5px">${esc(x.question)}</div><div class="ov-prob"><span>Oculon</span><div class="ov-meter"><i data-w="${(x.pModel * 100).toFixed(1)}"></i></div><span>${Math.round(x.pModel * 100)}%</span></div><div class="ov-prob mk"><span>Market</span><div class="ov-meter"><i data-w="${(x.pMarket * 100).toFixed(1)}"></i></div><span>${Math.round(x.pMarket * 100)}%</span></div><div class="meta">${x.resolvedAt ? `resolved ${esc(x.result ?? '')}` : 'open'} · ${esc(x.method)} · ${esc(x.createdAt.slice(0, 10))}</div></div>`).join('') || '<p class="meta">No forecasts yet.</p>'}`;
1736
+ setTimeout(() => el.querySelectorAll('[data-w]').forEach((i) => { i.style.width = `${i.dataset.w}%`; }), 60);
1737
+ }
1738
+
1739
+ /* ================================================================== overview: drag to reorder, hide and restore cards */
1740
+ (function ovLayout() {
1741
+ const grid = document.querySelector('#tab-overview .ov-grid'); if (!grid) return;
1742
+ const cards = [...grid.querySelectorAll('.ov')];
1743
+ cards.forEach((c) => { c.dataset.key = c.querySelector('.ovb')?.id || c.querySelector('.ovh span')?.textContent; });
1744
+ const layout = store.get('oculon-ov-layout', { order: [], hidden: [] });
1745
+ const apply = () => {
1746
+ const byKey = new Map(cards.map((c) => [c.dataset.key, c]));
1747
+ [...layout.order.filter((k) => byKey.has(k)), ...cards.map((c) => c.dataset.key).filter((k) => !layout.order.includes(k))].forEach((k) => grid.appendChild(byKey.get(k)));
1748
+ cards.forEach((c) => { c.hidden = layout.hidden.includes(c.dataset.key); });
1749
+ let bar = document.getElementById('ov-hidden'); if (!bar) { bar = document.createElement('div'); bar.id = 'ov-hidden'; bar.className = 'ov-hidden'; grid.after(bar); }
1750
+ bar.innerHTML = (layout.hidden.length ? `hidden cards: ${layout.hidden.map((k) => `<button data-k="${esc(k)}">+ ${esc(byKey.get(k)?.querySelector('.ovh span')?.textContent || k)}</button>`).join('')}` : 'Drag cards to reorder, × to hide.') + ' <button data-reset>Reset layout</button>';
1751
+ bar.querySelectorAll('[data-k]').forEach((b) => b.onclick = () => { layout.hidden = layout.hidden.filter((k) => k !== b.dataset.k); store.set('oculon-ov-layout', layout); apply(); });
1752
+ bar.querySelector('[data-reset]').onclick = () => { layout.order = []; layout.hidden = []; store.set('oculon-ov-layout', layout); cards.forEach((c) => grid.appendChild(c)); apply(); };
1753
+ };
1754
+ let dragging = null;
1755
+ cards.forEach((c) => {
1756
+ c.draggable = true;
1757
+ const x = document.createElement('button'); x.className = 'pin'; x.title = 'Hide card'; x.textContent = '×';
1758
+ x.onclick = (e) => { e.stopPropagation(); layout.hidden.push(c.dataset.key); store.set('oculon-ov-layout', layout); apply(); };
1759
+ c.querySelector('.ovh')?.appendChild(x);
1760
+ c.addEventListener('dragstart', () => { dragging = c; c.classList.add('dragging'); });
1761
+ c.addEventListener('dragend', () => { c.classList.remove('dragging'); cards.forEach((d) => d.classList.remove('drop')); dragging = null; layout.order = [...grid.querySelectorAll('.ov')].map((d) => d.dataset.key); store.set('oculon-ov-layout', layout); });
1762
+ c.addEventListener('dragover', (e) => { e.preventDefault(); if (dragging && dragging !== c) c.classList.add('drop'); });
1763
+ c.addEventListener('dragleave', () => c.classList.remove('drop'));
1764
+ c.addEventListener('drop', (e) => { e.preventDefault(); c.classList.remove('drop'); if (!dragging || dragging === c) return; const r = c.getBoundingClientRect(); grid.insertBefore(dragging, e.clientX > r.left + r.width / 2 ? c.nextSibling : c); });
1765
+ });
1766
+ apply();
1767
+ })();
1768
+
1769
+ /* ================================================================== PWA */
1770
+ if ('serviceWorker' in navigator) navigator.serviceWorker.register('/sw.js').catch(() => {});
1771
+
1772
+ const fromHash = () => document.querySelector(`nav button[data-tab="${CSS.escape(location.hash.slice(1))}"]`)?.click();
1773
+ document.querySelectorAll('nav button').forEach((b) => b.addEventListener('click', () => history.replaceState(null, '', '#' + b.dataset.tab)));
1774
+ addEventListener('hashchange', fromHash);
1775
+ if (location.hash.startsWith('#entity:')) openEntity(decodeURIComponent(location.hash.slice(8)));
1776
+ else if (location.hash) fromHash();
1777
+ loadInbox().catch(() => {});
1778
+ if (!loaded.overview && !document.getElementById('tab-overview').hidden) { loaded.overview = true; loadOverview(); }
1779
+
1780
+ /* ---------- motion ---------- */
1781
+ (function motion() {
1782
+ const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
1783
+ // Spotlights follow the pointer inside each card; drift offsets are staggered.
1784
+ const wire = (root) => root.querySelectorAll('.card').forEach((el, i) => {
1785
+ if (el.dataset.fx) return; el.dataset.fx = '1'; el.style.setProperty('--i', i);
1786
+ el.addEventListener('pointermove', (e) => { const r = el.getBoundingClientRect(); el.style.setProperty('--mx', `${e.clientX - r.left}px`); el.style.setProperty('--my', `${e.clientY - r.top}px`); });
1787
+ });
1788
+ wire(document);
1789
+ // "Loading…" placeholders shimmer until their content arrives.
1790
+ const shimmer = () => document.querySelectorAll('main *').forEach((el) => { if (el.children.length === 0 && /^(Loading|Rewriting|Running|Asking|Searching)…?\.{0,3}$/.test(el.textContent.trim())) el.classList.add('loading'); else el.classList.remove('loading'); });
1791
+ // Numbers in KPI tiles count up when they are written.
1792
+ const countUp = (b) => {
1793
+ if (b.dataset.anim) return; // our own frames trigger the observer; ignore them
1794
+ const m =/^([+-]?)([\d,]+(?:\.\d+)?)(.*)$/.exec(b.textContent.trim()); if (!m || b.dataset.counted === b.textContent) return;
1795
+ const to = Number(m[2].replace(/,/g, '')), dec = (m[2].split('.')[1] || '').length, sign = m[1], tail = m[3];
1796
+ if (!isFinite(to) || reduce) { b.dataset.counted = b.textContent; return; }
1797
+ const t0 = performance.now(), d = 1100;
1798
+ const fmt = (v) => sign + v.toLocaleString('en-US', { minimumFractionDigits: dec, maximumFractionDigits: dec }) + tail;
1799
+ const final = fmt(to);
1800
+ const step = (t) => { const k = Math.min(1, (t - t0) / d), e = 1 - Math.pow(1 - k, 3); b.textContent = fmt(to * e); if (k < 1) requestAnimationFrame(step); else { b.textContent = final; b.dataset.counted = final; delete b.dataset.anim; } };
1801
+ b.dataset.counted = final; b.dataset.anim = '1'; requestAnimationFrame(step);
1802
+ };
1803
+ let pending = false;
1804
+ new MutationObserver(() => { if (pending) return; pending = true; requestAnimationFrame(() => { pending = false; wire(document); shimmer(); document.querySelectorAll('.kpi b, .ov-kpi b').forEach(countUp); }); }).observe(document.querySelector('main'), { childList: true, subtree: true, characterData: true });
1805
+ shimmer();
1806
+ // Page-wide drifting points behind the panels.
1807
+ if (window.OculonFX) {
1808
+ const lq = document.createElement('canvas'); lq.id = 'liquidbg'; lq.setAttribute('aria-hidden', 'true'); document.body.prepend(lq);
1809
+ OculonFX.liquid(lq, { base: '#000000', mid: '#001a26', hi: '#00c8e0', intensity: 0.85, scale: 0.3 });
1810
+
1811
+ }
1812
+ const c = document.createElement('canvas'); c.id = 'bgfx'; c.setAttribute('aria-hidden', 'true'); document.body.prepend(c);
1813
+ if (reduce) return;
1814
+ const x = c.getContext('2d'); let W, H, pts;
1815
+ const size = () => { W = c.width = innerWidth; H = c.height = innerHeight; pts = Array.from({ length: Math.round(W * H / 24000) }, () => ({ x: Math.random() * W, y: Math.random() * H, vx: (Math.random() - .5) * .2, vy: (Math.random() - .5) * .2, r: Math.random() * 1.2 + .3 })); };
1816
+ size(); addEventListener('resize', size);
1817
+ const frame = () => {
1818
+ const light = document.documentElement.dataset.theme === 'light';
1819
+ x.clearRect(0, 0, W, H);
1820
+ for (const p of pts) { p.x = (p.x + p.vx + W) % W; p.y = (p.y + p.vy + H) % H; x.fillStyle = light ? 'rgba(0,0,0,.25)' : 'rgba(255,255,255,.35)'; x.beginPath(); x.arc(p.x, p.y, p.r, 0, 7); x.fill(); }
1821
+ for (let i = 0; i < pts.length; i++) for (let j = i + 1; j < pts.length; j++) { const a = pts[i], b = pts[j], d = Math.hypot(a.x - b.x, a.y - b.y); if (d < 120) { x.strokeStyle = light ? `rgba(0,0,0,${(1 - d / 120) * .08})` : `rgba(0,240,255,${(1 - d / 120) * .08})`; x.beginPath(); x.moveTo(a.x, a.y); x.lineTo(b.x, b.y); x.stroke(); } }
1822
+ requestAnimationFrame(frame);
1823
+ };
1824
+ frame();
1825
+ })();
1826
+ </script>
1827
+ </body>
1828
+ </html>