// Lalaluxe — core/brand.jsx
// What the brand shows: the studio's logo, from its files, and the editorial nail & toe artwork.
// Loaded by booking.html and admin.html before their shared primitives; hues come from colors.css.

/* ---------- Logo: the one the studio picked, from its files ---------- */
// The logo the studio picked (Look → Logo), as the server wrote it on <html data-brand>. Each
// built-in logo is a set of files under images/brand/<id>/ — the wordmark for a light and a dark
// ground (the theme shows one), the app and tab icons.
// TWIN: lib/config/brand.js#BRANDS
const BRAND_LOGOS = {
	ransom: { name: "Ransom Note", logo: ["logo-day.webp", "logo-night.webp"] },
};
// The logo of a studio that never picked one (or whose pick is gone), and the one the page
// templates are written with.
// TWIN: lib/config/brand.js#DEFAULT_BRAND
// TWIN: lib/views/pages/booking.html#ransom
// TWIN: lib/views/pages/admin.html#ransom
const DEFAULT_BRAND = "ransom";
// A logo package the studio uploaded (Look → Logo) is "custom": its files are photos, which the
// server names on <html data-brand-files> (the console names them too, once it has the config).
// The names are the ones fileUrl in lib/config/brand.js serves: logo-day, logo-night, icon-192, …
let customLogo = null;
function customFiles() {
	if (customLogo) return customLogo;
	try { return JSON.parse((typeof document !== "undefined" && document.documentElement.dataset.brandFiles) || "null"); } catch { return null; }
}
const setCustomLogo = (files) => { customLogo = files || null; };
const knownBrand = (id) => (id === "custom" ? !!customFiles() : Object.hasOwn(BRAND_LOGOS, id || ""));
// Where one of a logo's files is served.
// TWIN: lib/config/brand.js#fileUrl
function brandUrl(id, file, files) {
	if (id === "custom") {
		const value = (files || customFiles() || {})[file] || "";
		return file === "email-logo" ? value : mediaUrl(value);
	}
	if (file === "og") return `/images/brand/${id}/og.jpg`;
	if (file === "logo-day" || file === "logo-night") return `/images/brand/${id}/${BRAND_LOGOS[id].logo[file === "logo-day" ? 0 : 1]}`;
	return `/images/brand/${id}/${file}.png`;
}
const brandNow = () => {
	const id = typeof document !== "undefined" && document.documentElement.dataset.brand;
	return id && knownBrand(id) ? id : DEFAULT_BRAND;
};
// Put a logo on the page now: the wordmarks redraw and the tab icon follows. An uploaded logo that
// was just replaced is put on again, so its new files show.
function setBrand(id) {
	if (!knownBrand(id) || (id === brandNow() && id !== "custom")) return;
	document.documentElement.dataset.brand = id;
	if (id === "custom") document.documentElement.dataset.brandFiles = JSON.stringify(customFiles());
	const icon = document.querySelector('link[rel="icon"]');
	if (icon) icon.setAttribute("href", brandUrl(id, location.pathname.startsWith("/admin") ? "console-32" : "favicon-32"));
	window.dispatchEvent(new CustomEvent("brandchange", { detail: id }));
}
function useBrand() {
	const [id, setId] = React.useState(brandNow);
	const [, redraw] = React.useState(0);
	React.useEffect(() => {
		const on = () => { setId(brandNow()); redraw((n) => n + 1); };
		window.addEventListener("brandchange", on);
		return () => window.removeEventListener("brandchange", on);
	}, []);
	return id;
}
// The wordmark from the logo's files, both grounds; the theme shows one. `brand` draws a logo other
// than the one on the page (the console's picker), and `files` an uploaded one not saved yet.
function Logo({ brand, files }) {
	const current = useBrand();
	const id = brand || current;
	return (
		<span className={`logo logo--art logo--${id}`} role="img" aria-label={STORE.name}>
			<img className="logo-day" src={brandUrl(id, "logo-day", files)} alt="" draggable="false" />
			<img className="logo-night" src={brandUrl(id, "logo-night", files)} alt="" draggable="false" />
		</span>
	);
}
// The mark on its own, where the full word cannot fit (the console's collapsed rail): the logo's
// app icon.
function LogoX({ brand }) {
	const current = useBrand();
	const id = brand || current;
	return <img className="logo logo--x logo--icon" src={brandUrl(id, "icon-192")} alt={STORE.name} draggable="false" />;
}

/* ---------- The painting ---------- */
// Filters shared by the painted figure: a hand-drawn wobble for contours and a dragged-brush
// texture for colour fields. Rendered once at the app root.
function PaintDefs() {
	return (
		<svg className="paint-defs" aria-hidden="true">
			<defs>
				<filter id="paint-hand" x="-8%" y="-8%" width="116%" height="116%">
					<feTurbulence type="fractalNoise" baseFrequency="0.045" numOctaves="2" seed="5" result="w" />
					<feDisplacementMap in="SourceGraphic" in2="w" scale="1.7" xChannelSelector="R" yChannelSelector="G" />
				</filter>
				<filter id="paint-field" x="0" y="0" width="100%" height="100%">
					<feTurbulence type="fractalNoise" baseFrequency="0.004 0.11" numOctaves="3" seed="21" result="s" />
					<feColorMatrix in="s" type="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.2 1.34" result="a" />
					<feComposite in="SourceGraphic" in2="a" operator="in" />
				</filter>
				{/* a dry brush: bristle gaps along the drag, a worked edge (WallArt) */}
				<filter id="paint-drag" x="-4%" y="-30%" width="108%" height="160%">
					<feTurbulence type="fractalNoise" baseFrequency="0.0016 0.075" numOctaves="3" seed="8" result="s" />
					<feColorMatrix in="s" type="matrix" values="0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -7 4.95" result="a" />
					<feComposite in="SourceGraphic" in2="a" operator="in" result="p" />
					<feTurbulence type="fractalNoise" baseFrequency="0.009" numOctaves="2" seed="3" result="w" />
					<feDisplacementMap in="p" in2="w" scale="18" xChannelSelector="R" yChannelSelector="G" />
				</filter>
			</defs>
		</svg>
	);
}

// Base lacquer tones for each look: [base, shaded edge, specular light, shade opacity].
const NAIL_FINISHES = {
	lacquer: ["var(--lacquer)", "var(--lacquer-shade)", "var(--lacquer-light)", 0.72],
	french: ["var(--lacquer-light)", "var(--lacquer)", "var(--chrome-light)", 0.42],
	frenchart: ["var(--lacquer-light)", "var(--lacquer)", "var(--chrome-light)", 0.42],
	cateye: ["var(--paint-berry)", "var(--art-ink)", "var(--lacquer-light)", 0.55],
	bling: ["var(--lacquer-light)", "var(--lacquer)", "var(--chrome-light)", 0.45],
	ombre: ["var(--on-paint)", "var(--lacquer-light)", "var(--chrome-light)", 0.3],
	milkbath: ["var(--on-paint)", "var(--lacquer-light)", "var(--chrome-light)", 0.4],
	airbrush: ["var(--on-paint)", "var(--lacquer-light)", "var(--chrome-light)", 0.32],
	chrome: ["var(--chrome)", "var(--chrome-shade)", "var(--chrome-light)", 0.85],
	animal: ["var(--on-paint)", "var(--paint-nude)", "var(--chrome-light)", 0.28],
	junk: ["var(--lacquer-light)", "var(--lacquer)", "var(--chrome-light)", 0.45],
	// a nail with nothing on it yet: translucent bare nail, outline dashed (Build your own)
	bare: ["var(--nail-bare)", "var(--skin-shade)", "var(--on-paint)", 0.22],
};

// The ground under every painted icon: two dragged passes over the colour field.
function PaintGround({ w = 300, h = 236 }) {
	return (
		<>
			<rect width={w} height={h} fill="#000" fillOpacity=".08" filter="url(#paint-field)" />
			<rect width={w} height={h} fill="#fff" fillOpacity=".1" filter="url(#paint-field)" transform={`translate(0 ${h}) scale(1 -1)`} />
		</>
	);
}

// How the free edge is cut: [corner radius, sidewall taper].
const NAIL_SHAPES = { square: [3, 0], coffin: [2.5, 8.5], almond: [6, 8], stiletto: [8, 9], round: [10, 0], duck: [2.5, 0] };
const DUCK_FLARE = 5.5;

// Editorial 4-point diamond light glint (graceful tapered star, never clunky outline).
function sparkPath(cx, cy, s) {
	const k = (n) => Math.round(n * 100) / 100;
	return `M${cx} ${k(cy - s)}C${k(cx + s * 0.1)} ${k(cy - s * 0.22)} ${k(cx + s * 0.22)} ${k(cy - s * 0.1)} ${k(cx + s)} ${cy}` +
		`C${k(cx + s * 0.22)} ${k(cy + s * 0.1)} ${k(cx + s * 0.1)} ${k(cy + s * 0.22)} ${cx} ${k(cy + s)}` +
		`C${k(cx - s * 0.1)} ${k(cy + s * 0.22)} ${k(cx - s * 0.22)} ${k(cy + s * 0.1)} ${k(cx - s)} ${cy}` +
		`C${k(cx - s * 0.22)} ${k(cy - s * 0.1)} ${k(cx - s * 0.1)} ${k(cy - s * 0.22)} ${cx} ${k(cy - s)}Z`;
}

