{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"aura-dial","type":"registry:component","title":"Aura Dial","description":"A 40px hexagon of the viewer's own six values (contrast, warmth, light, density, motion, focus) that opens into an instrument: pull a corner and every Ultra asset on the page retunes live.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/aura-dial.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, PointerEvent as ReactPointerEvent } from \"react\";\n\n/**\n * AuraDial — your six values as one shape: a hexagon you pull, and the page re-forms under your hand.\n *\n * Closed, it is a 40px glyph: a hexagon whose corners sit at your contrast,\n * warmth, light, density, motion and focus. A hollow corner follows your\n * system and the time of day; a filled one is a value you set. Click it\n * (or press U) and it opens in place into an instrument: drag any corner\n * along its rail and every Ultra asset on the page retunes as you move,\n * with soft detents at the quarters. The light rail is hatched where no\n * text can be read, and a corner released there settles to the nearer\n * safe edge. Double-click a corner (or Backspace) to hand it back to the\n * system. Copy setup puts your values in a link (#u=...), read once by any\n * Ultra page. Use useUltra(), ultraTokens() and ultraVars() to make your own\n * components follow the same tuning.\n *\n * Part of the Ultra kit: an adaptive style whose grammar is the viewer. Every\n * Ultra asset reads six live values (contrast, warmth, light, density, motion,\n * focus) from one shared tuning and re-forms its tone, edges, density and\n * tempo to match: move any Ultra control and every Ultra asset on the page\n * follows. Values the viewer sets are saved on the device (localStorage\n * key ultra:v1); the rest follow the system (prefers-contrast,\n * prefers-reduced-motion, prefers-color-scheme) and the time of day. Nothing\n * is sent anywhere. Every colour is solved for APCA contrast at runtime, so no\n * tuning can make text illegible. Springs are critically damped (no\n * overshoot) and motion 0 swaps states. Type through var(--font-ultra)\n * (Google Sans Flex, whose GRAD and ROND axes follow contrast) over Geist.\n * Paste it as its own file: it carries its own copy of the small engine, and\n * copies on one page share a single store through Symbol.for.\n */\n\n/** The six values every Ultra asset reads. Each runs 0..1. */\nexport type UAxis = \"contrast\" | \"warmth\" | \"density\" | \"motion\" | \"focus\" | \"light\";\n\nexport type UAxes = Record<UAxis, number>;\n\n/** Dial order, clockwise from the top. */\nconst U_AXES: UAxis[] = [\"contrast\", \"warmth\", \"light\", \"density\", \"motion\", \"focus\"];\n\n/** Pole names, so a value can be read aloud (\"Contrast: crisp, 72%\"). */\nconst U_POLES: Record<UAxis, [string, string]> = {\n  contrast: [\"soft\", \"crisp\"],\n  warmth: [\"cool\", \"warm\"],\n  light: [\"dark\", \"paper\"],\n  density: [\"airy\", \"dense\"],\n  motion: [\"still\", \"lively\"],\n  focus: [\"wide\", \"narrow\"],\n};\n\n/** What the server renders and what an asset shows before the store boots. */\nconst U_DEFAULTS: UAxes = { contrast: 0.45, warmth: 0.3, light: 0.1, density: 0.4, motion: 0.45, focus: 0.35 };\n\n/** The exposure band no text can sit on (ground L 0.46..0.66): light snaps out of it. */\nconst U_LIGHT_GAP: [number, number] = [0.46, 0.54];\n\nconst uClamp = (v: number, a = 0, b = 1) => (v < a ? a : v > b ? b : v);\n\nconst uLerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\nconst uSmooth = (a: number, b: number, x: number) => {\n  const t = uClamp((x - a) / (b - a));\n  return t * t * (3 - 2 * t);\n};\n\n/** Nearest safe exposure: anything inside the unsafe band goes to its closer edge. */\nfunction uSafeLight(v: number): number {\n  const [a, b] = U_LIGHT_GAP;\n  if (v <= a || v >= b) return uClamp(v);\n  return v - a < b - v ? a : b;\n}\n\ninterface UStore {\n  v: 1;\n  /** The values the viewer pinned (dragged). Only these are saved. */\n  pinned: Partial<UAxes>;\n  /** Values derived from the system (prefers-*) and the clock. */\n  auto: UAxes;\n  /** Which auto values the system decided (those beat an author's seed). */\n  sys: { contrast: boolean; motion: boolean };\n  /** The author's starting look for values the viewer has not set. */\n  seed: Partial<UAxes>;\n  /** pinned over auto: what assets read. A new object on every change. */\n  snap: UAxes;\n  listeners: Set<() => void>;\n  booted: boolean;\n  /** The one goal on screen: the first claimant wins the filled accent. */\n  goals: string[];\n  /** Shared pointer, for gaze-driven assets. Written by one passive listener. */\n  gaze: { x: number; y: number; speed: number; t: number; live: boolean };\n}\n\nconst U_KEY = \"ultra:v1\";\n\nfunction uStore(): UStore {\n  const g = globalThis as unknown as Record<symbol, UStore | undefined>;\n  const sym = Symbol.for(\"viberdy.ultra.v1\");\n  let s = g[sym];\n  if (!s) {\n    s = {\n      v: 1,\n      pinned: {},\n      auto: { ...U_DEFAULTS },\n      sys: { contrast: false, motion: false },\n      seed: {},\n      snap: { ...U_DEFAULTS },\n      listeners: new Set(),\n      booted: false,\n      goals: [],\n      gaze: { x: -1, y: -1, speed: 0, t: 0, live: false },\n    };\n    g[sym] = s;\n  }\n  return s;\n}\n\nfunction uEmit(s: UStore) {\n  const seed = { ...s.seed };\n  if (s.sys.contrast) delete seed.contrast;\n  if (s.sys.motion) delete seed.motion;\n  s.snap = { ...s.auto, ...seed, ...s.pinned };\n  s.snap.light = uSafeLight(s.snap.light);\n  s.listeners.forEach((fn) => fn());\n}\n\nfunction uMedia(q: string): boolean {\n  return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" && window.matchMedia(q).matches;\n}\n\n/** Auto values: system preferences first, then the clock (read at boot and when the tab returns, never on a timer). */\nfunction uAuto(): UAxes {\n  const a: UAxes = { ...U_DEFAULTS };\n  if (uMedia(\"(prefers-contrast: more)\")) a.contrast = 0.95;\n  else if (uMedia(\"(prefers-contrast: less)\")) a.contrast = 0.12;\n  if (uMedia(\"(prefers-reduced-motion: reduce)\")) a.motion = 0;\n  if (uMedia(\"(pointer: coarse)\")) a.density = 0.25;\n  const h = new Date().getHours() + new Date().getMinutes() / 60;\n  // Warmth rises through the evening and lowers the light with it: a warm tint alone\n  // does not cut the evening's short-wave load, dimming does (RPI LRC, 2018).\n  const evening = h >= 17 ? uSmooth(17, 21, h) : h < 8 ? 1 - uSmooth(6, 8, h) : 0;\n  a.warmth = uLerp(0.3, 0.82, evening);\n  const paper = uMedia(\"(prefers-color-scheme: light)\");\n  a.light = paper ? uLerp(0.86, 0.7, evening) : uLerp(0.12, 0.04, evening);\n  return a;\n}\n\nfunction uLoad(): Partial<UAxes> {\n  try {\n    const raw = window.localStorage.getItem(U_KEY);\n    if (!raw) return {};\n    const data = JSON.parse(raw) as { v?: number; p?: Record<string, unknown> };\n    if (data.v !== 1 || !data.p) return {};\n    const out: Partial<UAxes> = {};\n    for (const k of U_AXES) {\n      const v = data.p[k];\n      if (typeof v === \"number\" && Number.isFinite(v)) out[k] = uClamp(v);\n    }\n    return out;\n  } catch {\n    return {};\n  }\n}\n\nfunction uSave(s: UStore) {\n  try {\n    window.localStorage.setItem(U_KEY, JSON.stringify({ v: 1, p: s.pinned }));\n  } catch {\n    // storage blocked: the tuning still works for this visit\n  }\n}\n\nfunction uSys(s: UStore) {\n  s.sys = {\n    contrast: uMedia(\"(prefers-contrast: more)\") || uMedia(\"(prefers-contrast: less)\"),\n    motion: uMedia(\"(prefers-reduced-motion: reduce)\"),\n  };\n}\n\nfunction uBoot() {\n  const s = uStore();\n  if (s.booted || typeof window === \"undefined\") return;\n  s.booted = true;\n  s.auto = uAuto();\n  uSys(s);\n  s.pinned = uLoad();\n  // A shared setup (#u=c7w3l2...: one letter per value and a base-36 digit) is read once.\n  const shared = /[#&]u=([a-z0-9]{2,12})/i.exec(window.location.hash);\n  if (shared && shared[1]) {\n    const code = shared[1].toLowerCase();\n    for (let i = 0; i + 1 < code.length; i += 2) {\n      const axis = U_AXES.find((k) => k[0] === code[i]);\n      const v = parseInt(code[i + 1] ?? \"\", 36);\n      if (axis && Number.isFinite(v)) s.pinned[axis] = uClamp(v / 35);\n    }\n    uSave(s);\n  }\n  uEmit(s);\n  const refresh = () => {\n    s.auto = uAuto();\n    uSys(s);\n    uEmit(s);\n  };\n  for (const q of [\"(prefers-contrast: more)\", \"(prefers-contrast: less)\", \"(prefers-reduced-motion: reduce)\", \"(prefers-color-scheme: light)\"]) {\n    window.matchMedia(q).addEventListener(\"change\", refresh);\n  }\n  document.addEventListener(\"visibilitychange\", () => {\n    if (document.visibilityState === \"visible\") refresh();\n  });\n  window.addEventListener(\"storage\", (e) => {\n    if (e.key !== U_KEY) return;\n    s.pinned = uLoad();\n    uEmit(s);\n  });\n  const gz = s.gaze;\n  window.addEventListener(\n    \"pointermove\",\n    (e) => {\n      const dt = Math.max(1, e.timeStamp - gz.t);\n      const d = gz.live ? Math.hypot(e.clientX - gz.x, e.clientY - gz.y) : 0;\n      gz.speed = gz.speed * 0.7 + ((d / dt) * 1000) * 0.3;\n      gz.x = e.clientX;\n      gz.y = e.clientY;\n      gz.t = e.timeStamp;\n      gz.live = true;\n    },\n    { passive: true },\n  );\n  document.documentElement.addEventListener(\"pointerleave\", () => {\n    gz.live = false;\n  });\n}\n\n/** Pin a value (the viewer chose it; it is saved), or pass null to hand it back to auto. */\nexport function setUltra(axis: UAxis, value: number | null) {\n  const s = uStore();\n  if (value === null) delete s.pinned[axis];\n  else s.pinned[axis] = axis === \"light\" ? uClamp(value) : uClamp(value);\n  uSave(s);\n  uEmit(s);\n}\n\n/**\n * The author's starting look for values the viewer has not set (they win\n * over the clock, never over a system preference for reduced motion or more\n * contrast, and never over the viewer). Not saved.\n */\nexport function seedUltra(values: Partial<UAxes>) {\n  const s = uStore();\n  const next: Partial<UAxes> = { ...s.seed };\n  let changed = false;\n  for (const k of U_AXES) {\n    const v = values[k];\n    if (typeof v === \"number\" && Number.isFinite(v) && next[k] !== uClamp(v)) {\n      next[k] = uClamp(v);\n      changed = true;\n    }\n  }\n  if (!changed) return;\n  s.seed = next;\n  uEmit(s);\n}\n\n/** Forget every pinned value. */\nexport function resetUltra() {\n  const s = uStore();\n  s.pinned = {};\n  uSave(s);\n  uEmit(s);\n}\n\nfunction uSubscribe(fn: () => void) {\n  const s = uStore();\n  s.listeners.add(fn);\n  uBoot();\n  return () => {\n    s.listeners.delete(fn);\n  };\n}\n\nconst uSnap = () => uStore().snap;\n\nconst uServerSnap = () => U_DEFAULTS;\n\n/**\n * The tuning, live. `tune` pins values for this instance only (a demo, a\n * fixed brand moment); they are never saved. `bounds` lets an author limit\n * the expressive direction only: motion, density and focus can be capped,\n * contrast can be floored, warmth and light can be ranged. The way back to\n * calm (motion 0, contrast 1, density 0, focus 0) can never be bounded.\n * `seed` is the author's starting look (see seedUltra).\n */\nexport function useUltra(tune?: Partial<UAxes>, bounds?: Partial<Record<UAxis, [number, number]>>, seed?: Partial<UAxes>): UAxes {\n  const snap = useSyncExternalStore(uSubscribe, uSnap, uServerSnap);\n  const seedKey = JSON.stringify(seed ?? null);\n  useLayoutEffect(() => {\n    const v = JSON.parse(seedKey) as Partial<UAxes> | null;\n    if (v) seedUltra(v);\n  }, [seedKey]);\n  // Compared by value, so inline objects do not churn.\n  const tuneKey = JSON.stringify(tune ?? null);\n  const boundsKey = JSON.stringify(bounds ?? null);\n  return useMemo(() => {\n    const tune = JSON.parse(tuneKey) as Partial<UAxes> | null;\n    const bounds = JSON.parse(boundsKey) as Partial<Record<UAxis, [number, number]>> | null;\n    const out: UAxes = { ...snap };\n    if (tune) {\n      for (const k of U_AXES) {\n        const v = tune[k];\n        if (typeof v === \"number\" && Number.isFinite(v)) out[k] = uClamp(v);\n      }\n    }\n    if (bounds) {\n      for (const k of U_AXES) {\n        const b = bounds[k];\n        if (!b) continue;\n        let [lo, hi] = b;\n        if (k === \"motion\" || k === \"density\" || k === \"focus\") lo = 0;\n        if (k === \"contrast\") hi = 1;\n        out[k] = uClamp(out[k], Math.min(lo, hi), Math.max(lo, hi));\n      }\n    }\n    out.light = uSafeLight(out.light);\n    return out;\n  }, [snap, tuneKey, boundsKey]);\n}\n\ntype URgb = [number, number, number];\n\nfunction uOklab(L: number, a: number, b: number): URgb {\n  const l_ = L + 0.3963377774 * a + 0.2158037573 * b;\n  const m_ = L - 0.1055613458 * a - 0.0638541728 * b;\n  const s_ = L - 0.0894841775 * a - 1.291485548 * b;\n  const l = l_ * l_ * l_;\n  const m = m_ * m_ * m_;\n  const s = s_ * s_ * s_;\n  const lin: URgb = [\n    4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n    -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n    -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,\n  ];\n  return lin.map((x) => {\n    const v = uClamp(x);\n    return Math.round((v <= 0.0031308 ? 12.92 * v : 1.055 * Math.pow(v, 1 / 2.4) - 0.055) * 255);\n  }) as URgb;\n}\n\nfunction uOklch(L: number, C: number, h: number): URgb {\n  const r = (h * Math.PI) / 180;\n  return uOklab(L, C * Math.cos(r), C * Math.sin(r));\n}\n\nconst uHex = (c: URgb) => \"#\" + c.map((v) => v.toString(16).padStart(2, \"0\")).join(\"\");\n\nfunction uY(c: URgb): number {\n  return 0.2126729 * Math.pow(c[0] / 255, 2.4) + 0.7151522 * Math.pow(c[1] / 255, 2.4) + 0.072175 * Math.pow(c[2] / 255, 2.4);\n}\n\n/** APCA-W3 0.0.98G lightness contrast (signed: negative = light text on dark). */\nfunction uApca(text: URgb, bg: URgb): number {\n  let yt = uY(text);\n  let yb = uY(bg);\n  if (yt < 0.022) yt += Math.pow(0.022 - yt, 1.414);\n  if (yb < 0.022) yb += Math.pow(0.022 - yb, 1.414);\n  if (Math.abs(yb - yt) < 0.0005) return 0;\n  if (yb > yt) {\n    const s = (Math.pow(yb, 0.56) - Math.pow(yt, 0.57)) * 1.14;\n    return s < 0.1 ? 0 : (s - 0.027) * 100;\n  }\n  const s = (Math.pow(yb, 0.65) - Math.pow(yt, 0.62)) * 1.14;\n  return s > -0.1 ? 0 : (s + 0.027) * 100;\n}\n\n/** The warmth tint: a straight line in OKLab from slate to amber, neutral at 0.5 (never a hue walk through green). */\nfunction uTint(w: number, mag: number): [number, number] {\n  return [uLerp(-0.0048, 0.0055, w) * mag, uLerp(-0.0132, 0.015, w) * mag];\n}\n\nfunction uCol(L: number, w: number, mag: number): URgb {\n  const [a, b] = uTint(w, mag);\n  return uOklab(L, a, b);\n}\n\n/** Find the ink lightness that reaches |Lc| = target on this ground (bisection, 24 steps). */\nfunction uSolve(bg: URgb, target: number, dark: boolean, w: number): URgb {\n  let lo = 0.02;\n  let hi = 0.995;\n  for (let i = 0; i < 24; i++) {\n    const m = (lo + hi) / 2;\n    const lc = Math.abs(uApca(uCol(m, w, 0.6), bg));\n    if (dark) {\n      if (lc < target) lo = m;\n      else hi = m;\n    } else if (lc < target) hi = m;\n    else lo = m;\n  }\n  return uCol((lo + hi) / 2, w, 0.6);\n}\n\n/** The accent's hue: a calm, low-chroma blue-violet, clear of every other kit's saturated blue. */\nconst U_HUE = 262;\n\nexport interface UTokens {\n  dark: boolean;\n  /** Ground lightness (OKLab L), for shaders. */\n  groundL: number;\n  ground: string;\n  s1: string;\n  s2: string;\n  well: string;\n  ink1: string;\n  ink2: string;\n  ink3: string;\n  hair: string;\n  /** Hairline alpha: edges only appear as contrast rises past 0.55. */\n  edge: number;\n  acc: string;\n  onAcc: string;\n  /** 4px base unit, scaled by density. */\n  unit: number;\n  body: number;\n  lh: number;\n  /** Critically damped spring stiffness; 0 means no motion (swap states). */\n  k: number;\n  /** The gaze aperture in px, from focus. */\n  aperture: number;\n  grad: number;\n  rond: number;\n  /** Ground and ink as linear-ish triples (0..1 sRGB) for canvases and shaders. */\n  groundRgb: URgb;\n  inkRgb: URgb;\n  accRgb: URgb;\n}\n\nconst uTokenCache = new Map<string, UTokens>();\n\n/** Every colour, size and tempo an Ultra asset uses, derived from the six values. No asset holds a fixed hex. */\nexport function ultraTokens(x: UAxes, hue = U_HUE): UTokens {\n  const q = (v: number) => Math.round(v * 200) / 200;\n  const key = [x.contrast, x.warmth, x.light, x.density, x.motion, x.focus].map(q).join(\",\") + \":\" + hue;\n  const hit = uTokenCache.get(key);\n  if (hit) return hit;\n  const c = q(x.contrast);\n  const w = q(x.warmth);\n  const lt = uSafeLight(q(x.light));\n  const d = q(x.density);\n  const m = q(x.motion);\n  const f = q(x.focus);\n  const dark = lt < 0.5;\n  // Exposure moves the ground within its room; contrast deepens it a little.\n  const gL = dark\n    ? uLerp(0.15, 0.3, lt / U_LIGHT_GAP[0]) - 0.03 * (c - 0.45)\n    : uLerp(0.89, 0.975, (lt - U_LIGHT_GAP[1]) / (1 - U_LIGHT_GAP[1])) + 0.012 * (c - 0.45);\n  const step = dark ? uLerp(0.03, 0.05, c) : uLerp(0.022, 0.04, c);\n  const g = uCol(gL, w, 1);\n  const s1 = uCol(dark ? gL + step : Math.min(0.995, gL + step * 0.7), w, dark ? 1 : 0.6);\n  const s2 = uCol(dark ? gL + step * 2 : Math.min(0.998, gL + step * 1.2), w, dark ? 1 : 0.5);\n  const well = uCol(gL - step * 0.8, w, 1);\n  const ink1 = uSolve(g, uLerp(75, 95, c), dark, w);\n  const ink2 = uSolve(g, uLerp(60, 72, c), dark, w);\n  const ink3 = uSolve(g, uLerp(52, 60, c), dark, w);\n  const hair = uSolve(g, uLerp(30, 45, c), dark, w);\n  const acc = dark ? uOklch(uLerp(0.84, 0.88, c), 0.09, hue) : uOklch(uLerp(0.5, 0.44, c), 0.14, hue);\n  // A label on the fill: solved, never pure black or white.\n  const onAcc = uSolve(acc, dark ? 70 : 78, !dark, w);\n  const t: UTokens = {\n    dark,\n    groundL: gL,\n    ground: uHex(g),\n    s1: uHex(s1),\n    s2: uHex(s2),\n    well: uHex(well),\n    ink1: uHex(ink1),\n    ink2: uHex(ink2),\n    ink3: uHex(ink3),\n    hair: uHex(hair),\n    edge: uClamp((c - 0.55) / 0.45),\n    acc: uHex(acc),\n    onAcc: uHex(onAcc),\n    unit: 4 * uLerp(1.18, 0.82, d),\n    body: uLerp(17, 15, d),\n    lh: uLerp(1.62, 1.45, d),\n    k: m < 0.02 ? 0 : uLerp(190, 560, m),\n    aperture: uLerp(560, 170, f),\n    grad: dark ? uLerp(40, 0, c) : uLerp(70, 30, c),\n    rond: uLerp(45, 8, c),\n    groundRgb: g,\n    inkRgb: ink1,\n    accRgb: acc,\n  };\n  uTokenCache.set(key, t);\n  return t;\n}\n\n/** The tokens as CSS custom properties on an asset root. Children read var(--u-*). */\nexport function ultraVars(t: UTokens): CSSProperties {\n  return {\n    \"--u-ground\": t.ground,\n    \"--u-s1\": t.s1,\n    \"--u-s2\": t.s2,\n    \"--u-well\": t.well,\n    \"--u-ink1\": t.ink1,\n    \"--u-ink2\": t.ink2,\n    \"--u-ink3\": t.ink3,\n    \"--u-hair\": t.hair,\n    \"--u-edge\": String(t.edge),\n    \"--u-acc\": t.acc,\n    \"--u-on-acc\": t.onAcc,\n    \"--u-unit\": t.unit.toFixed(2) + \"px\",\n    \"--u-body\": t.body.toFixed(2) + \"px\",\n    \"--u-lh\": t.lh.toFixed(3),\n    // Signature layer: one tempo (0ms at motion 0), the shadow and glow colours, the caught-light edge.\n    \"--u-dur\": (t.k ? Math.round(uLerp(980, 520, (t.k - 190) / 370)) : 0) + \"ms\",\n    \"--u-shade\": t.dark ? \"rgba(0,0,0,.5)\" : \"rgba(28,32,52,.14)\",\n    \"--u-glow\": \"color-mix(in oklab, \" + t.acc + \" \" + (t.dark ? 55 : 42) + \"%, transparent)\",\n    \"--u-lit\": t.dark ? \"rgba(255,255,255,.075)\" : \"rgba(255,255,255,.92)\",\n    colorScheme: t.dark ? \"dark\" : \"light\",\n    color: t.ink1,\n    fontFamily: 'var(--font-ultra, \"Google Sans Flex\", \"Geist\", ui-sans-serif, system-ui, sans-serif)',\n    fontVariationSettings: '\"GRAD\" ' + t.grad.toFixed(0) + ', \"ROND\" ' + t.rond.toFixed(0),\n  } as CSSProperties;\n}\n\n/**\n * The kit's signature layer, shared by every Ultra asset and timed by --u-dur\n * (the viewer's motion value; 0ms at motion 0 and under reduced motion, so\n * every entrance lands at once):\n *   .u-rise   a blur-and-rise entrance, staggered by --u-i\n *   .u-draw   a stroke that draws itself in (set pathLength=\"1\")\n *   .u-glass  a lifted surface: tinted gradient, caught-light top edge, soft shadow\n *   .u-lamp   a light and a lit edge that follow the pointer (--mx/--my, set on pointermove)\n *   .u-cta    the page's one goal: an accent glow, a lift and a sheen on hover\n */\nconst U_FX =\n  \"@keyframes u-rise{from{opacity:0;transform:translateY(.55em);filter:blur(6px)}}\" +\n  \"@keyframes u-draw{from{stroke-dashoffset:1}}\" +\n  \"@keyframes u-sheen{from{transform:translateX(-130%) skewX(-18deg)}to{transform:translateX(330%) skewX(-18deg)}}\" +\n  \"@keyframes u-spin{to{transform:rotate(1turn)}}\" +\n  \".u-scope .u-rise{animation:u-rise var(--u-dur) cubic-bezier(.16,1,.3,1) both;animation-delay:calc(var(--u-i,0) * var(--u-dur) * .09)}\" +\n  \".u-scope .u-draw{stroke-dasharray:1;stroke-dashoffset:0;animation:u-draw calc(var(--u-dur) * 2) cubic-bezier(.65,0,.35,1) both;animation-delay:calc(var(--u-i,0) * var(--u-dur) * .05)}\" +\n  \".u-scope .u-glass{background:linear-gradient(180deg,var(--u-s2),var(--u-s1) 62%);box-shadow:inset 0 1px 0 var(--u-lit),inset 0 0 0 1px color-mix(in oklab,var(--u-hair) calc(16% + var(--u-edge) * 60%),transparent),0 1px 2px var(--u-shade),0 30px 64px -34px var(--u-shade)}\" +\n  \".u-scope .u-lamp{position:relative;isolation:isolate}\" +\n  \".u-scope .u-lamp::before,.u-scope .u-lamp::after{content:'';position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity calc(var(--u-dur) * .5)}\" +\n  \".u-scope .u-lamp::before{z-index:-1;background:radial-gradient(var(--u-lamp-r,240px) circle at var(--mx,50%) var(--my,50%),color-mix(in oklab,var(--u-acc) 13%,transparent),transparent 70%)}\" +\n  \".u-scope .u-lamp::after{padding:1px;background:radial-gradient(180px circle at var(--mx,50%) var(--my,50%),color-mix(in oklab,var(--u-acc) 85%,transparent),transparent 70%);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude}\" +\n  \".u-scope .u-lamp:hover::before,.u-scope .u-lamp:hover::after{opacity:1}\" +\n  \".u-scope .u-cta{position:relative;overflow:hidden;isolation:isolate;box-shadow:inset 0 1px 0 rgba(255,255,255,.4),0 0 0 1px color-mix(in oklab,var(--u-acc) 80%,transparent),0 10px 28px -10px var(--u-glow);transition:transform calc(var(--u-dur) * .45) cubic-bezier(.16,1,.3,1),box-shadow calc(var(--u-dur) * .45)}\" +\n  \".u-scope .u-cta:hover{transform:translateY(-1px);box-shadow:inset 0 1px 0 rgba(255,255,255,.4),0 0 0 1px var(--u-acc),0 16px 40px -10px var(--u-glow)}\" +\n  \".u-scope .u-cta:active{transform:translateY(0) scale(.98)}\" +\n  \".u-scope .u-cta::after{content:'';position:absolute;inset:0 auto 0 0;width:42%;pointer-events:none;background:linear-gradient(90deg,transparent,rgba(255,255,255,.5),transparent);transform:translateX(-130%) skewX(-18deg)}\" +\n  \".u-scope .u-cta:hover::after{animation:u-sheen calc(var(--u-dur) * 1.3) cubic-bezier(.16,1,.3,1)}\" +\n  \".u-scope .u-arr{transition:transform calc(var(--u-dur) * .45) cubic-bezier(.16,1,.3,1)}.u-scope .u-cta:hover .u-arr{transform:translateX(3px)}\" +\n  \"@media (prefers-reduced-motion:reduce){.u-scope .u-rise,.u-scope .u-draw,.u-scope .u-cta::after{animation:none!important}.u-scope .u-cta{transition:none}}\";\n\n/**\n * The kit's scoped CSS: the one focus ring (the accent, 2px, offset 3px, the\n * element's own radius), tabular figures, and transitions off for elements a\n * frame loop writes. Rendered once per asset; identical text dedupes in React 19.\n */\nconst U_CSS =\n  \".u-scope :focus-visible{outline:2px solid var(--u-acc)!important;outline-offset:3px!important;border-radius:revert-layer!important}\" +\n  \".u-scope .u-num{font-variant-numeric:tabular-nums}\" +\n  \".u-scope [data-u-live]{transition:none!important}\" +\n  U_FX;\n\nconst AD_NAMES: Record<UAxis, string> = {\n  contrast: \"Contrast\",\n  warmth: \"Warmth\",\n  light: \"Light\",\n  density: \"Density\",\n  motion: \"Motion\",\n  focus: \"Focus\",\n};\n\n/** Which values the viewer pinned, as a stable string (\"contrast,light\"); \"\" on the server. */\nfunction useUltraPinned(): Set<UAxis> {\n  const key = useSyncExternalStore(\n    uSubscribe,\n    () => U_AXES.filter((k) => typeof uStore().pinned[k] === \"number\").join(\",\"),\n    () => \"\",\n  );\n  return useMemo(() => new Set((key ? key.split(\",\") : []) as UAxis[]), [key]);\n}\n\n/** A point on axis i of a hexagon (clockwise from 12 o'clock), rounded so server and browser agree. */\nfunction adPoint(i: number, r: number, cx: number, cy: number): [number, number] {\n  const a = (-90 + i * 60) * (Math.PI / 180);\n  return [Math.round((cx + Math.cos(a) * r) * 100) / 100, Math.round((cy + Math.sin(a) * r) * 100) / 100];\n}\n\nfunction adWord(axis: UAxis, v: number) {\n  const [lo, hi] = U_POLES[axis];\n  return AD_NAMES[axis] + \": \" + (v < 0.5 ? lo : hi) + \", \" + Math.round(v * 100) + \" percent\";\n}\n\n/** The share code: one letter per value plus a base-36 digit (#u=c7w3l2d4m5f2). */\nfunction adCode(a: UAxes, pinned: Set<UAxis>) {\n  return U_AXES.filter((k) => pinned.has(k))\n    .map((k) => k[0] + Math.round(a[k] * 35).toString(36))\n    .join(\"\");\n}\n\n/**\n * The shape the dial draws: eased toward the tuning so a reset or a shared\n * link morphs the hexagon instead of jumping it. Under the hand (hold) and at\n * motion 0 it is the tuning itself.\n */\nfunction useAdEase(target: UAxes, k: number, hold: boolean): UAxes {\n  const [shown, setShown] = useState(target);\n  const live = useRef({ cur: target, target, k, hold });\n  const key = U_AXES.map((ax) => target[ax].toFixed(4)).join(\",\");\n  useEffect(() => {\n    live.current.target = target;\n    live.current.k = k;\n    live.current.hold = hold;\n  });\n  useEffect(() => {\n    const L = live.current;\n    let raf = 0;\n    let last = 0;\n    const step = (now: number) => {\n      const dt = last ? Math.min(0.05, (now - last) / 1000) : 1 / 60;\n      last = now;\n      const r = 1 - Math.exp((-dt * L.k) / 45);\n      const next = { ...L.cur };\n      let done = true;\n      for (const ax of U_AXES) {\n        const d = L.target[ax] - L.cur[ax];\n        if (L.hold || !L.k || Math.abs(d) < 0.002) next[ax] = L.target[ax];\n        else {\n          next[ax] = L.cur[ax] + d * r;\n          done = false;\n        }\n      }\n      L.cur = next;\n      setShown(next);\n      raf = done ? 0 : requestAnimationFrame(step);\n    };\n    raf = requestAnimationFrame(step);\n    return () => cancelAnimationFrame(raf);\n  }, [key, k, hold]);\n  return hold || !k ? target : shown;\n}\n\n/** The aura's three colours: the accent, an orchid, and a third that runs cool to amber with warmth. */\nfunction adHues(tk: UTokens, warmth: number): [string, string, string] {\n  const L = tk.dark ? 0.84 : 0.56;\n  return [tk.acc, uHex(uOklch(L, tk.dark ? 0.1 : 0.13, uLerp(305, 345, warmth))), uHex(uOklch(L, tk.dark ? 0.09 : 0.12, uLerp(215, 60, warmth)))];\n}\n\nconst AD_CSS =\n  \"@property --u-ad-a{syntax:'<angle>';inherits:false;initial-value:0deg}\" +\n  \"@keyframes u-ad-turn{to{--u-ad-a:1turn}}\" +\n  \"@keyframes u-ad-pulse{from{transform:scale(.7);opacity:.55}to{transform:scale(2.1);opacity:0}}\" +\n  \".u-ad-glyph{position:relative;transition:transform calc(var(--u-dur) * .45) cubic-bezier(.16,1,.3,1),opacity 160ms}\" +\n  \".u-ad-glyph:hover{transform:scale(1.06)}\" +\n  \".u-ad-glyph::before{content:'';position:absolute;inset:0;border-radius:inherit;padding:1.5px;pointer-events:none;background:conic-gradient(from var(--u-ad-a),var(--u-ad-1),var(--u-ad-2),var(--u-ad-3),var(--u-ad-1));-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude;animation:u-ad-turn calc(var(--u-dur) * 9) linear infinite}\" +\n  \".u-ad-halo{opacity:0;transition:opacity 200ms}\" +\n  \".u-ad-v:hover .u-ad-halo,.u-ad-v:focus-visible .u-ad-halo{opacity:.2}\" +\n  \".u-ad-v[data-grab] .u-ad-halo{opacity:.3}\" +\n  \".u-ad-pulse{transform-box:fill-box;transform-origin:center;animation:u-ad-pulse calc(var(--u-dur) * 1.8) cubic-bezier(.16,1,.3,1) infinite}\" +\n  \".u-ad-aura{animation:u-spin calc(var(--u-dur) * 24) linear infinite}\" +\n  \"@media (prefers-reduced-motion:reduce){.u-ad-glyph::before,.u-ad-pulse,.u-ad-aura{animation:none!important}}\";\n\nexport interface AuraDialProps {\n  /** inline sits in the flow; fixed pins it to a corner of the viewport. */\n  placement?: \"inline\" | \"fixed\";\n  corner?: \"br\" | \"bl\" | \"tr\" | \"tl\";\n  defaultOpen?: boolean;\n  /** Toggles the dial when no field is focused; null turns it off. */\n  hotkey?: string | null;\n  /** Leave out a value the page cannot change (for example light on a page with one polarity). */\n  axes?: UAxis[];\n  /** The closed glyph's size in px (the panel is 248). */\n  size?: number;\n  onChange?: (axes: UAxes) => void;\n  className?: string;\n}\n\n/**\n * AuraDial — your six values as one shape: a hexagon you pull, and the page re-forms under your hand.\n */\nexport function AuraDial({ placement = \"inline\", corner = \"br\", defaultOpen = false, hotkey = \"u\", axes: show = U_AXES, size = 40, onChange, className = \"\" }: AuraDialProps) {\n  const a = useUltra();\n  const tk = ultraTokens(a);\n  const pinned = useUltraPinned();\n  const [open, setOpen] = useState(defaultOpen);\n  const [grab, setGrab] = useState<UAxis | null>(null);\n  const [copied, setCopied] = useState(false);\n  const btnRef = useRef<HTMLButtonElement>(null);\n  const panelRef = useRef<HTMLDivElement>(null);\n  const svgRef = useRef<SVGSVGElement>(null);\n  const onChangeRef = useRef(onChange);\n  const id = useId().replace(/[^a-zA-Z0-9]/g, \"\");\n  const visible = U_AXES.filter((k) => show.includes(k));\n\n  useEffect(() => {\n    onChangeRef.current = onChange;\n  });\n\n  useEffect(() => {\n    if (!hotkey) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key.toLowerCase() !== hotkey.toLowerCase() || e.metaKey || e.ctrlKey || e.altKey || e.repeat) return;\n      const t = e.target as HTMLElement | null;\n      if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;\n      setOpen((o) => !o);\n    };\n    window.addEventListener(\"keydown\", onKey);\n    return () => window.removeEventListener(\"keydown\", onKey);\n  }, [hotkey]);\n\n  const write = (axis: UAxis, v: number | null) => {\n    setUltra(axis, v);\n    onChangeRef.current?.(uStore().snap);\n  };\n\n  // Panel geometry: a 248px plane, the hexagon centred in its top 228px.\n  const W = 248;\n  const CX = 124;\n  const CY = 118;\n  const R = 78;\n  const R0 = 14;\n  const rOf = (v: number) => R0 + (R - R0) * v;\n\n  const fromPointer = (axis: UAxis, clientX: number, clientY: number) => {\n    const svg = svgRef.current;\n    if (!svg) return 0;\n    const box = svg.getBoundingClientRect();\n    const k = box.width / W;\n    const x = (clientX - box.left) / k - CX;\n    const y = (clientY - box.top) / k - CY;\n    const i = U_AXES.indexOf(axis);\n    const ang = (-90 + i * 60) * (Math.PI / 180);\n    const along = x * Math.cos(ang) + y * Math.sin(ang);\n    let v = uClamp((along - R0) / (R - R0));\n    // Detents at quarters, 0.03 wide.\n    for (const d of [0, 0.25, 0.5, 0.75, 1]) if (Math.abs(v - d) < 0.03) v = d;\n    return v;\n  };\n\n  // The drag follows the pointer anywhere on the page until release (window listeners, so a\n  // release off the corner still ends it).\n  const onVertexDown = (axis: UAxis) => (e: ReactPointerEvent<SVGGElement>) => {\n    if (e.button !== 0) return;\n    e.preventDefault();\n    setGrab(axis);\n    if (e.pointerType === \"touch\" && typeof navigator.vibrate === \"function\") navigator.vibrate(4);\n    const pid = e.pointerId;\n    const move = (ev: PointerEvent) => {\n      if (ev.pointerId === pid) write(axis, fromPointer(axis, ev.clientX, ev.clientY));\n    };\n    const up = (ev: PointerEvent) => {\n      if (ev.pointerId !== pid) return;\n      window.removeEventListener(\"pointermove\", move);\n      window.removeEventListener(\"pointerup\", up);\n      window.removeEventListener(\"pointercancel\", up);\n      setGrab(null);\n      if (axis === \"light\") {\n        const raw = uStore().pinned.light;\n        if (typeof raw === \"number\") write(\"light\", uSafeLight(raw));\n      }\n    };\n    window.addEventListener(\"pointermove\", move);\n    window.addEventListener(\"pointerup\", up);\n    window.addEventListener(\"pointercancel\", up);\n  };\n  const onVertexKey = (axis: UAxis) => (e: ReactKeyboardEvent<SVGGElement>) => {\n    const step = e.shiftKey ? 0.2 : 0.05;\n    let v = a[axis];\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") v += step;\n    else if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") v -= step;\n    else if (e.key === \"Home\") v = 0;\n    else if (e.key === \"End\") v = 1;\n    else if (e.key === \"Backspace\" || e.key === \"Delete\") {\n      e.preventDefault();\n      write(axis, null);\n      return;\n    } else if (e.key === \"Escape\") {\n      setOpen(false);\n      btnRef.current?.focus();\n      return;\n    } else return;\n    e.preventDefault();\n    if (axis === \"light\") {\n      const up = v > a.light;\n      if (v > U_LIGHT_GAP[0] && v < U_LIGHT_GAP[1]) v = up ? U_LIGHT_GAP[1] : U_LIGHT_GAP[0];\n    }\n    write(axis, uClamp(v));\n  };\n\n  const copy = () => {\n    const url = location.origin + location.pathname + location.search + \"#u=\" + adCode(a, pinned);\n    navigator.clipboard?.writeText(url).then(\n      () => {\n        setCopied(true);\n        window.setTimeout(() => setCopied(false), 1600);\n      },\n      () => {},\n    );\n  };\n\n  const poly = (r: (i: number) => number, cx: number, cy: number) =>\n    U_AXES.map((_, i) => adPoint(i, r(i), cx, cy).join(\",\")).join(\" \");\n  const k = tk.k;\n  const v = useAdEase(a, k, grab !== null);\n  const [h1, h2, h3] = adHues(tk, a.warmth);\n  const morph = k ? \"transform 420ms cubic-bezier(.16,1,.3,1), opacity 260ms ease-out, filter 320ms ease-out\" : \"opacity 120ms linear\";\n  const gs = Math.max(28, Math.min(48, size * uLerp(1, 0.8, a.density)));\n  const gr = (x: number) => gs * (0.13 + 0.3 * x);\n  const fixedPos: CSSProperties =\n    placement === \"fixed\"\n      ? { position: \"fixed\", zIndex: 60, [corner[0] === \"b\" ? \"bottom\" : \"top\"]: 24, [corner[1] === \"r\" ? \"right\" : \"left\"]: 24 }\n      : {};\n  const origin = (corner[0] === \"b\" ? \"bottom\" : \"top\") + \" \" + (corner[1] === \"r\" ? \"right\" : \"left\");\n  // The aura behind the shape swells with how far the tuning reaches.\n  const reach = U_AXES.reduce((s, ax) => s + v[ax], 0) / 6;\n  const hues = { \"--u-ad-1\": h1, \"--u-ad-2\": h2, \"--u-ad-3\": h3 } as CSSProperties;\n  const grad = (gid: string) => (\n    <linearGradient id={gid} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\">\n      <stop offset=\"0\" stopColor={h1} />\n      <stop offset=\"0.55\" stopColor={h2} />\n      <stop offset=\"1\" stopColor={h3} />\n    </linearGradient>\n  );\n\n  return (\n    <div className={\"u-scope relative inline-block \" + className} style={{ ...ultraVars(tk), ...hues, ...fixedPos, width: gs, height: gs }}>\n      <style>{U_CSS + AD_CSS}</style>\n      <button\n        ref={btnRef}\n        type=\"button\"\n        aria-expanded={open}\n        aria-controls={\"ad\" + id}\n        aria-label=\"Your tuning: contrast, warmth, light, density, motion and focus\"\n        onClick={() => setOpen((o) => !o)}\n        className=\"u-ad-glyph grid h-full w-full cursor-pointer place-items-center rounded-[30%] p-0\"\n        style={{ background: tk.s1, border: 0, boxShadow: \"inset 0 1px 0 var(--u-lit), 0 8px 22px -10px var(--u-glow)\", opacity: open ? 0 : 1 }}\n      >\n        <svg width={gs} height={gs} viewBox={\"0 0 \" + gs + \" \" + gs} aria-hidden>\n          <defs>{grad(\"adgg\" + id)}</defs>\n          <polygon points={poly((i) => gr(v[U_AXES[i] as UAxis]), gs / 2, gs / 2)} fill={\"url(#adgg\" + id + \")\"} fillOpacity={0.4} stroke={\"url(#adgg\" + id + \")\"} strokeWidth={1.5} strokeLinejoin=\"round\" />\n          {U_AXES.map((ax, i) => {\n            const [x, y] = adPoint(i, gr(v[ax]), gs / 2, gs / 2);\n            return <circle key={ax} cx={x} cy={y} r={1.9} fill={pinned.has(ax) ? tk.ink1 : tk.s1} stroke={tk.ink1} strokeWidth={1.1} />;\n          })}\n        </svg>\n      </button>\n      <div\n        ref={panelRef}\n        id={\"ad\" + id}\n        role=\"dialog\"\n        aria-label=\"Your tuning\"\n        className=\"u-glass absolute overflow-hidden rounded-[28px]\"\n        style={{\n          width: W,\n          [corner[0] === \"b\" ? \"bottom\" : \"top\"]: 0,\n          [corner[1] === \"r\" ? \"right\" : \"left\"]: 0,\n          color: tk.ink1,\n          transformOrigin: origin,\n          transform: open ? \"scale(1)\" : \"scale(\" + (gs / W).toFixed(3) + \")\",\n          opacity: open ? 1 : 0,\n          filter: open || !k ? \"none\" : \"blur(10px)\",\n          pointerEvents: open ? \"auto\" : \"none\",\n          visibility: open ? \"visible\" : \"hidden\",\n          transition: morph + (open ? \"\" : \", visibility 0s linear 420ms\"),\n          zIndex: 2,\n        }}\n      >\n        {/* The aura: the dial's three colours turning slowly behind the shape. */}\n        <div\n          aria-hidden\n          className=\"pointer-events-none absolute\"\n          style={{ left: CX - 100, top: 48 + CY - 100, width: 200, height: 200, transform: \"scale(\" + (0.55 + 0.6 * reach).toFixed(3) + \")\", transition: k ? \"transform 600ms cubic-bezier(.16,1,.3,1)\" : undefined }}\n        >\n          <div className=\"u-ad-aura h-full w-full rounded-full\" style={{ background: \"conic-gradient(from 30deg, \" + h1 + \", \" + h2 + \", \" + h3 + \", \" + h1 + \")\", filter: \"blur(34px)\", opacity: tk.dark ? 0.3 : 0.38 }} />\n        </div>\n        <div className=\"relative flex items-center justify-between px-5 pt-4 text-[12.5px] font-medium\" style={{ color: tk.ink3 }}>\n          <span>Your tuning</span>\n          <button\n            type=\"button\"\n            onClick={() => {\n              setOpen(false);\n              btnRef.current?.focus();\n            }}\n            className=\"-mr-2 grid h-8 w-8 cursor-pointer place-items-center rounded-full\"\n            style={{ background: \"transparent\", border: 0, color: tk.ink2 }}\n            aria-label=\"Close\"\n          >\n            <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" aria-hidden>\n              <path d=\"M2 2l8 8M10 2l-8 8\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" />\n            </svg>\n          </button>\n        </div>\n        <svg ref={svgRef} width={W} height={228} viewBox={\"0 0 \" + W + \" 228\"} className=\"relative block touch-none select-none\">\n          <defs>\n            {grad(\"adg\" + id)}\n            <radialGradient id={\"adw\" + id}>\n              <stop offset=\"0\" stopColor={tk.ink1} stopOpacity={tk.dark ? 0.07 : 0.05} />\n              <stop offset=\"1\" stopColor={tk.ink1} stopOpacity={0} />\n            </radialGradient>\n            <filter id={\"adf\" + id} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n              <feGaussianBlur stdDeviation=\"7\" />\n            </filter>\n          </defs>\n          <polygon points={poly(() => R, CX, CY)} fill={\"url(#adw\" + id + \")\"} />\n          {[0.25, 0.5, 0.75, 1].map((t) => (\n            <polygon key={t} points={poly(() => rOf(t), CX, CY)} fill=\"none\" stroke={tk.hair} strokeOpacity={(t === 1 ? 0.45 : 0.22) + 0.35 * tk.edge} strokeWidth={1} strokeDasharray={t === 1 ? undefined : \"1.5 4\"} />\n          ))}\n          {U_AXES.map((ax, i) => {\n            const [x0, y0] = adPoint(i, R0, CX, CY);\n            const [x1, y1] = adPoint(i, R, CX, CY);\n            return <line key={ax} x1={x0} y1={y0} x2={x1} y2={y1} stroke={grab === ax ? h1 : tk.hair} strokeOpacity={grab === ax ? 0.9 : 0.4 + 0.4 * tk.edge} strokeWidth={grab === ax ? 1.5 : 1} />;\n          })}\n          {/* The band no text survives: the light rail is hatched there. */}\n          {(() => {\n            const i = U_AXES.indexOf(\"light\");\n            const [x0, y0] = adPoint(i, rOf(U_LIGHT_GAP[0]), CX, CY);\n            const [x1, y1] = adPoint(i, rOf(U_LIGHT_GAP[1]), CX, CY);\n            return <line x1={x0} y1={y0} x2={x1} y2={y1} stroke={tk.ink3} strokeWidth={5} strokeDasharray=\"1.5 1.5\" strokeOpacity={0.7} />;\n          })()}\n          {/* The shape, lit: a soft glow of itself underneath, a tinted fill, a gradient edge. */}\n          <polygon points={poly((i) => rOf(v[U_AXES[i] as UAxis]), CX, CY)} fill={\"url(#adg\" + id + \")\"} opacity={tk.dark ? 0.8 : 0.55} filter={\"url(#adf\" + id + \")\"} />\n          <polygon points={poly((i) => rOf(v[U_AXES[i] as UAxis]), CX, CY)} fill={\"url(#adg\" + id + \")\"} fillOpacity={tk.dark ? 0.3 : 0.28} stroke={\"url(#adg\" + id + \")\"} strokeWidth={1.75} strokeLinejoin=\"round\" />\n          {U_AXES.map((ax, i) => {\n            const [lx, ly] = adPoint(i, R + 20, CX, CY);\n            const quiet = grab !== null && grab !== ax;\n            return (\n              <text key={ax} x={lx} y={ly + 4} textAnchor=\"middle\" fontSize={11.5} fontWeight={grab === ax ? 600 : 500} fill={grab === ax ? tk.ink1 : tk.ink3} style={{ opacity: quiet ? 0.5 : 1, transition: k ? \"opacity 160ms\" : undefined }}>\n                {grab === ax ? U_POLES[ax][a[ax] < 0.5 ? 0 : 1] + \" \" + Math.round(a[ax] * 100) : AD_NAMES[ax]}\n              </text>\n            );\n          })}\n          {visible.map((ax) => {\n            const i = U_AXES.indexOf(ax);\n            const [x, y] = adPoint(i, rOf(v[ax]), CX, CY);\n            const on = pinned.has(ax);\n            const quiet = grab !== null && grab !== ax;\n            return (\n              <g\n                key={ax}\n                role=\"slider\"\n                tabIndex={open ? 0 : -1}\n                aria-label={AD_NAMES[ax]}\n                aria-valuemin={0}\n                aria-valuemax={100}\n                aria-valuenow={Math.round(a[ax] * 100)}\n                aria-valuetext={adWord(ax, a[ax]) + (on ? \"\" : \", following your system\")}\n                data-grab={grab === ax ? \"\" : undefined}\n                className=\"u-ad-v cursor-grab outline-none active:cursor-grabbing\"\n                style={{ opacity: quiet ? 0.45 : 1, transition: k ? \"opacity 160ms\" : undefined }}\n                onPointerDown={onVertexDown(ax)}\n                onDoubleClick={() => write(ax, null)}\n                onKeyDown={onVertexKey(ax)}\n              >\n                <circle cx={x} cy={y} r={14} fill=\"transparent\" />\n                <circle className=\"u-ad-halo\" cx={x} cy={y} r={13} fill={h1} />\n                {grab === ax && k ? <circle className=\"u-ad-pulse\" cx={x} cy={y} r={9} fill=\"none\" stroke={h1} strokeWidth={1.5} /> : null}\n                <circle cx={x} cy={y} r={grab === ax ? 7 : 5.5} fill={on ? tk.ink1 : tk.s1} stroke={tk.ink1} strokeWidth={1.5} style={{ transition: k ? \"r 160ms\" : undefined, filter: on ? \"drop-shadow(0 0 5px \" + h1 + \")\" : undefined }} />\n              </g>\n            );\n          })}\n        </svg>\n        <div className=\"relative flex items-center justify-between gap-2 whitespace-nowrap px-5 pb-4 text-[12px]\" style={{ color: tk.ink3 }}>\n          <span className=\"inline-flex items-center gap-1.5\">\n            <svg width=\"22\" height=\"8\" viewBox=\"0 0 22 8\" aria-hidden>\n              <circle cx=\"4\" cy=\"4\" r=\"3\" fill=\"none\" stroke={tk.ink3} strokeWidth=\"1.2\" />\n              <circle cx=\"16\" cy=\"4\" r=\"3\" fill={tk.ink3} />\n            </svg>\n            system / you\n          </span>\n          <span className=\"flex items-center gap-3\">\n            <button type=\"button\" onClick={copy} disabled={pinned.size === 0} className=\"cursor-pointer p-0 underline decoration-1 underline-offset-4 disabled:cursor-default disabled:no-underline disabled:opacity-50\" style={{ background: \"none\", border: 0, color: tk.ink2, font: \"inherit\" }}>\n              {copied ? \"Copied\" : \"Share\"}\n            </button>\n            <button type=\"button\" onClick={() => { resetUltra(); onChangeRef.current?.(uStore().snap); }} disabled={pinned.size === 0} className=\"cursor-pointer p-0 underline decoration-1 underline-offset-4 disabled:cursor-default disabled:no-underline disabled:opacity-50\" style={{ background: \"none\", border: 0, color: tk.ink2, font: \"inherit\" }}>\n              Reset\n            </button>\n          </span>\n        </div>\n      </div>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/aura-dial.tsx"}],"meta":{"tier":"free","tags":["personalization","theme","settings","accessibility","adaptive","svg","control","dark mode"],"href":"https://viberdy.dev/library/aura-dial","aiPrompt":"Add the Ultra \"AuraDial\" to this app: the viewer's personal tuning control. Closed it is a 40px glyph (a hexagon whose six corners are the viewer's contrast, warmth, light, density, motion and focus); opened, the viewer drags any corner along its rail and every Ultra asset on the page retunes live. Values the viewer sets are saved on the device (localStorage key ultra:v1); everything else follows the system preferences and the time of day.\n\nHow to use it:\n- Put one `<AuraDial placement=\"fixed\" corner=\"br\" />` in the root layout so it floats in a corner on every page, or `placement=\"inline\"` inside a toolbar. `hotkey` (default \"u\") toggles it when no field is focused; pass `null` to turn it off.\n- `axes` limits which corners are draggable (for example leave out \"light\" on a page that must stay dark).\n- Make your own components follow the same tuning: `const a = useUltra(); const t = ultraTokens(a);`, then use `t.ground`, `t.s1`/`t.s2` (raised surfaces), `t.ink1`/`t.ink2`/`t.ink3` (solved text colours), `t.hair` and `t.edge` (hairline colour and how visible edges should be), `t.acc`/`t.onAcc` (the one filled action), `t.unit` (4px base unit scaled by density), `t.body`/`t.lh` (body size and leading) and `t.k` (spring stiffness; 0 means no motion). Or spread `ultraVars(t)` on a root and use `var(--u-ink1)` and friends in CSS.\n- `setUltra(axis, value)` sets a value from your own UI, `setUltra(axis, null)` hands it back to the system, `resetUltra()` clears everything. `onChange` reports every change.\n\nRules to keep: never hard-code colours in an Ultra component (the tuning re-solves them for contrast), never use a filter or an opacity overlay to implement a tuning, keep one filled accent per view, and keep motion 0 meaning no animation at all. Load Google Sans Flex with next/font (`variable: \"--font-ultra\"`, axes GRAD and ROND) for the intended type.","license":"https://viberdy.dev/license"}}