// Sculpted 3D acrylic relief flower: layered teardrop petals with soft shadow, inner crease, and jewel center.
function SculptedBloom({ cx, cy, r, turn = 0 }) {
	const k = (n) => Math.round(n * 100) / 100;
	const petal = `M0 0 C${k(-r * 0.48)} ${k(-r * 0.35)} ${k(-r * 0.44)} ${k(-r * 0.96)} 0 ${k(-r)} C${k(r * 0.44)} ${k(-r * 0.96)} ${k(r * 0.48)} ${k(-r * 0.35)} 0 0 Z`;
	const inner = `M0 ${k(-r * 0.12)} C${k(-r * 0.18)} ${k(-r * 0.4)} ${k(-r * 0.16)} ${k(-r * 0.72)} 0 ${k(-r * 0.76)} C${k(r * 0.16)} ${k(-r * 0.72)} ${k(r * 0.18)} ${k(-r * 0.4)} 0 ${k(-r * 0.12)} Z`;
	return (
		<g transform={`translate(${k(cx)} ${k(cy)}) rotate(${turn})`}>
			{/* soft ambient cast shadow onto the lacquer */}
			<circle cx={k(r * 0.08)} cy={k(r * 0.14)} r={k(r * 0.96)} fill="var(--art-ink)" fillOpacity=".16" />
			{[0, 72, 144, 216, 288].map((a) => (
				<g key={a} transform={`rotate(${a})`}>
					<path d={petal} fill="var(--on-paint)" stroke="var(--lacquer-shade)" strokeWidth={k(Math.max(0.65, r * 0.075))} strokeLinejoin="round" />
					<path d={inner} fill="var(--lacquer-light)" fillOpacity=".65" />
				</g>
			))}
			{/* center crystal & gold micro-caviar */}
			<circle cx="0" cy="0" r={k(r * 0.28)} fill="var(--paint-ochre)" stroke="var(--art-ink)" strokeWidth={k(Math.max(0.55, r * 0.06))} strokeOpacity=".55" />
			<circle cx={k(-r * 0.07)} cy={k(-r * 0.07)} r={k(r * 0.1)} fill="var(--chrome-light)" />
		</g>
	);
}

// Satin coquette ribbon bow (for frenchart, junk, character).
function CoquetteBow({ cx, cy, s = 1, fill = "var(--paint-berry)", ribbon = "var(--lacquer-light)" }) {
	const k = (n) => Math.round(n * 100) / 100;
	return (
		<g transform={`translate(${k(cx)} ${k(cy)}) scale(${k(s)})`}>
			{/* soft shadow */}
			<ellipse cx="0.6" cy="2.2" rx="10.5" ry="4.5" fill="var(--art-ink)" fillOpacity=".15" />
			{/* tails */}
			<path d="M-1.5 1.5 C-4 5.5 -6.5 9.5 -8.5 12.5 C-6 12.2 -3.8 11 -1.5 5.5 Z" fill={fill} stroke="var(--art-ink)" strokeWidth=".75" strokeOpacity=".55" strokeLinejoin="round" />
			<path d="M1.5 1.5 C4 5.5 6.5 9.5 8.5 12.5 C6 12.2 3.8 11 1.5 5.5 Z" fill={fill} stroke="var(--art-ink)" strokeWidth=".75" strokeOpacity=".55" strokeLinejoin="round" />
			{/* left & right loops */}
			<path d="M-1.5 0 C-5 -5.8 -12.5 -5.4 -12 0.2 C-11.5 5.4 -5 4.8 -1.5 1.4 Z" fill={fill} stroke="var(--art-ink)" strokeWidth=".8" strokeOpacity=".6" strokeLinejoin="round" />
			<path d="M1.5 0 C5 -5.8 12.5 -5.4 12 0.2 C11.5 5.4 5 4.8 1.5 1.4 Z" fill={fill} stroke="var(--art-ink)" strokeWidth=".8" strokeOpacity=".6" strokeLinejoin="round" />
			{/* inner silk highlights */}
			<path d="M-3.5 -0.8 C-6 -2.8 -9.2 -2.4 -9 0" fill="none" stroke={ribbon} strokeWidth="1.2" strokeLinecap="round" strokeOpacity=".8" />
			<path d="M3.5 -0.8 C6 -2.8 9.2 -2.4 9 0" fill="none" stroke={ribbon} strokeWidth="1.2" strokeLinecap="round" strokeOpacity=".8" />
			{/* center knot + pearl */}
			<rect x="-2.4" y="-2.2" width="4.8" height="4.6" rx="1.8" fill={fill} stroke="var(--art-ink)" strokeWidth=".75" strokeOpacity=".6" />
			<circle cx="0" cy="0" r="1.2" fill="var(--on-paint)" />
		</g>
	);
}

// Faceted luxury crystal gem (marquise, oval, or round) with crisp internal facets and glint.
function FacetedGem({ cx, cy, rx, ry, turn = 0, tint = "var(--chrome-light)", bezel = "var(--paint-ochre)" }) {
	const k = (n) => Math.round(n * 100) / 100;
	return (
		<g transform={`translate(${k(cx)} ${k(cy)}) rotate(${turn})`}>
			<ellipse cx={k(rx * 0.1)} cy={k(ry * 0.14)} rx={k(rx * 1.15)} ry={k(ry * 1.15)} fill="var(--art-ink)" fillOpacity=".18" />
			{bezel && <ellipse cx="0" cy="0" rx={k(rx * 1.12)} ry={k(ry * 1.12)} fill={bezel} stroke="var(--art-ink)" strokeWidth=".6" strokeOpacity=".5" />}
			<path d={`M0 ${k(-ry)} L${k(rx * 0.72)} ${k(-ry * 0.55)} L${k(rx)} 0 L${k(rx * 0.72)} ${k(ry * 0.55)} L0 ${k(ry)} L${k(-rx * 0.72)} ${k(ry * 0.55)} L${k(-rx)} 0 L${k(-rx * 0.72)} ${k(-ry * 0.55)} Z`} fill={tint} stroke="var(--chrome-shade)" strokeWidth=".65" strokeLinejoin="round" />
			{/* inner table & crown facets */}
			<path d={`M0 ${k(-ry * 0.55)} L${k(rx * 0.45)} 0 L0 ${k(ry * 0.55)} L${k(-rx * 0.45)} 0 Z`} fill="#fff" fillOpacity=".78" stroke="var(--chrome-shade)" strokeWidth=".45" />
			<path d={`M0 ${k(-ry)} L0 ${k(-ry * 0.55)} M0 ${k(ry)} L0 ${k(ry * 0.55)} M${k(-rx)} 0 L${k(-rx * 0.45)} 0 M${k(rx)} 0 L${k(rx * 0.45)} 0`} stroke="var(--chrome-shade)" strokeWidth=".45" strokeOpacity=".7" />
			<circle cx={k(-rx * 0.22)} cy={k(-ry * 0.25)} r={k(Math.max(0.7, rx * 0.16))} fill="#fff" />
		</g>
	);
}

// Luminous pearl bead with shadow and pinpoint specular.
function PearlBead({ cx, cy, r, fill = "var(--on-paint)" }) {
	const k = (n) => Math.round(n * 100) / 100;
	return (
		<g>
			<circle cx={k(cx + r * 0.18)} cy={k(cy + r * 0.24)} r={k(r)} fill="var(--art-ink)" fillOpacity=".18" />
			<circle cx={k(cx)} cy={k(cy)} r={k(r)} fill={fill} stroke="var(--art-ink)" strokeWidth={k(Math.max(0.5, r * 0.22))} strokeOpacity=".42" />
			<circle cx={k(cx - r * 0.28)} cy={k(cy - r * 0.28)} r={k(r * 0.34)} fill="#fff" fillOpacity=".9" />
		</g>
	);
}

// Heart flame ("Flame letter"): Old English L + metallic-edged black flames + cuticle crystals.
const OLD_ENGLISH_L = "M2 -38.6Q1 -28.4 0.9 -20.3Q0.9 -12.3 1.1 -5.1Q1.3 2.1 1.3 9.8Q1.3 14.6 -0.2 17.4Q-1.8 20.3 -4.8 22.4Q-7.7 24.5 -12.1 27L-11.8 27.9L36.2 30.6Q38.1 32.5 38.1 35.3L30.3 50Q17.4 48.3 9.3 47.2Q1.2 46.1 -3.6 45.5Q-8.4 45 -10.8 44.8Q-13.2 44.5 -14.6 44.5Q-16.4 44.5 -20 45.1Q-23.7 45.8 -28 46.6Q-32.3 47.5 -36.2 48.4L-38.3 46.7L-35.9 33.3Q-30.9 31.8 -28.6 30.1Q-26.2 28.4 -25.6 25.5Q-25 22.6 -25 17.9Q-25 14.8 -25.3 10.7Q-25.6 6.7 -26.1 2.1Q-26.5 -2.4 -26.9 -7Q-27.3 -11.5 -27.5 -15.5Q-27.6 -19.5 -27.5 -22.5Q-25.9 -25.1 -22.1 -28.9Q-18.2 -32.6 -13.2 -36.4Q-8.2 -40.1 -3.5 -42.6ZM7.6 30V-38.4Q7.6 -39.7 8.4 -43.2Q9.2 -46.7 10.3 -49.8L16 -48.1V21Q16 22 14.9 24.4Q13.7 26.8 12 30ZM36.4 -14H23.7L21.4 -32.9Q20.1 -33.6 18.5 -34.2Q17 -34.8 15.3 -35.3Q13.5 -35.8 11.8 -35.8Q11.2 -35.8 10.6 -35.8Q10.1 -35.8 9.5 -35.6L10.3 -49.8Q10.9 -50 11.6 -50Q12.3 -50 12.9 -50Q16.4 -50 20.8 -49.4Q25.3 -48.7 29.9 -48Q34.5 -47.2 38.3 -46.6Z";

function flameTongue(bx, by, w, h, dir = 1) {
	const k = (n) => Math.round(n * 100) / 100;
	const X = (a) => k(bx + a * w * dir), Y = (b) => k(by - b * h);
	return `M${X(-0.5)} ${Y(0)}C${X(-0.5)} ${Y(0.35)} ${X(-0.02)} ${Y(0.5)} ${X(-0.12)} ${Y(0.72)}` +
		`C${X(-0.2)} ${Y(0.88)} ${X(-0.02)} ${Y(0.99)} ${X(0.3)} ${Y(1)}` +
		`C${X(0.04)} ${Y(0.9)} ${X(0.06)} ${Y(0.78)} ${X(0.2)} ${Y(0.62)}` +
		`C${X(0.42)} ${Y(0.4)} ${X(0.5)} ${Y(0.22)} ${X(0.5)} ${Y(0)}Z`;
}
const HF_FLAMES = [[0.08, 0.42, 0.5, 1], [0.36, 0.66, 0.5, -1], [0.66, 0.56, 0.5, 1], [0.94, 0.53, 0.5, -1]];

function HeartFlameNail({ at, cuticle, w, rise = 1, letter: [lp, lh], line = 1 }) {
	const k = (n) => Math.round(n * 100) / 100;
	const [, tipY] = at(0, 0), [, cutY] = at(0, 1);
	const len = cutY - tipY;
	const flames = HF_FLAMES.map(([u, h, fw, dir]) => {
		const [bx, by] = cuticle(u);
		return flameTongue(bx, by + len * 0.12, fw * w, h * rise * len, dir);
	});
	const edge = [-0.1, 0.05, 0.2, 0.35, 0.5, 0.65, 0.8, 0.95, 1.1].map((u) => {
		const [ex, ey] = cuticle(u);
		return `${ex} ${k(ey - len * 0.14)}`;
	});
	const [lx, ly] = at(0.5, lp);
	const s = lh / 100;
	return (
		<g strokeLinejoin="round">
			{flames.map((d, i) => <path key={"e" + i} d={d} fill="none" stroke="var(--chrome-light)" strokeWidth={k(2.4 * line)} />)}
			<path d={`M${edge.join("L")}V${k(cutY + len * 0.4)}H${cuticle(-0.1)[0]}Z`} fill="var(--art-ink)" />
			{flames.map((d, i) => <path key={"f" + i} d={d} fill="var(--art-ink)" />)}
			<g transform={`translate(${lx} ${ly}) scale(${Math.round(s * 1000) / 1000})`}>
				<path d={OLD_ENGLISH_L} fill="none" stroke="var(--chrome-light)" strokeWidth={k((2.2 * line) / s)} />
				<path d={OLD_ENGLISH_L} fill="var(--art-ink)" />
			</g>
		</g>
	);
}

function HeartFlameCrystals({ cuticle, size = 1.75, count = 9 }) {
	const k = (n) => Math.round(n * 100) / 100;
	return (
		<g>
			{Array.from({ length: count }, (_, i) => {
				const [cx, cy] = cuticle(0.08 + (0.84 * i) / (count - 1));
				const mid = i === (count - 1) / 2;
				const r = mid ? size * 1.45 : size * (1 - Math.abs(i - (count - 1) / 2) * 0.06);
				return <PearlBead key={i} cx={cx} cy={k(cy - r * 0.35)} r={k(r)} fill={mid ? "var(--lacquer)" : "var(--chrome-light)"} />;
			})}
		</g>
	);
}

// Organic fluid cow-print patches (varied silhouettes, wrapped across sidewalls).
const COW_SPOTS = [
	[0.86, 0.16, 12, 1.05, "M-8 -3 C-6 -9 4 -10 8 -5 C11 -1 10 5 5 7 C1 8 -1 10 -6 8 C-10 6 -10 1 -8 -3 Z"],
	[0.14, 0.32, -18, 1.12, "M-7 -6 C-2 -10 6 -7 8 -2 C9 2 4 4 3 8 C2 11 -5 10 -8 6 C-10 2 -11 -3 -7 -6 Z"],
	[0.72, 0.52, 22, 1.0, "M-7 0 C-8 -6 -1 -9 5 -6 C9 -4 10 2 6 6 C2 9 -6 7 -7 0 Z"],
	[0.18, 0.71, 35, 0.92, "M-6 -4 C-3 -8 5 -7 7 -2 C8 2 4 7 -1 7 C-6 7 -9 1 -6 -4 Z"],
	[0.82, 0.82, -24, 0.96, "M-7 -2 C-5 -7 3 -8 7 -4 C10 0 8 6 3 7 C-2 8 -9 4 -7 -2 Z"],
	[0.44, 0.24, -10, 0.52, "M-5 -2 C-4 -6 3 -6 5 -2 C6 2 3 6 -2 5 C-6 4 -6 1 -5 -2 Z"],
	[0.48, 0.9, 8, 0.62, "M-6 -2 C-3 -6 4 -5 6 -1 C7 3 2 6 -3 5 C-7 4 -8 1 -6 -2 Z"],
];

// Shared editorial nail art renderer — runs inside the nail clip (`layer="in"`) and over the nail (`layer="over"`),
// scaling cleanly to both long fingers (HandStage) and short wide toenails (ToeIcon).
function NailArtLayer({ look, layer, at, cuticle, w, h, id, shape, isToe = false }) {
	const k = (n) => Math.round(n * 100) / 100;
	const [xL] = at(-0.08, 0), [xR] = at(1.08, 0);
	const [, yTop] = at(0.5, 0), [, yCut] = at(0.5, 1);
	const u = Math.min(w, h) / 38; // unit scale relative to finger nail width (38)
	const [cx, cy] = at(0.5, 0.5);

	if (layer === "in") {
		return (
			<g>
				{/* French & French art & Junk: razor-crisp sculpted salon smile line */}
				{(look === "french" || look === "frenchart" || look === "junk") && (
					<g>
						<path
							d={`M${xL} ${k(yTop - 6)} H${xR} V${k(at(0.5, isToe ? 0.44 : 0.41)[1])} Q${cx} ${k(at(0.5, isToe ? 0.14 : 0.15)[1])} ${xL} ${k(at(0.5, isToe ? 0.44 : 0.41)[1])} Z`}
							fill="var(--on-paint)"
						/>
						{/* whisper smile-line depth */}
						<path
							d={`M${xL} ${k(at(0.5, isToe ? 0.44 : 0.41)[1])} Q${cx} ${k(at(0.5, isToe ? 0.14 : 0.15)[1])} ${xR} ${k(at(0.5, isToe ? 0.44 : 0.41)[1])}`}
							fill="none"
							stroke="var(--lacquer-shade)"
							strokeWidth={k(0.9 * u)}
							strokeOpacity=".35"
						/>
					</g>
				)}

				{/* Ombré: silky 4-stop editorial blush-to-berry fade */}
				{look === "ombre" && (
					<rect x={xL} y={k(yTop - 4)} width={k(xR - xL)} height={k(yCut - yTop + 12)} fill={`url(#${id}ombre)`} />
				)}

				{/* Cat Eye: velvety deep plum-berry with luminous magnetic silk S-band */}
				{look === "cateye" && (
					<g>
						<rect x={xL} y={k(yTop - 4)} width={k(xR - xL)} height={k(yCut - yTop + 12)} fill={`url(#${id}catbase)`} />
						{/* soft diffused magnetic velvet glow */}
						<ellipse
							cx={at(0.52, 0.48)[0]}
							cy={at(0.52, 0.48)[1]}
							rx={k(w * 0.56)}
							ry={k(h * 0.3)}
							transform={`rotate(${isToe ? -18 : -26} ${at(0.52, 0.48)[0]} ${at(0.52, 0.48)[1]})`}
							fill={`url(#${id}catglow)`}
						/>
						{/* crisp magnetic silk catch-line */}
						<path
							d={`M${xL} ${at(0, 0.72)[1]} Q${at(0.5, 0.48)[0]} ${at(0.5, 0.52)[1]} ${xR} ${at(1, 0.28)[1]}`}
							fill="none"
							stroke="var(--lacquer-light)"
							strokeWidth={k(2.6 * u)}
							strokeOpacity=".72"
							strokeLinecap="round"
						/>
						<path
							d={`M${xL} ${at(0, 0.72)[1]} Q${at(0.5, 0.48)[0]} ${at(0.5, 0.52)[1]} ${xR} ${at(1, 0.28)[1]}`}
							fill="none"
							stroke="#fff"
							strokeWidth={k(0.9 * u)}
							strokeOpacity=".65"
							strokeLinecap="round"
						/>
					</g>
				)}

				{/* Airbrush Aura: luminous multi-layered radial blush-berry halo + fine-line chrome starlight */}
				{look === "airbrush" && (
					<g>
						<rect x={xL} y={k(yTop - 4)} width={k(xR - xL)} height={k(yCut - yTop + 12)} fill={`url(#${id}aura)`} />
						{/* delicate fine-line chrome sparkles (signature aura nail accent) */}
						<path d={sparkPath(at(0.32, 0.34)[0], at(0.32, 0.34)[1], k(4.6 * u))} fill="var(--chrome-light)" stroke="var(--chrome-shade)" strokeWidth={k(0.5 * u)} />
						<path d={sparkPath(at(0.68, 0.64)[0], at(0.68, 0.64)[1], k(3.1 * u))} fill="var(--chrome-light)" stroke="var(--chrome-shade)" strokeWidth={k(0.45 * u)} />
						<circle cx={at(0.66, 0.3)[0]} cy={at(0.66, 0.3)[1]} r={k(1.0 * u)} fill="var(--chrome-light)" />
					</g>
				)}

				{/* Mirror Chrome: liquid-metal multi-stop metallic reflection across the C-curve */}
				{look === "chrome" && (
					<g>
						<rect x={xL} y={k(yTop - 4)} width={k(xR - xL)} height={k(yCut - yTop + 12)} fill={`url(#${id}chrome)`} />
						{/* horizon liquid reflection bend */}
						<path
							d={`M${xL} ${at(0, 0.38)[1]} Q${cx} ${at(0.5, 0.56)[1]} ${xR} ${at(1, 0.34)[1]} V${at(1, 0.54)[1]} Q${cx} ${at(0.5, 0.74)[1]} ${xL} ${at(0, 0.56)[1]} Z`}
							fill="var(--chrome-shade)"
							fillOpacity=".58"
						/>
						<path
							d={`M${xL} ${at(0, 0.58)[1]} Q${cx} ${at(0.5, 0.74)[1]} ${xR} ${at(1, 0.54)[1]}`}
							fill="none"
							stroke="#fff"
							strokeWidth={k(2.2 * u)}
							strokeOpacity=".85"
						/>
						<path
							d={`M${xL} ${at(0, 0.22)[1]} Q${cx} ${at(0.5, 0.34)[1]} ${xR} ${at(1, 0.18)[1]}`}
							fill="none"
							stroke="var(--lacquer-light)"
							strokeWidth={k(2.0 * u)}
							strokeOpacity=".35"
						/>
					</g>
				)}

				{/* Milk Bath: translucent encapsulated dried petals, silky marble wisps & gold-pink foil flakes */}
				{look === "milkbath" && (
					<g>
						{/* silky milky marble wisps */}
						<path
							d={`M${at(0.12, 0.16)[0]} ${at(0.12, 0.16)[1]} C${at(0.86, 0.28)[0]} ${at(0.86, 0.28)[1]} ${at(0.14, 0.52)[0]} ${at(0.14, 0.52)[1]} ${at(0.82, 0.74)[0]} ${at(0.82, 0.74)[1]}`}
							fill="none"
							stroke="var(--lacquer-light)"
							strokeWidth={k(8 * u)}
							strokeOpacity=".45"
							strokeLinecap="round"
						/>
						{/* pressed botanical blossoms (soft multi-petal clusters under milky glaze) */}
						{[
							[0.34, 0.34, 5.2 * u, 18],
							[0.68, 0.56, 4.6 * u, -24],
							[0.38, 0.76, 3.8 * u, 42]
						].map(([ux, py, r, rot], i) => {
							const [px, pyc] = at(ux, py);
							return (
								<g key={i} transform={`translate(${px} ${pyc}) rotate(${rot})`}>
									{[0, 72, 144, 216, 288].map((a) => (
										<ellipse
											key={a}
											cx="0"
											cy={k(-r * 0.55)}
											rx={k(r * 0.36)}
											ry={k(r * 0.58)}
											fill={i === 1 ? "var(--paint-rose)" : "var(--lacquer)"}
											fillOpacity=".78"
											transform={`rotate(${a})`}
										/>
									))}
									<circle cx="0" cy="0" r={k(r * 0.22)} fill="var(--paint-ochre)" />
								</g>
							);
						})}
						{/* delicate metallic foil flakes */}
						{[
							[0.66, 0.24, 22],
							[0.24, 0.52, -30],
							[0.72, 0.82, 15],
							[0.5, 0.44, -12]
						].map(([ux, py, rot], i) => {
							const [fx, fy] = at(ux, py);
							return (
								<path
									key={i}
									d={`M${k(-2.2 * u)} 0 L0 ${k(-1.6 * u)} L${k(2.5 * u)} ${k(-0.4 * u)} L${k(0.6 * u)} ${k(1.8 * u)} Z`}
									fill="var(--paint-ochre)"
									fillOpacity=".92"
									transform={`translate(${fx} ${fy}) rotate(${rot})`}
								/>
							);
						})}
						{/* milky translucent builder-gel encapsulation veil */}
						<rect x={xL} y={k(yTop - 4)} width={k(xR - xL)} height={k(yCut - yTop + 12)} fill="var(--on-paint)" fillOpacity=".28" />
					</g>
				)}

				{/* Animal print: fluid editorial cow spots wrapped smoothly around the nail */}
				{look === "animal" &&
					COW_SPOTS.map(([ux, py, rot, sc, d], i) => {
						const [px, pyc] = at(ux, py);
						return (
							<path
								key={i}
								d={d}
								fill="var(--art-ink)"
								fillOpacity=".92"
								transform={`translate(${px} ${pyc}) rotate(${rot}) scale(${k(sc * u * (isToe ? 1.1 : 0.92))})`}
							/>
						);
					})}

				{/* Heart flame: Old English L + metallic-edged black flames */}
				{look === "heartflame" && (
					<HeartFlameNail
						at={at}
						cuticle={cuticle}
						w={isToe ? w * 0.62 : w}
						rise={isToe ? 1.05 : 1}
						letter={isToe ? [0.24, 20] : shape === "stiletto" ? [0.35, 19] : shape === "almond" ? [0.3, 24] : [0.27, 27]}
						line={isToe ? 1.15 : 1}
					/>
				)}

				{/* Character art: bespoke hand-painted kawaii studio kitty/bunny portrait with berry bow (never a generic smiley) */}
				{look === "character" && (() => {
					const [hx, hy] = at(0.5, isToe ? 0.56 : 0.5);
					const sc = k(u * (isToe ? 0.95 : 0.92));
					return (
						<g transform={`translate(${hx} ${hy}) scale(${sc})`}>
							{/* soft tinted aura behind portrait */}
							<circle cx="0" cy="0" r="16" fill="var(--lacquer-light)" fillOpacity=".55" />
							{/* left & right cute ears */}
							<path d="M-11 -6 L-13 -16.5 C-10 -15.5 -6.5 -13 -4.5 -10 Z" fill="var(--on-paint)" stroke="var(--art-ink)" strokeWidth="1.25" strokeLinejoin="round" />
							<path d="M11 -6 L13 -16.5 C10 -15.5 6.5 -13 4.5 -10 Z" fill="var(--on-paint)" stroke="var(--art-ink)" strokeWidth="1.25" strokeLinejoin="round" />
							{/* inner ear blush */}
							<path d="M-10.2 -8 L-11.2 -13.6 L-7 -10.4 Z" fill="var(--lacquer)" />
							<path d="M10.2 -8 L11.2 -13.6 L7 -10.4 Z" fill="var(--lacquer)" />
							{/* sculpted kawaii face */}
							<ellipse cx="0" cy="0" rx="13.2" ry="10.8" fill="var(--on-paint)" stroke="var(--art-ink)" strokeWidth="1.25" />
							{/* rosy airbrushed cheeks */}
							<ellipse cx="-7.5" cy="2.6" rx="2.7" ry="1.6" fill="var(--lacquer)" fillOpacity=".75" />
							<ellipse cx="7.5" cy="2.6" rx="2.7" ry="1.6" fill="var(--lacquer)" fillOpacity=".75" />
							{/* sparkling manga eyes */}
							<ellipse cx="-4.8" cy="-0.4" rx="1.65" ry="2.2" fill="var(--art-ink)" />
							<ellipse cx="4.8" cy="-0.4" rx="1.65" ry="2.2" fill="var(--art-ink)" />
							<circle cx="-5.3" cy="-1.2" r=".72" fill="#fff" />
							<circle cx="4.3" cy="-1.2" r=".72" fill="#fff" />
							{/* tiny nose + delicate cat smile */}
							<ellipse cx="0" cy="1.8" rx="1.35" ry=".95" fill="var(--paint-ochre)" stroke="var(--art-ink)" strokeWidth=".6" />
							<path d="M-2.2 3.4 Q-1.1 4.8 0 3.5 Q1.1 4.8 2.2 3.4" fill="none" stroke="var(--art-ink)" strokeWidth=".95" strokeLinecap="round" />
							{/* tiny satin bow perched on right ear */}
							<g transform="translate(8.2 -10.4) rotate(22) scale(.52)">
								<CoquetteBow cx={0} cy={0} s={1} fill="var(--paint-berry)" ribbon="var(--lacquer-light)" />
							</g>
						</g>
					);
				})()}

				{/* French with Designs: delicate fine-line coquette swirl under smile line */}
				{look === "frenchart" && (
					<path
						d={`M${at(0.18, 0.55)[0]} ${at(0.18, 0.55)[1]} C${at(0.32, 0.44)[0]} ${at(0.32, 0.44)[1]} ${at(0.68, 0.44)[0]} ${at(0.68, 0.44)[1]} ${at(0.82, 0.55)[0]} ${at(0.82, 0.55)[1]}`}
						fill="none"
						stroke="var(--paint-berry)"
						strokeWidth={k(1.0 * u)}
						strokeOpacity=".45"
						strokeLinecap="round"
					/>
				)}
			</g>
		);
	}

	// Raised 3D art, crystals, charms, bows & blooms painted cleanly OVER the nail gloss
	return (
		<g>
			{look === "frenchart" && (
				<g>
					<CoquetteBow cx={at(0.5, isToe ? 0.64 : 0.58)[0]} cy={at(0.5, isToe ? 0.64 : 0.58)[1]} s={k(u * (isToe ? 0.85 : 0.82))} />
					<PearlBead cx={at(0.24, isToe ? 0.68 : 0.66)[0]} cy={at(0.24, isToe ? 0.68 : 0.66)[1]} r={k(1.6 * u)} />
					<PearlBead cx={at(0.76, isToe ? 0.68 : 0.66)[0]} cy={at(0.76, isToe ? 0.68 : 0.66)[1]} r={k(1.6 * u)} />
					<path d={sparkPath(at(0.5, isToe ? 0.86 : 0.82)[0], at(0.5, isToe ? 0.86 : 0.82)[1], k(3.4 * u))} fill="var(--paint-ochre)" />
				</g>
			)}

			{look === "flowers" && (
				<g>
					<SculptedBloom cx={at(0.44, isToe ? 0.42 : 0.36)[0]} cy={at(0.44, isToe ? 0.42 : 0.36)[1]} r={k(11.5 * u)} turn={-12} />
					<SculptedBloom cx={at(0.66, isToe ? 0.72 : 0.68)[0]} cy={at(0.66, isToe ? 0.72 : 0.68)[1]} r={k(8.2 * u)} turn={24} />
					<PearlBead cx={at(0.26, isToe ? 0.74 : 0.68)[0]} cy={at(0.26, isToe ? 0.74 : 0.68)[1]} r={k(1.8 * u)} fill="var(--paint-ochre)" />
					<PearlBead cx={at(0.36, isToe ? 0.84 : 0.78)[0]} cy={at(0.36, isToe ? 0.84 : 0.78)[1]} r={k(1.4 * u)} fill="var(--on-paint)" />
				</g>
			)}

			{look === "charms" && (
				<g>
					{/* couture centerpiece bezel brooch + cascading pearls & caviar beads */}
					<FacetedGem cx={at(0.5, isToe ? 0.44 : 0.38)[0]} cy={at(0.5, isToe ? 0.44 : 0.38)[1]} rx={k(5.8 * u)} ry={k(7.4 * u)} />
					<PearlBead cx={at(0.26, isToe ? 0.46 : 0.42)[0]} cy={at(0.26, isToe ? 0.46 : 0.42)[1]} r={k(2.2 * u)} fill="var(--on-paint)" />
					<PearlBead cx={at(0.74, isToe ? 0.46 : 0.42)[0]} cy={at(0.74, isToe ? 0.46 : 0.42)[1]} r={k(2.2 * u)} fill="var(--on-paint)" />
					<PearlBead cx={at(0.5, isToe ? 0.7 : 0.62)[0]} cy={at(0.5, isToe ? 0.7 : 0.62)[1]} r={k(2.7 * u)} fill="var(--paint-ochre)" />
					<PearlBead cx={at(0.32, isToe ? 0.8 : 0.74)[0]} cy={at(0.32, isToe ? 0.8 : 0.74)[1]} r={k(1.7 * u)} fill="var(--paint-ochre)" />
					<PearlBead cx={at(0.68, isToe ? 0.8 : 0.74)[0]} cy={at(0.68, isToe ? 0.8 : 0.74)[1]} r={k(1.7 * u)} fill="var(--paint-ochre)" />
					<PearlBead cx={at(0.5, isToe ? 0.88 : 0.84)[0]} cy={at(0.5, isToe ? 0.88 : 0.84)[1]} r={k(1.6 * u)} fill="var(--on-paint)" />
				</g>
			)}

			{look === "bling" && (
				<g>
					{/* couture full-bling crystal pavé: tightly nested varied faceted gems & sparkling micro-crystals */}
					<FacetedGem cx={at(0.5, isToe ? 0.5 : 0.48)[0]} cy={at(0.5, isToe ? 0.5 : 0.48)[1]} rx={k(5.6 * u)} ry={k(7.4 * u)} bezel="var(--chrome)" />
					<FacetedGem cx={at(0.24, isToe ? 0.34 : 0.3)[0]} cy={at(0.24, isToe ? 0.34 : 0.3)[1]} rx={k(3.6 * u)} ry={k(4.5 * u)} turn={-16} bezel="var(--chrome)" />
					<FacetedGem cx={at(0.76, isToe ? 0.34 : 0.3)[0]} cy={at(0.76, isToe ? 0.34 : 0.3)[1]} rx={k(3.6 * u)} ry={k(4.5 * u)} turn={16} bezel="var(--chrome)" />
					<FacetedGem cx={at(0.5, isToe ? 0.2 : 0.17)[0]} cy={at(0.5, isToe ? 0.2 : 0.17)[1]} rx={k(3.6 * u)} ry={k(4.4 * u)} bezel="var(--chrome)" />
					<FacetedGem cx={at(0.24, isToe ? 0.68 : 0.68)[0]} cy={at(0.24, isToe ? 0.68 : 0.68)[1]} rx={k(3.7 * u)} ry={k(4.6 * u)} turn={14} bezel="var(--chrome)" />
					<FacetedGem cx={at(0.76, isToe ? 0.68 : 0.68)[0]} cy={at(0.76, isToe ? 0.68 : 0.68)[1]} rx={k(3.7 * u)} ry={k(4.6 * u)} turn={-14} bezel="var(--chrome)" />
					<FacetedGem cx={at(0.5, isToe ? 0.84 : 0.82)[0]} cy={at(0.5, isToe ? 0.84 : 0.82)[1]} rx={k(4.0 * u)} ry={k(4.0 * u)} bezel="var(--chrome)" />
					{/* dense micro-pavé filling every gap */}
					{[
						[0.24, 0.12, 2.0], [0.76, 0.12, 2.0], [0.5, 0.06, 1.8],
						[0.18, 0.5, 2.2], [0.82, 0.5, 2.2],
						[0.34, 0.32, 1.7], [0.66, 0.32, 1.7],
						[0.34, 0.64, 1.7], [0.66, 0.64, 1.7],
						[0.24, 0.88, 2.1], [0.76, 0.88, 2.1],
						[0.36, 0.92, 1.8], [0.64, 0.92, 1.8]
					].map(([ux, py, r], i) => (
						<PearlBead key={i} cx={at(ux, py)[0]} cy={at(ux, py)[1]} r={k(r * u)} fill="var(--chrome-light)" />
					))}
					<path d={sparkPath(at(0.5, isToe ? 0.44 : 0.42)[0], at(0.5, isToe ? 0.44 : 0.42)[1], k(4.8 * u))} fill="#fff" />
					<path d={sparkPath(at(0.28, isToe ? 0.66 : 0.66)[0], at(0.28, isToe ? 0.66 : 0.66)[1], k(3.2 * u))} fill="#fff" />
				</g>
			)}

			{look === "junk" && (
				<g>
					{/* maximalist couture collage: sculpted 3D bloom, coquette bow, bezel jewel, pearls & caviar */}
					<SculptedBloom cx={at(0.32, isToe ? 0.44 : 0.42)[0]} cy={at(0.32, isToe ? 0.44 : 0.42)[1]} r={k(9.0 * u)} turn={-14} />
					<FacetedGem cx={at(0.7, isToe ? 0.42 : 0.36)[0]} cy={at(0.7, isToe ? 0.42 : 0.36)[1]} rx={k(4.6 * u)} ry={k(5.8 * u)} turn={10} />
					<CoquetteBow cx={at(0.54, isToe ? 0.72 : 0.68)[0]} cy={at(0.54, isToe ? 0.72 : 0.68)[1]} s={k(u * 0.72)} fill="var(--paint-rose)" ribbon="var(--on-paint)" />
					<PearlBead cx={at(0.24, isToe ? 0.74 : 0.72)[0]} cy={at(0.24, isToe ? 0.74 : 0.72)[1]} r={k(2.4 * u)} fill="var(--on-paint)" />
					<PearlBead cx={at(0.78, isToe ? 0.76 : 0.76)[0]} cy={at(0.78, isToe ? 0.76 : 0.76)[1]} r={k(2.0 * u)} fill="var(--paint-ochre)" />
					<PearlBead cx={at(0.42, isToe ? 0.88 : 0.86)[0]} cy={at(0.42, isToe ? 0.88 : 0.86)[1]} r={k(1.7 * u)} fill="var(--chrome-light)" />
					<PearlBead cx={at(0.68, isToe ? 0.2 : 0.18)[0]} cy={at(0.68, isToe ? 0.2 : 0.18)[1]} r={k(1.7 * u)} fill="var(--on-paint)" />
				</g>
			)}

			{look === "heartflame" && <HeartFlameCrystals cuticle={cuticle} size={isToe ? 2.4 : 1.7} count={isToe ? 9 : 7} />}
		</g>
	);
}

function HandStage({ ext, marks = [], label = "Nail length preview", look, shape, frame = "0 0 300 236" }) {
	const CX = 150, T = 114, BED = 50, NW = 38;
	const e = Math.max(0, ext);
	const f = (n) => Math.round(n * 100) / 100;
	const x = CX - NW / 2;
	const top = T + 4 - e;
	const cut = T + BED;
	const c = NW * 0.3;
	const cutTo = NAIL_SHAPES[shape];
	const r = cutTo ? cutTo[0] : Math.max(3.2, 11 - e * 0.24);
	const t = cutTo ? cutTo[1] : Math.min(7, Math.max(0, (e - 10) * 0.085));
	const yt = Math.max(T + 6, top + r);
	const rise = yt - top;
	const fl = shape === "duck" ? DUCK_FLARE : 0;
	const xl = x - 3 - fl, xr = x + NW + 3 + fl;
	const edge =
		shape === "duck" ? `C${x + NW} ${f(yt - rise * 0.3)} ${f(x + NW + fl * 0.7)} ${f(top + rise * 0.3)} ${x + NW + fl} ${f(top + r)}Q${x + NW + fl} ${f(top)} ${f(x + NW + fl - r)} ${f(top)}L${f(x - fl + r)} ${f(top)}Q${x - fl} ${f(top)} ${x - fl} ${f(top + r)}C${f(x - fl * 0.7)} ${f(top + rise * 0.3)} ${x} ${f(yt - rise * 0.3)} ${x} ${f(yt)}`
		: shape === "almond" ? `C${x + NW} ${f(yt - rise * 0.5)} ${CX + 11} ${f(top + 4)} ${CX} ${f(top)}C${CX - 11} ${f(top + 4)} ${x} ${f(yt - rise * 0.5)} ${x} ${f(yt)}`
		: shape === "stiletto" ? `C${x + NW - 0.5} ${f(yt - rise * 0.38)} ${CX + 5.5} ${f(top + 13)} ${CX + 1.3} ${f(top + 1.6)}Q${CX} ${f(top - 0.6)} ${CX - 1.3} ${f(top + 1.6)}C${CX - 5.5} ${f(top + 13)} ${x + 0.5} ${f(yt - rise * 0.38)} ${x} ${f(yt)}`
		: shape === "round" ? `C${x + NW} ${f(top + 3)} ${CX + 13} ${f(top)} ${CX} ${f(top)}C${CX - 13} ${f(top)} ${x} ${f(top + 3)} ${x} ${f(yt)}`
		: `L${f(x + NW - t)} ${f(top + r)}Q${f(x + NW - t)} ${f(top)} ${f(x + NW - t - r)} ${f(top)}L${f(x + t + r)} ${f(top)}Q${f(x + t)} ${f(top)} ${f(x + t)} ${f(top + r)}L${x} ${f(yt)}`;
	const nail = `M${x} ${f(cut - c)}C${x} ${f(cut + c * 0.5)} ${x + NW} ${f(cut + c * 0.5)} ${x + NW} ${f(cut - c)}L${x + NW} ${f(yt)}${edge}Z`;
	// one slender fingertip, a little asymmetric, the way a real one is
	const finger =
		`M121.5 252C121.5 238 119.5 ${T + 116} 120.5 ${T + 101}C121.5 ${T + 84} 124 ${T + 68} 123.5 ${T + 46}` +
		`C123 ${T + 17} 133.5 ${T} 149.8 ${T}C166.5 ${T} 177 ${T + 18} 176.5 ${T + 47}` +
		`C176 ${T + 68} 178.5 ${T + 84} 179.5 ${T + 101}C180.5 ${T + 116} 178.5 238 178.5 252Z`;

	const id = "hs" + React.useId().replace(/[^a-zA-Z0-9]/g, "");
	const clip = (name) => `url(#${id}${name})`;
	const ny = (p) => f(top + (cut - top) * p);
	const at = (u, p) => [f(x + u * NW), ny(p)];
	const cuticleAt = (u) => [f(x + u * NW), f(cut + c * 0.125 - ((u - 0.5) * 2) ** 2 * c * 1.125)];
	const [paint, paintShade, paintLight, shadeStrength] = NAIL_FINISHES[look] || NAIL_FINISHES.lacquer;
	const nh = cut - top;
	// fill-in regrowth crescent
	const gap = `M${x - 2} ${f(cut - c - 13)}C${x - 2} ${f(cut + c * 0.45 - 13)} ${x + NW + 2} ${f(cut + c * 0.45 - 13)} ${x + NW + 2} ${f(cut - c - 13)}`;
	// editorial repair stress fracture line
	const fracY = ny(0.42);
	const fracture = `M${f(x - 1)} ${f(fracY + 5)} L${f(x + NW * 0.42)} ${f(fracY - 2)} L${f(x + NW * 0.62)} ${f(fracY + 2)} L${f(x + NW + 1)} ${f(fracY - 5)}`;

	const lacquer = (
		<g>
			<path d={nail} fill={paint} />
			<g clipPath={clip("n")}>
				<NailArtLayer look={look} layer="in" at={at} cuticle={cuticleAt} w={NW} h={nh} id={id} shape={shape} />
				{/* dimensional C-curve shading across nail plate */}
				{look !== "bare" && <rect x={xl} y={f(top - 4)} width={f(xr - xl)} height={f(nh + 12)} fill={clip("ccurve")} />}
				{/* soft vertical gloss ribbon along lit left apex */}
				{look !== "bare" && (
					<path
						d={`M${f(x + NW * 0.22 + t * 0.4)} ${f(top + r + 3)} C${f(x + NW * 0.31 + t * 0.35)} ${f(top + r)} ${f(x + NW * 0.34)} ${f(ny(0.5))} ${f(x + NW * 0.29)} ${f(cut - c - 5)} C${f(x + NW * 0.23)} ${f(cut - c - 4)} ${f(x + NW * 0.18)} ${f(ny(0.5))} ${f(x + NW * 0.22 + t * 0.4)} ${f(top + r + 3)} Z`}
						fill={paintLight}
						fillOpacity={look === "cateye" || look === "chrome" ? ".45" : ".68"}
					/>
				)}
				{/* wet gel gloss band */}
				{look === "gel" && (
					<path
						d={`M${xl} ${ny(0.18)} Q${CX} ${ny(0.04)} ${xr} ${ny(0.2)} V${ny(0.34)} Q${CX} ${ny(0.18)} ${xl} ${ny(0.32)} Z`}
						fill="#fff"
						fillOpacity=".62"
					/>
				)}
				{/* fill-in bare nail regrowth bed */}
				{look === "fillin" && (
					<g>
						<path d={`${gap}V${cut + 10}H${xl}Z`} fill="var(--nail-bare)" />
						<path d={gap} fill="none" stroke="var(--on-paint)" strokeWidth="1.8" strokeOpacity=".55" transform="translate(0 -1.2)" />
						<path d={gap} fill="none" stroke="var(--art-ink)" strokeWidth="1.2" strokeOpacity=".55" />
					</g>
				)}
				{/* repair silk-wrap fracture */}
				{look === "repair" && (
					<g>
						<path d={fracture} fill="none" stroke="var(--on-paint)" strokeWidth="3.2" strokeOpacity=".6" strokeLinecap="round" />
						<path d={fracture} fill="none" stroke="var(--art-ink)" strokeWidth="1.45" strokeOpacity=".82" strokeLinecap="round" strokeLinejoin="round" />
						{/* translucent silk patch across fracture */}
						<rect x={f(x + 4)} y={f(fracY - 9)} width={f(NW - 8)} height="18" rx="3" fill="#fff" fillOpacity=".36" stroke="var(--on-paint)" strokeWidth=".8" strokeDasharray="3 2" />
					</g>
				)}
			</g>
			{/* Nail contour */}
			<path
				d={nail}
				fill="none"
				stroke="var(--art-ink)"
				strokeWidth="1.85"
				strokeLinejoin="round"
				strokeDasharray={look === "bare" ? "5 4" : undefined}
			/>
		</g>
	);

	return (
		<svg className="hand" viewBox={frame} preserveAspectRatio="xMidYMin slice" {...(label ? { role: "img", "aria-label": label } : { "aria-hidden": true })}>
			<defs>
				<clipPath id={id + "f"}><path d={finger} /></clipPath>
				<clipPath id={id + "n"}><path d={nail} /></clipPath>
				{/* Dimensional C-curve nail glaze */}
				<linearGradient id={id + "ccurve"} x1="0%" y1="0%" x2="100%" y2="0%">
					<stop offset="0%" style={{ stopColor: paintShade }} stopOpacity={f(shadeStrength * 0.25)} />
					<stop offset="28%" style={{ stopColor: paintLight }} stopOpacity=".22" />
					<stop offset="62%" style={{ stopColor: paintShade }} stopOpacity="0" />
					<stop offset="100%" style={{ stopColor: paintShade }} stopOpacity={f(shadeStrength * 0.72)} />
				</linearGradient>
				{look === "ombre" && (
					<linearGradient id={id + "ombre"} gradientUnits="userSpaceOnUse" x1="0" y1={f(top)} x2="0" y2={f(cut)}>
						<stop offset="0%" style={{ stopColor: "var(--paint-berry)" }} />
						<stop offset="28%" style={{ stopColor: "var(--lacquer-shade)" }} stopOpacity=".95" />
						<stop offset="58%" style={{ stopColor: "var(--lacquer-light)" }} stopOpacity=".75" />
						<stop offset="90%" style={{ stopColor: "var(--on-paint)" }} stopOpacity="0" />
					</linearGradient>
				)}
				{look === "airbrush" && (
					<radialGradient id={id + "aura"} gradientUnits="userSpaceOnUse" cx={CX} cy={ny(0.48)} r={f(NW * 0.76)}>
						<stop offset="0%" style={{ stopColor: "var(--paint-berry)" }} stopOpacity=".92" />
						<stop offset="38%" style={{ stopColor: "var(--lacquer)" }} stopOpacity=".8" />
						<stop offset="72%" style={{ stopColor: "var(--lacquer-light)" }} stopOpacity=".4" />
						<stop offset="100%" style={{ stopColor: "var(--on-paint)" }} stopOpacity="0" />
					</radialGradient>
				)}
				{look === "cateye" && (
					<>
						<linearGradient id={id + "catbase"} x1="0%" y1="0%" x2="100%" y2="100%">
							<stop offset="0%" style={{ stopColor: "var(--art-ink)" }} stopOpacity=".65" />
							<stop offset="50%" style={{ stopColor: "var(--paint-berry)" }} stopOpacity=".25" />
							<stop offset="100%" style={{ stopColor: "var(--art-ink)" }} stopOpacity=".78" />
						</linearGradient>
						<radialGradient id={id + "catglow"} cx="50%" cy="50%" r="52%">
							<stop offset="0%" style={{ stopColor: "var(--lacquer-light)" }} stopOpacity=".92" />
							<stop offset="45%" style={{ stopColor: "var(--lacquer)" }} stopOpacity=".58" />
							<stop offset="100%" style={{ stopColor: "var(--paint-berry)" }} stopOpacity="0" />
						</radialGradient>
					</>
				)}
				{look === "chrome" && (
					<linearGradient id={id + "chrome"} x1="0%" y1="0%" x2="100%" y2="100%">
						<stop offset="0%" style={{ stopColor: "var(--chrome-light)" }} />
						<stop offset="32%" style={{ stopColor: "var(--chrome)" }} />
						<stop offset="60%" style={{ stopColor: "var(--chrome-light)" }} />
						<stop offset="86%" style={{ stopColor: "var(--chrome-shade)" }} />
						<stop offset="100%" style={{ stopColor: "var(--chrome)" }} />
					</linearGradient>
				)}
			</defs>

			<PaintGround />

			<g className="hand-ruler">
				{marks.map((m) => {
					const y = T + 4 - m.ext;
					return (
						<g key={m.id} className={m.on ? "on" : undefined}>
							<line x1="18" x2="282" y1={y} y2={y} />
							<text x="18" y={y - 5}>{m.label}</text>
						</g>
					);
				})}
			</g>

			<g filter="url(#paint-hand)">
				<path d={finger} fill="var(--skin)" />
				<g clipPath={clip("f")}>
					{/* shade: the turned-away side, cut like paper */}
					<path d={`M168.5 ${T + 2}C175 ${T + 22} 170.5 ${T + 42} 172.5 ${T + 64}C174.5 ${T + 88} 169.5 ${T + 106} 171.5 ${T + 132}L184 ${T + 132}L184 ${T}Z`} fill="var(--skin-shade)" />
					{/* light: a long warm plane down the lit side */}
					<path d={`M127 ${T + 50}C127.6 ${T + 38} 131.8 ${T + 31} 134.4 ${T + 37}C132.2 ${T + 60} 135.2 ${T + 82} 133 ${T + 104}C131.8 ${T + 116} 133.4 ${T + 126} 132.6 ${T + 134}L125.4 ${T + 134}C124 ${T + 108} 126.4 ${T + 78} 127 ${T + 50}Z`} fill="var(--skin-light)" />
					{/* the fingertip catches it */}
					<path d={`M130.5 ${T + 27}C134.5 ${T + 12} 142 ${T + 6} 150.5 ${T + 6.5}C143.3 ${T + 10} 137.6 ${T + 16} 134.2 ${T + 30}C132.9 ${T + 33} 129.8 ${T + 31} 130.5 ${T + 27}Z`} fill="var(--skin-glint)" />
					{/* a cool reflected edge */}
					<path d={`M175.2 ${T + 58}C176.5 ${T + 78} 177.8 ${T + 92} 178.2 ${T + 116}`} fill="none" stroke="var(--skin-cool)" strokeWidth="2.6" strokeLinecap="round" strokeOpacity=".85" />
					{/* gestural marks */}
					<path d={`M138 ${T + 74}c2.2 9 1.4 18 2.8 27`} fill="none" stroke="var(--skin-glint)" strokeWidth="2.8" strokeLinecap="round" strokeOpacity=".8" />
					<path d={`M160.5 ${T + 70}c1.5 8 0 15 2.2 24`} fill="none" stroke="var(--skin-shade)" strokeWidth="3.2" strokeLinecap="round" strokeOpacity=".7" />
					{/* knuckle: two confident tapered marks */}
					<path d={`M132 ${T + 95}Q150 ${T + 106} 169 ${T + 95}Q150 ${T + 101.5} 132 ${T + 95}Z`} fill="var(--art-ink)" />
					<path d={`M135.5 ${T + 105.5}Q150 ${T + 114} 165.5 ${T + 105.5}Q150 ${T + 110.2} 135.5 ${T + 105.5}Z`} fill="var(--art-ink)" fillOpacity=".8" />
					{/* the nail sits in the skin: fold shadow around it */}
					<path d={nail} fill="none" stroke="var(--skin-shade)" strokeWidth="7" strokeOpacity=".9" />
				</g>
				<path d={finger} fill="none" stroke="var(--art-ink)" strokeWidth="2.1" strokeLinejoin="round" />
			</g>

			{/* Nail plate */}
			{lacquer}

			{/* Raised 3D nail art */}
			<NailArtLayer look={look} layer="over" at={at} cuticle={cuticleAt} w={NW} h={nh} id={id} shape={shape} />

			{/* Overlay: luminous sculpted translucent builder-gel cap rising subtly over the nail */}
			{look === "overlay" && (
				<g transform="translate(6 -11)">
					<path d={nail} fill="var(--chrome-light)" fillOpacity=".46" stroke="var(--art-ink)" strokeWidth="1.2" strokeOpacity=".6" strokeLinejoin="round" />
					<path d={`M${f(x + 7)} ${f(top + 7)} C${f(x + 10)} ${f(top + 5)} ${f(x + 12)} ${f(ny(0.5))} ${f(x + 9)} ${f(cut - 14)}`} fill="none" stroke="#fff" strokeWidth="2.4" strokeLinecap="round" strokeOpacity=".85" />
				</g>
			)}

			{/* Subtle crisp diamond light glints on glossy/reflective finishes */}
			{(look === "fullset" || look === "gel" || look === "chrome" || look === "bling" || look === "heartflame") && (
				<g fill="var(--on-paint)">
					<path d={sparkPath(CX + 30, top + 16, 7.5)} stroke="var(--art-ink)" strokeWidth=".7" strokeOpacity=".55" />
					<path d={sparkPath(CX - 30, top + 44, 4.4)} stroke="var(--art-ink)" strokeWidth=".6" strokeOpacity=".5" />
				</g>
			)}
		</svg>
	);
}

/* ---------- Service icons ---------- */
// TWIN: lib/config/site-config-schema.js#SERVICE_ICONS
// TWIN: public/admin/ui/menu-config.js#SERVICE_ICON_NAMES
const SERVICE_ICONS = { fullset: 56, fillin: 56, overlay: 6, repair: 44, gel: 10, plain: 30 };
function ServiceIcon({ kind }) {
	const look = SERVICE_ICONS[kind] === undefined ? "plain" : kind;
	return (
		<span className="svc-ico">
			<HandStage ext={SERVICE_ICONS[look]} look={look} shape={look === "gel" ? "round" : undefined} frame="95 50 110 131" label="" />
		</span>
	);
}

/* ---------- Nail art icons ---------- */
// TWIN: lib/config/site-config-schema.js#ART_ICONS
// TWIN: public/admin/ui/menu-config.js#ART_ICON_NAMES
const ART_ICONS = ["french", "frenchart", "cateye", "ombre", "charms", "chrome", "flowers", "character", "airbrush", "bling", "junk", "milkbath", "animal", "heartflame", "plain"];
function ArtIcon({ kind, shape }) {
	return (
		<span className="svc-ico art-ico">
			<HandStage ext={48} look={kind === "bare" || ART_ICONS.includes(kind) ? kind : "plain"} shape={shape} frame="104 56 92 110" label="" />
		</span>
	);
}

/* ---------- Shape icons ---------- */
// TWIN: lib/config/site-config-schema.js#SHAPE_ICONS
// TWIN: public/admin/ui/menu-config.js#SHAPE_ICON_NAMES
const SHAPE_ICONS = { square: 38, coffin: 46, almond: 46, stiletto: 56, round: 10, duck: 42 };
function ShapeIcon({ cut }) {
	const at = cut in SHAPE_ICONS ? cut : "square";
	return (
		<span className="svc-ico shape-ico">
			<HandStage ext={SHAPE_ICONS[at]} shape={at} frame="95 50 110 131" label="" />
		</span>
	);
}

/* ---------- Visit icons: editorial calendar card with 1 day (single) or 3 days (plan) ---------- */
const VISIT_DAYS = { cols: [38, 52, 66, 80], rows: [54, 67, 80], one: [[66, 67]], three: [[38, 54], [66, 67], [52, 80]] };
function VisitIcon({ count }) {
	const ticked = count === 1 ? VISIT_DAYS.one : VISIT_DAYS.three;
	const is = (x, y) => ticked.some(([tx, ty]) => tx === x && ty === y);
	const id = "vi" + React.useId().replace(/[^a-zA-Z0-9]/g, "");
	return (
		<span className="svc-ico visit-ico">
			<svg className="hand" viewBox="0 0 120 110" preserveAspectRatio="xMidYMid slice" aria-hidden="true">
				<PaintGround w={120} h={110} id={id} />
				{/* soft stationery shadow */}
				<rect x="27" y="25" width="70" height="70" rx="6" fill="var(--art-ink)" fillOpacity=".12" />
				{/* calendar card */}
				<rect x="25" y="22" width="70" height="70" rx="6" fill="var(--on-paint)" stroke="var(--art-ink)" strokeWidth="1.4" strokeOpacity=".78" />
				{/* top pink header strip */}
				<path d="M25.7 39 H94.3 V28 Q94.3 22.7 89 22.7 H31 Q25.7 22.7 25.7 28 Z" fill="var(--paint-ochre)" />
				<line x1="25" y1="39" x2="95" y2="39" stroke="var(--art-ink)" strokeWidth="1" strokeOpacity=".25" />
				{/* refined ring clasps */}
				<rect x="41.5" y="15" width="3.5" height="12" rx="1.75" fill="var(--art-ink)" fillOpacity=".82" />
				<rect x="75" y="15" width="3.5" height="12" rx="1.75" fill="var(--art-ink)" fillOpacity=".82" />
				{/* subtle calendar date dots */}
				{VISIT_DAYS.rows.map((y) => VISIT_DAYS.cols.map((x) => !is(x, y) && <circle key={x + "-" + y} cx={x} cy={y} r="1.9" fill="var(--art-ink)" fillOpacity=".32" />))}
				{/* ticked appointment circles */}
				{ticked.map(([x, y]) => (
					<g key={x + "-" + y}>
						<circle cx={x} cy={y + 0.8} r="7.4" fill="var(--art-ink)" fillOpacity=".14" />
						<circle cx={x} cy={y} r="7.4" fill="var(--lacquer)" stroke="var(--art-ink)" strokeWidth="1.15" strokeOpacity=".75" />
						<path d={`M${x - 3.2} ${y + 0.2} l2.2 2.4 4.4-5`} fill="none" stroke="#fff" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" />
					</g>
				))}
			</svg>
		</span>
	);
}

/* ---------- Toe icons: one big toe, close up, painted the same way ---------- */
// For the toes screen: sculpted acrylic is square and a touch long, gel is rounded with a wet shine,
// solid is the plain nail, french has the white free edge. One toe only, cropped close, the nail
// most of its width — the owner's call after trying a row of toes and a smaller nail.
// `art` paints a piece of nail art (one of ART_ICONS) on the toenail instead, for the toe art ladder,
// drawn as ArtIcon draws it on a finger but laid out for the short, wide nail of a big toe; "bare" is
// a toe built toe by toe that wears nothing yet, its nail bare and dashed. `base` cuts the nail as
// acrylic or gel under the art, for a toe built toe by toe.
const TOE_LOOKS = ["acrylic", "gel", "solid", "french"];
function ToeIcon({ kind, art, base }) {
	const pick = art === undefined ? null : art === "bare" || ART_ICONS.includes(art) ? art : "plain";
	const look = pick ? (pick === "french" || pick === "frenchart" || pick === "junk" ? "french" : "solid") : TOE_LOOKS.includes(kind) ? kind : "solid";
	const cut = TOE_LOOKS.slice(0, 2).includes(base) ? base : look;
	const acrylic = cut === "acrylic", gel = cut === "gel";
	const f = (n) => Math.round(n * 100) / 100;
	const id = "toe" + React.useId().replace(/[^a-zA-Z0-9]/g, "");
	const cx = 66, w = 96, tip = 24, x0 = cx - w / 2, x1 = cx + w / 2;
	// a toe is widest at the pad and rounds over at the tip
	const outline =
		`M${f(x0 + w * 0.05)} 176C${f(x0 - w * 0.02)} 152 ${f(x0 - w * 0.06)} ${f(tip + w * 0.86)} ${f(x0 - w * 0.02)} ${f(tip + w * 0.46)}` +
		`C${f(x0 + w * 0.03)} ${f(tip + w * 0.12)} ${f(x0 + w * 0.24)} ${tip} ${cx} ${tip}` +
		`C${f(x1 - w * 0.24)} ${tip} ${f(x1 - w * 0.03)} ${f(tip + w * 0.12)} ${f(x1 + w * 0.02)} ${f(tip + w * 0.46)}` +
		`C${f(x1 + w * 0.06)} ${f(tip + w * 0.86)} ${f(x1 + w * 0.02)} 152 ${f(x1 - w * 0.05)} 176`;
	const nw = w * 0.76, nh = nw * 0.86;
	const h = nh * (acrylic ? 1.1 : gel ? 0.88 : 1);
	const ny = tip + w * (acrylic ? 0.06 : gel ? 0.15 : 0.1), nx = cx - nw / 2;
	const r = gel ? nw * 0.3 : acrylic ? nw * 0.07 : nw * 0.13, c = nw * 0.26, flare = gel ? 0 : nw * 0.03;
	const nail =
		`M${f(nx)} ${f(ny + h - c)}C${f(nx)} ${f(ny + h + c * 0.5)} ${f(nx + nw)} ${f(ny + h + c * 0.5)} ${f(nx + nw)} ${f(ny + h - c)}` +
		`L${f(nx + nw + flare)} ${f(ny + r)}Q${f(nx + nw + flare)} ${f(ny)} ${f(nx + nw + flare - r)} ${f(ny)}` +
		`L${f(nx - flare + r)} ${f(ny)}Q${f(nx - flare)} ${f(ny)} ${f(nx - flare)} ${f(ny + r)}Z`;
	const crease = ny + h + w * 0.2;
	const at = (u, p) => [f(nx + u * nw), f(ny + h * p)];
	const cuticleAt = (u) => [f(nx + u * nw), f(ny + h + c * 0.125 - ((u - 0.5) * 2) ** 2 * c * 1.125)];
	const artLook = pick || (kind === "french" ? "french" : "lacquer");
	const [paint, paintShade, paintLight, shadeStrength] = NAIL_FINISHES[artLook] || NAIL_FINISHES.lacquer;

	return (
		<span className="svc-ico toe-ico">
			<svg className="hand" viewBox="16 12 100 119" preserveAspectRatio="xMidYMin slice" aria-hidden="true">
				<defs>
					<clipPath id={id + "t"}><path d={outline + "Z"} /></clipPath>
					<clipPath id={id + "n"}><path d={nail} /></clipPath>
					<linearGradient id={id + "ccurve"} x1="0%" y1="0%" x2="100%" y2="0%">
						<stop offset="0%" style={{ stopColor: paintShade }} stopOpacity={f(shadeStrength * 0.22)} />
						<stop offset="28%" style={{ stopColor: paintLight }} stopOpacity=".22" />
						<stop offset="62%" style={{ stopColor: paintShade }} stopOpacity="0" />
						<stop offset="100%" style={{ stopColor: paintShade }} stopOpacity={f(shadeStrength * 0.68)} />
					</linearGradient>
					{artLook === "ombre" && (
						<linearGradient id={id + "ombre"} gradientUnits="userSpaceOnUse" x1="0" y1={f(ny)} x2="0" y2={f(ny + h)}>
							<stop offset="0%" style={{ stopColor: "var(--paint-berry)" }} />
							<stop offset="30%" style={{ stopColor: "var(--lacquer-shade)" }} stopOpacity=".95" />
							<stop offset="60%" style={{ stopColor: "var(--lacquer-light)" }} stopOpacity=".72" />
							<stop offset="92%" style={{ stopColor: "var(--on-paint)" }} stopOpacity="0" />
						</linearGradient>
					)}
					{artLook === "airbrush" && (
						<radialGradient id={id + "aura"} gradientUnits="userSpaceOnUse" cx={cx} cy={f(ny + h * 0.48)} r={f(nw * 0.58)}>
							<stop offset="0%" style={{ stopColor: "var(--paint-berry)" }} stopOpacity=".92" />
							<stop offset="40%" style={{ stopColor: "var(--lacquer)" }} stopOpacity=".78" />
							<stop offset="72%" style={{ stopColor: "var(--lacquer-light)" }} stopOpacity=".38" />
							<stop offset="100%" style={{ stopColor: "var(--on-paint)" }} stopOpacity="0" />
						</radialGradient>
					)}
					{artLook === "cateye" && (
						<>
							<linearGradient id={id + "catbase"} x1="0%" y1="0%" x2="100%" y2="100%">
								<stop offset="0%" style={{ stopColor: "var(--art-ink)" }} stopOpacity=".65" />
								<stop offset="50%" style={{ stopColor: "var(--paint-berry)" }} stopOpacity=".25" />
								<stop offset="100%" style={{ stopColor: "var(--art-ink)" }} stopOpacity=".78" />
							</linearGradient>
							<radialGradient id={id + "catglow"} cx="50%" cy="50%" r="52%">
								<stop offset="0%" style={{ stopColor: "var(--lacquer-light)" }} stopOpacity=".92" />
								<stop offset="45%" style={{ stopColor: "var(--lacquer)" }} stopOpacity=".58" />
								<stop offset="100%" style={{ stopColor: "var(--paint-berry)" }} stopOpacity="0" />
							</radialGradient>
						</>
					)}
					{artLook === "chrome" && (
						<linearGradient id={id + "chrome"} x1="0%" y1="0%" x2="100%" y2="100%">
							<stop offset="0%" style={{ stopColor: "var(--chrome-light)" }} />
							<stop offset="32%" style={{ stopColor: "var(--chrome)" }} />
							<stop offset="60%" style={{ stopColor: "var(--chrome-light)" }} />
							<stop offset="86%" style={{ stopColor: "var(--chrome-shade)" }} />
							<stop offset="100%" style={{ stopColor: "var(--chrome)" }} />
						</linearGradient>
					)}
				</defs>
				<PaintGround w={132} h={157} />
				<g filter="url(#paint-hand)">
					<path d={outline + "Z"} fill="var(--skin)" />
					<g clipPath={`url(#${id}t)`}>
						{/* the turned side in shade, light down the other */}
						<path d={`M${f(x1 - w * 0.2)} ${tip - 4}C${f(x1 - w * 0.06)} ${f(tip + w * 0.3)} ${f(x1 - w * 0.12)} ${f(tip + w * 0.8)} ${f(x1 - w * 0.16)} 180H${f(x1 + w * 0.2)}V${tip - 4}Z`} fill="var(--skin-shade)" />
						<path d={`M${f(x0 + w * 0.1)} ${f(tip + w * 0.36)}C${f(x0 + w * 0.05)} ${f(tip + w * 0.7)} ${f(x0 + w * 0.1)} ${f(tip + w * 1.1)} ${f(x0 + w * 0.08)} 170`} fill="none" stroke="var(--skin-light)" strokeWidth={f(w * 0.075)} strokeLinecap="round" />
					</g>
					{/* the fold of skin the nail sits in, then the creases of the joint */}
					<path d={nail} fill="none" stroke="var(--skin-shade)" strokeWidth={f(w * 0.07)} strokeOpacity=".85" />
					<path d={`M${f(cx - w * 0.3)} ${f(crease)}Q${cx} ${f(crease + w * 0.1)} ${f(cx + w * 0.3)} ${f(crease)}`} fill="none" stroke="var(--art-ink)" strokeWidth="1.7" strokeLinecap="round" strokeOpacity=".75" />
					<path d={`M${f(cx - w * 0.22)} ${f(crease + w * 0.13)}Q${cx} ${f(crease + w * 0.2)} ${f(cx + w * 0.22)} ${f(crease + w * 0.13)}`} fill="none" stroke="var(--art-ink)" strokeWidth="1.4" strokeLinecap="round" strokeOpacity=".5" />
					<path d={outline} fill="none" stroke="var(--art-ink)" strokeWidth="2.2" strokeLinejoin="round" strokeLinecap="round" />
				</g>
				{/* the nail is the one hard, straight thing in the picture: no wobble on it */}
				<path d={nail} fill={paint} />
				<g clipPath={`url(#${id}n)`}>
					<NailArtLayer look={artLook} layer="in" at={at} cuticle={cuticleAt} w={nw} h={h} id={id} isToe />
					{artLook !== "bare" && <rect x={f(nx - 4)} y={f(ny - 4)} width={f(nw + 8)} height={f(h + 12)} fill={`url(#${id}ccurve)`} />}
					{artLook !== "bare" && (
						<path
							d={`M${f(nx + nw * 0.2)} ${f(ny + r + 2.5)} C${f(nx + nw * 0.28)} ${f(ny + r)} ${f(nx + nw * 0.3)} ${f(ny + h * 0.5)} ${f(nx + nw * 0.25)} ${f(ny + h - c - 2)} C${f(nx + nw * 0.19)} ${f(ny + h - c - 2)} ${f(nx + nw * 0.16)} ${f(ny + h * 0.5)} ${f(nx + nw * 0.2)} ${f(ny + r + 2.5)} Z`}
							fill={paintLight}
							fillOpacity={artLook === "cateye" || artLook === "chrome" ? ".42" : ".65"}
						/>
					)}
					{/* gel: curved wet gloss highlight */}
					{gel && (
						<g>
							<path
								d={`M${f(nx + nw * 0.1)} ${f(ny + h * 0.42)} C${f(nx + nw * 0.24)} ${f(ny + h * 0.14)} ${f(nx + nw * 0.56)} ${f(ny + h * 0.08)} ${f(nx + nw * 0.86)} ${f(ny + h * 0.22)} C${f(nx + nw * 0.58)} ${f(ny + h * 0.17)} ${f(nx + nw * 0.32)} ${f(ny + h * 0.26)} ${f(nx + nw * 0.16)} ${f(ny + h * 0.5)} Z`}
								fill="#fff"
								fillOpacity=".62"
							/>
							<ellipse cx={f(nx + nw * 0.72)} cy={f(ny + h * 0.34)} rx="4.6" ry="2.1" transform={`rotate(-18 ${f(nx + nw * 0.72)} ${f(ny + h * 0.34)})`} fill="#fff" fillOpacity=".46" />
						</g>
					)}
				</g>
				<path d={nail} fill="none" stroke="var(--art-ink)" strokeWidth="2" strokeLinejoin="round" strokeDasharray={artLook === "bare" ? "5 4" : undefined} />
				{/* Raised 3D toe art */}
				<NailArtLayer look={artLook} layer="over" at={at} cuticle={cuticleAt} w={nw} h={h} id={id} isToe />
				{(gel || artLook === "chrome" || artLook === "bling" || artLook === "heartflame") && (
					<g fill="var(--chrome-light)" stroke="var(--art-ink)" strokeWidth="1.1" strokeLinejoin="round">
						<path d={sparkPath(106, 23, 7)} />
						<path d={sparkPath(26, 27, 4)} />
					</g>
				)}
			</svg>
		</span>
	);
}

/* ---------- The wall: diffused atmospheric light washes behind the wide-screen column ---------- */
// Soft crossing ribbons & ambient blooms on a 1440 × 900 canvas, melted through a wide Gaussian
// blur so the left and right walls carry dreamy out-of-focus studio light rather than hard edges.
// [cx, cy, rx, ry, lean°, paint, opacity]
const WALL_PASSES = [
	[700, 470, 980, 155, -29, "var(--paint-rose)", 0.62],
	[745, 425, 960, 130, 27, "var(--paint-ochre)", 0.66],
	[1150, 190, 440, 270, -14, "var(--paint-clay)", 0.54],
	[265, 710, 460, 285, 16, "var(--paint-rose)", 0.5],
	[1240, 740, 380, 230, -22, "var(--paint-berry)", 0.22],
	[210, 180, 350, 210, 20, "var(--paint-ochre)", 0.38],
];
function WallArt() {
	const id = "wall" + React.useId().replace(/[^a-zA-Z0-9]/g, "");
	return (
		<div className="wall" aria-hidden="true">
			<svg viewBox="0 0 1440 900" preserveAspectRatio="xMidYMid slice">
				<defs>
					<filter id={id + "blur"} x="-40%" y="-40%" width="180%" height="180%" colorInterpolationFilters="sRGB">
						<feGaussianBlur stdDeviation="88" />
					</filter>
				</defs>
				<g filter={`url(#${id}blur)`}>
					{WALL_PASSES.map(([cx, cy, rx, ry, lean, paint, opacity], i) => (
						<ellipse
							key={i}
							cx={cx}
							cy={cy}
							rx={rx}
							ry={ry}
							fill={paint}
							fillOpacity={opacity}
							transform={`rotate(${lean} ${cx} ${cy})`}
							style={{ animationDelay: 0.1 + i * 0.14 + "s" }}
						/>
					))}
				</g>
			</svg>
		</div>
	);
}
