Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

114 KB
Raw Blame
<!doctype html>
<html lang="en">
	<head>
		<script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
		<meta charset="utf-8" />
		<title data-i18n="profile.meta_title">Agent Profile</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
		<meta name="description" content="On-chain agent identity profile."  data-i18n-attr="content:profile.meta_description"/>
		<meta name="theme-color" content="#000000" />
		<meta name="mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
		<meta name="apple-mobile-web-app-title" content="three.ws" />
		<link rel="icon" href="/favicon.ico" sizes="any" />
		<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
		<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
		<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
		<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
		<link rel="manifest" href="/manifest.webmanifest" />

		<link rel="stylesheet" href="/style.css" />
		<link rel="stylesheet" href="/footer.css" />
		<script defer src="/footer-newsletter.js"></script>
		<link rel="stylesheet" href="/fonts/fonts.css" />
		<script
			type="module"
			src="https://cdn.jsdelivr.net/npm/@google/[email protected]/dist/model-viewer.min.js"
			integrity="sha384-wjsPzEO+lXOf7d9csIDfAQpPt2OKuUU3m0K9qsdKIuzX4N8czSF6hdh23eAbZa3p"
			crossorigin="anonymous"
		></script>

		<meta property="og:type" content="profile" />
		<meta property="og:site_name" content="three.ws" />
		<meta property="og:url" content="" id="og-url" />
		<meta property="og:title" content="Agent Profile" id="og-title"  data-i18n-attr="content:profile.meta_og_title"/>
		<meta property="og:description" content="On-chain agent identity." id="og-description"  data-i18n-attr="content:profile.meta_og_description"/>
		<meta property="og:image" content="https://three.ws/og-image.png" id="og-image" />
		<meta property="og:image:width" content="1200" />
		<meta property="og:image:height" content="630" />
		<meta name="twitter:card" content="summary_large_image" />
		<meta name="twitter:title" content="Agent Profile" id="tw-title"  data-i18n-attr="content:profile.meta_twitter_title"/>
		<meta name="twitter:description" content="On-chain agent identity." id="tw-description"  data-i18n-attr="content:profile.meta_twitter_description"/>
		<meta name="twitter:image" content="https://three.ws/og-image.png" id="tw-image" />

		<style>
			body {
				overflow: auto;
				display: flex;
				flex-direction: column;
				min-height: 100vh;
			}

			.profile-page-header {
				display: flex;
				align-items: center;
				gap: 1rem;
				padding: 1rem 1.618rem;
				border-bottom: 1px solid rgba(255, 255, 255, 0.06);
				justify-content: space-between;
			}

			.profile-page-header a {
				color: rgba(255, 255, 255, 0.4);
				text-decoration: none;
				font-size: 0.764rem;
			}

			.profile-page-header a:hover {
				color: rgba(255, 255, 255, 0.8);
			}

			.profile-root {
				max-width: 960px;
				margin: 0 auto;
				padding: 2.5rem 1.5rem 5rem;
				width: 100%;
			}

			/* ── Hero ────────────────────────────────────────────────────────── */
			.up-hero {
				display: flex;
				align-items: center;
				gap: 1.5rem;
				margin-bottom: 2.5rem;
			}

			.up-avatar-ring {
				width: 72px;
				height: 72px;
				border-radius: 50%;
				border: 1px solid rgba(255, 255, 255, 0.12);
				background: radial-gradient(
					ellipse at center,
					rgba(255, 215, 0, 0.06) 0%,
					transparent 70%
				);
				display: flex;
				align-items: center;
				justify-content: center;
				flex-shrink: 0;
			}

			.up-avatar-glyph {
				font-size: 1.618rem;
				color: rgba(255, 215, 0, 0.5);
			}

			.up-address {
				font-size: 1.382rem;
				font-weight: 300;
				color: #e5e5e5;
				letter-spacing: -0.02em;
				margin: 0 0 0.25rem;
			}

			.up-muted {
				color: rgba(255, 255, 255, 0.3);
				font-size: 0.764rem;
				margin: 0;
				line-height: 1.5;
			}

			.up-full-address {
				font-family: monospace;
				font-size: 0.618rem;
				word-break: break-all;
			}

			/* ── Chain filter pills ───────────────────────────────────────────── */
			.up-chain-bar {
				display: flex;
				flex-wrap: wrap;
				gap: 0.382rem;
				margin-bottom: 1.618rem;
			}

			.up-chain-pill {
				background: transparent;
				border: 1px solid rgba(255, 255, 255, 0.1);
				color: rgba(255, 255, 255, 0.4);
				font-size: 0.618rem;
				padding: 0.25rem 0.618rem;
				border-radius: 999px;
				cursor: pointer;
				font-family: inherit;
				transition:
					color var(--duration-fast),
					border-color var(--duration-fast),
					background var(--duration-fast);
			}

			.up-chain-pill:hover {
				color: rgba(255, 255, 255, 0.8);
				border-color: rgba(255, 255, 255, 0.2);
			}

			.up-chain-pill--active {
				background: rgba(255, 215, 0, 0.1);
				border-color: rgba(255, 215, 0, 0.3);
				color: rgba(255, 215, 0, 0.9);
			}

			/* ── Agent grid ──────────────────────────────────────────────────── */
			.up-grid {
				display: grid;
				grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
				gap: 1rem;
			}

			.up-empty {
				color: rgba(255, 255, 255, 0.3);
				font-size: 0.85rem;
				grid-column: 1 / -1;
				text-align: center;
				padding: 3rem 0;
			}

			.up-empty a {
				color: rgba(255, 215, 0, 0.7);
				text-decoration: none;
			}

			.up-empty a:hover {
				color: #ffd700;
			}

			/* ── Card ────────────────────────────────────────────────────────── */
			.up-card {
				background: rgba(255, 255, 255, 0.02);
				border: 1px solid rgba(255, 255, 255, 0.07);
				border-radius: 12px;
				overflow: hidden;
				transition:
					border-color var(--duration-fast),
					background var(--duration-fast);
				display: flex;
				flex-direction: column;
			}

			.up-card:hover {
				border-color: rgba(255, 255, 255, 0.14);
				background: rgba(255, 255, 255, 0.04);
			}

			/* Card wrapper lets the prompt action float above the whole-card anchor. */
			.up-card-wrap {
				position: relative;
				display: flex;
				flex-direction: column;
			}
			.up-card-wrap .up-card {
				flex: 1;
			}
			.up-copy-prompt {
				position: absolute;
				top: 8px;
				right: 8px;
				z-index: 2;
				appearance: none;
				border: 1px solid rgba(255, 255, 255, 0.16);
				background: rgba(10, 10, 16, 0.72);
				color: rgba(255, 255, 255, 0.75);
				border-radius: 999px;
				padding: 4px 10px;
				font-size: 11px;
				cursor: pointer;
				opacity: 0;
				transition: opacity var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
			}
			.up-card-wrap:hover .up-copy-prompt,
			.up-copy-prompt:focus-visible {
				opacity: 1;
			}
			.up-copy-prompt:hover {
				color: #fff;
				border-color: rgba(255, 255, 255, 0.35);
			}
			@media (hover: none) {
				.up-copy-prompt {
					opacity: 1;
				}
			}

			.up-card-thumb-link {
				display: block;
				text-decoration: none;
			}

			.up-card-thumb {
				width: 100%;
				aspect-ratio: 1;
				background: radial-gradient(
					ellipse at center,
					rgba(255, 215, 0, 0.03) 0%,
					transparent 70%
				);
				overflow: hidden;
				position: relative;
			}

			.up-card-thumb-placeholder {
				width: 100%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 2.5rem;
				color: rgba(255, 255, 255, 0.08);
			}

			.up-card-body {
				padding: 0.75rem 0.875rem 0.875rem;
				display: flex;
				flex-direction: column;
				gap: 0.25rem;
				flex: 1;
			}

			.up-card-chain {
				font-size: 0.55rem;
				text-transform: uppercase;
				letter-spacing: 0.1em;
				color: rgba(255, 215, 0, 0.5);
				font-weight: 500;
			}

			.up-card-name {
				font-size: 0.875rem;
				font-weight: 500;
				color: rgba(255, 255, 255, 0.85);
				text-decoration: none;
				line-height: 1.3;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
				overflow: hidden;
			}

			.up-card-name:hover {
				color: #fff;
			}

			.up-card-desc {
				font-size: 0.618rem;
				color: rgba(255, 255, 255, 0.3);
				margin: 0;
				line-height: 1.5;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
				overflow: hidden;
			}

			.up-card-footer {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: auto;
				padding-top: 0.382rem;
			}

			.up-card-id {
				font-size: 0.55rem;
				font-family: monospace;
				color: rgba(255, 255, 255, 0.18);
			}

			.up-card-edit {
				font-size: 0.618rem;
				color: rgba(255, 215, 0, 0.4);
				text-decoration: none;
				transition: color var(--duration-fast);
			}

			.up-card-edit:hover {
				color: rgba(255, 215, 0, 0.8);
			}

			/* ── Error / loading ─────────────────────────────────────────────── */
			.up-error {
				text-align: center;
				color: rgba(255, 255, 255, 0.3);
				font-size: 0.85rem;
				padding: 4rem 1rem;
			}

			/* ── Claim handle (signed in, no username yet) ───────────────────── */
			.up-claim {
				max-width: 430px;
				margin: 0 auto;
				padding: 4rem 1rem;
				text-align: center;
			}
			.up-claim-title {
				font-size: 1.4rem;
				font-weight: 700;
				letter-spacing: -0.02em;
				margin: 0 0 0.75rem;
			}
			.up-claim-sub {
				color: rgba(255, 255, 255, 0.5);
				font-size: 0.9rem;
				line-height: 1.6;
				margin: 0 0 1.5rem;
			}
			.up-claim-url {
				color: rgba(255, 255, 255, 0.75);
				font-family: ui-monospace, 'SF Mono', Menlo, monospace;
				font-size: 0.85em;
				white-space: nowrap;
			}
			.up-claim-row {
				display: flex;
				align-items: center;
				justify-content: center;
				gap: 0.5rem;
			}
			.up-claim-at {
				color: rgba(255, 255, 255, 0.35);
				font-size: 1rem;
			}
			.up-claim-row input {
				background: rgba(255, 255, 255, 0.05);
				border: 1px solid rgba(255, 255, 255, 0.14);
				border-radius: 8px;
				padding: 0.55rem 0.75rem;
				color: #fff;
				font-size: 0.95rem;
				font-family: inherit;
				width: min(220px, 55vw);
				transition: border-color var(--duration-fast);
			}
			.up-claim-row input:focus {
				outline: none;
				border-color: #69e16f;
			}
			.up-claim-row button {
				background: #69e16f;
				color: #0a0c10;
				border: none;
				border-radius: 8px;
				padding: 0.55rem 1.1rem;
				font-size: 0.95rem;
				font-weight: 600;
				font-family: inherit;
				cursor: pointer;
				transition: opacity var(--duration-fast);
			}
			.up-claim-row button:hover {
				opacity: 0.88;
			}
			.up-claim-row button:focus-visible {
				outline: 2px solid #69e16f;
				outline-offset: 2px;
			}
			.up-claim-row button:disabled {
				opacity: 0.5;
				cursor: default;
			}
			.up-claim-err {
				color: #ff7a7a;
				font-size: 0.8rem;
				min-height: 1.1em;
				margin: 0.75rem 0 0;
			}
			.up-claim-hint {
				color: rgba(255, 255, 255, 0.3);
				font-size: 0.75rem;
				margin: 0.35rem 0 0;
			}
			.up-claim-hint a {
				color: rgba(255, 255, 255, 0.5);
			}

			/* ── Copy button ─────────────────────────────────────────────────── */
			.profile-copy-btn {
				background: transparent;
				border: 1px solid rgba(255, 255, 255, 0.1);
				color: rgba(255, 255, 255, 0.4);
				font-size: 0.618rem;
				padding: 0.25rem 0.618rem;
				border-radius: 6px;
				cursor: pointer;
				font-family: inherit;
				transition:
					color var(--duration-fast),
					border-color var(--duration-fast);
			}

			.profile-copy-btn:hover {
				color: rgba(255, 255, 255, 0.8);
				border-color: rgba(255, 255, 255, 0.2);
			}

			.profile-copy-btn.copied {
				color: var(--success);
				border-color: rgba(74, 222, 128, 0.3);
			}

			/* ── Rich profile (username) ─────────────────────────────────────── */
			.up-hero-rich {
				display: grid;
				grid-template-columns: 280px 1fr;
				gap: 2rem;
				align-items: center;
				margin-bottom: 2rem;
				padding-bottom: 2rem;
				border-bottom: 1px solid rgba(255, 255, 255, 0.06);
			}

			.up-hero-3d {
				width: 280px;
				height: 280px;
				border-radius: 16px;
				border: 1px solid rgba(255, 255, 255, 0.08);
				background:
					radial-gradient(ellipse at top, rgba(255, 215, 0, 0.05) 0%, transparent 60%),
					rgba(255, 255, 255, 0.015);
				overflow: hidden;
				position: relative;
			}

			.up-hero-3d model-viewer,
			.up-hero-3d img {
				width: 100%;
				height: 100%;
				object-fit: cover;
				--poster-color: transparent;
				background: transparent;
			}

			.up-hero-3d-empty {
				width: 100%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 4rem;
				color: rgba(255, 215, 0, 0.18);
			}

			.up-display-name {
				font-size: 2.236rem;
				font-weight: 300;
				color: #f5f5f5;
				letter-spacing: -0.025em;
				margin: 0 0 0.382rem;
				line-height: 1.05;
			}

			.up-handle {
				font-size: 0.875rem;
				color: rgba(255, 215, 0, 0.65);
				margin: 0 0 0.75rem;
				font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
			}

			.up-meta-line {
				display: flex;
				flex-wrap: wrap;
				gap: 0.5rem 1rem;
				font-size: 0.7rem;
				color: rgba(255, 255, 255, 0.4);
				margin: 0 0 0.875rem;
			}

			.up-meta-line a {
				color: rgba(255, 255, 255, 0.55);
				text-decoration: none;
				display: inline-flex;
				align-items: center;
				gap: 0.25rem;
			}

			.up-meta-line a:hover {
				color: #fff;
			}

			.up-meta-line svg {
				width: 12px;
				height: 12px;
			}

			.up-wallet-pill {
				display: inline-flex;
				align-items: center;
				gap: 0.382rem;
				background: rgba(255, 255, 255, 0.03);
				border: 1px solid rgba(255, 255, 255, 0.08);
				padding: 0.25rem 0.618rem;
				border-radius: 999px;
				font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
				font-size: 0.65rem;
				color: rgba(255, 255, 255, 0.55);
			}

			/* ── Stats strip ─────────────────────────────────────────────────── */
			.up-stats {
				display: grid;
				grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
				gap: 0;
				margin-bottom: 2rem;
				border: 1px solid rgba(255, 255, 255, 0.06);
				border-radius: 12px;
				overflow: hidden;
				background: rgba(255, 255, 255, 0.015);
			}

			.up-stat {
				padding: 0.875rem 1rem;
				border-right: 1px solid rgba(255, 255, 255, 0.05);
				text-align: center;
			}

			.up-stat:last-child {
				border-right: none;
			}

			.up-stat-num {
				display: block;
				font-size: 1.382rem;
				font-weight: 300;
				color: #f5f5f5;
				letter-spacing: -0.02em;
				line-height: 1.1;
				margin-bottom: 0.2rem;
			}

			.up-stat-label {
				font-size: 0.55rem;
				text-transform: uppercase;
				letter-spacing: 0.12em;
				color: rgba(255, 255, 255, 0.35);
			}

			/* ── Streak + badges ─────────────────────────────────────────────── */
			.up-streak-row {
				display: flex;
				flex-wrap: wrap;
				align-items: center;
				gap: 0.75rem;
				margin: -1.1rem 0 2rem;
			}

			.up-streak-pill {
				display: inline-flex;
				align-items: center;
				gap: 0.4rem;
				padding: 0.4rem 0.75rem;
				border: 1px solid rgba(255, 255, 255, 0.08);
				border-radius: 999px;
				background: rgba(255, 255, 255, 0.02);
				font-size: 0.72rem;
				font-weight: 500;
				color: rgba(255, 255, 255, 0.75);
			}

			.up-streak-pill .up-streak-flame {
				font-size: 0.85rem;
				line-height: 1;
			}

			.up-badge-chip {
				display: inline-flex;
				align-items: center;
				gap: 0.35rem;
				padding: 0.4rem 0.7rem;
				border: 1px solid rgba(255, 255, 255, 0.08);
				border-radius: 999px;
				background: rgba(255, 255, 255, 0.02);
				font-size: 0.72rem;
				font-weight: 500;
				color: rgba(255, 255, 255, 0.75);
				cursor: default;
				transition: border-color var(--duration-fast), background var(--duration-fast);
			}

			.up-badge-chip:hover {
				border-color: rgba(255, 255, 255, 0.2);
				background: rgba(255, 255, 255, 0.04);
			}

			/* ── Tabs ────────────────────────────────────────────────────────── */
			.up-tabs {
				display: flex;
				flex-wrap: wrap;
				gap: 0.25rem;
				margin-bottom: 1.5rem;
				border-bottom: 1px solid rgba(255, 255, 255, 0.06);
			}

			.up-tab {
				background: transparent;
				border: none;
				border-bottom: 2px solid transparent;
				color: rgba(255, 255, 255, 0.4);
				font-family: inherit;
				font-size: 0.764rem;
				padding: 0.618rem 1rem;
				cursor: pointer;
				transition:
					color var(--duration-fast),
					border-color var(--duration-fast);
				display: inline-flex;
				align-items: center;
				gap: 0.382rem;
				margin-bottom: -1px;
			}

			.up-tab:hover {
				color: rgba(255, 255, 255, 0.8);
			}

			.up-tab--active {
				color: #ffd700;
				border-bottom-color: rgba(255, 215, 0, 0.7);
			}

			.up-tab-badge {
				font-size: 0.55rem;
				background: rgba(255, 255, 255, 0.06);
				border-radius: 999px;
				padding: 0.1rem 0.5rem;
				color: rgba(255, 255, 255, 0.5);
				font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
			}

			.up-tab--active .up-tab-badge {
				background: rgba(255, 215, 0, 0.12);
				color: rgba(255, 215, 0, 0.85);
			}

			.up-section {
				display: block;
			}

			.up-section[hidden] {
				display: none;
			}

			/* ── Agent / widget / skill / plugin cards ───────────────────────── */
			.up-card-row {
				display: flex;
				gap: 0.875rem;
				padding: 0.875rem;
				background: rgba(255, 255, 255, 0.02);
				border: 1px solid rgba(255, 255, 255, 0.07);
				border-radius: 12px;
				transition:
					border-color var(--duration-fast),
					background var(--duration-fast);
				text-decoration: none;
				color: inherit;
			}

			.up-card-row:hover {
				border-color: rgba(255, 255, 255, 0.14);
				background: rgba(255, 255, 255, 0.04);
			}

			.up-card-row-thumb {
				width: 56px;
				height: 56px;
				flex-shrink: 0;
				border-radius: 50%;
				background: radial-gradient(
					ellipse at center,
					rgba(255, 215, 0, 0.06) 0%,
					transparent 70%
				);
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 1.5rem;
				color: rgba(255, 215, 0, 0.4);
				overflow: hidden;
			}

			.up-card-row-thumb img {
				width: 100%;
				height: 100%;
				object-fit: cover;
			}

			.up-card-row-body {
				flex: 1;
				min-width: 0;
				display: flex;
				flex-direction: column;
				gap: 0.25rem;
			}

			.up-card-row-head {
				display: flex;
				align-items: baseline;
				gap: 0.5rem;
				flex-wrap: wrap;
			}

			.up-card-row-name {
				font-size: 0.875rem;
				color: rgba(255, 255, 255, 0.92);
				margin: 0;
				font-weight: 500;
			}

			.up-card-row-desc {
				font-size: 0.7rem;
				color: rgba(255, 255, 255, 0.45);
				margin: 0;
				line-height: 1.5;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
				overflow: hidden;
			}

			.up-card-row-meta {
				display: flex;
				flex-wrap: wrap;
				gap: 0.5rem 0.875rem;
				font-size: 0.6rem;
				color: rgba(255, 255, 255, 0.3);
				margin-top: 0.25rem;
				font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
			}

			.up-card-row-meta a {
				color: rgba(154, 140, 255, 0.6);
				text-decoration: none;
			}

			.up-card-row-meta a:hover {
				color: rgba(154, 140, 255, 0.95);
			}

			.up-tag {
				display: inline-block;
				font-size: 0.55rem;
				padding: 0.1rem 0.5rem;
				border-radius: 999px;
				background: rgba(154, 140, 255, 0.08);
				color: rgba(154, 140, 255, 0.7);
				margin-right: 4px;
				font-family: inherit;
				letter-spacing: 0.02em;
			}

			.up-list {
				display: grid;
				gap: 0.618rem;
			}

			.up-list-cols-2 {
				grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
			}

			.up-card-row-pill {
				display: inline-flex;
				align-items: center;
				font-size: 0.55rem;
				padding: 0.15rem 0.5rem;
				border-radius: 999px;
				background: rgba(255, 215, 0, 0.08);
				color: rgba(255, 215, 0, 0.75);
				text-transform: uppercase;
				letter-spacing: 0.08em;
			}

			.up-loading-shimmer {
				background: linear-gradient(
					90deg,
					rgba(255, 255, 255, 0.02) 0%,
					rgba(255, 255, 255, 0.05) 50%,
					rgba(255, 255, 255, 0.02) 100%
				);
				background-size: 200% 100%;
				animation: up-shimmer 1.4s infinite;
				border-radius: 12px;
				height: 220px;
			}

			@keyframes up-shimmer {
				0% {
					background-position: 200% 0;
				}
				100% {
					background-position: -200% 0;
				}
			}

			@media (max-width: 720px) {
				.up-hero-rich {
					grid-template-columns: 1fr;
					gap: 1.5rem;
				}
				.up-hero-3d {
					width: 100%;
					max-width: 320px;
					height: 320px;
				}
				.up-display-name {
					font-size: 1.764rem;
				}
			}

			@media (max-width: 480px) {
				.up-hero {
					flex-direction: column;
					align-items: flex-start;
				}

				.up-grid {
					grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
				}

				.up-stat {
					padding: 0.618rem 0.5rem;
				}
				.up-stat-num {
					font-size: 1.1rem;
				}
			}

			/* ── Social: banner, bio, actions, edit + follow modals ─────────────── */
			.up-banner {
				width: 100%;
				height: 180px;
				border-radius: 16px;
				margin-bottom: -56px;
				background-size: cover;
				background-position: center;
				border: 1px solid rgba(255, 255, 255, 0.08);
			}
			.up-banner-pad { padding-top: 64px; }

			.up-pfp {
				width: 88px;
				height: 88px;
				border-radius: 50%;
				object-fit: cover;
				border: 3px solid var(--bg-0, #000);
				background: var(--bg-0);
				flex-shrink: 0;
			}

			.up-bio {
				color: rgba(255, 255, 255, 0.78);
				font-size: 0.95rem;
				line-height: 1.55;
				margin: 0.7rem 0 0;
				max-width: 52ch;
				white-space: pre-wrap;
			}
			.up-bio-meta {
				display: flex;
				flex-wrap: wrap;
				gap: 0.4rem 1rem;
				margin-top: 0.6rem;
				font-size: 0.82rem;
				color: rgba(255, 255, 255, 0.45);
			}
			.up-bio-meta a { color: #69b7ff; text-decoration: none; }
			.up-bio-meta a:hover { text-decoration: underline; }
			.up-bio-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }

			.up-actions {
				display: flex;
				gap: 0.5rem;
				margin-top: 0.9rem;
				flex-wrap: wrap;
			}
			.up-action-btn {
				display: inline-flex;
				align-items: center;
				gap: 0.4rem;
				font-family: inherit;
				font-size: 0.85rem;
				font-weight: 500;
				padding: 0.5rem 1.1rem;
				border-radius: 999px;
				cursor: pointer;
				border: 1px solid rgba(255, 255, 255, 0.18);
				background: transparent;
				color: rgba(255, 255, 255, 0.9);
				transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), opacity var(--duration-fast) var(--ease-standard);
			}
			.up-action-btn:hover { border-color: rgba(255, 255, 255, 0.4); }
			.up-action-btn--primary {
				background: #fff;
				color: #000;
				border-color: #fff;
			}
			.up-action-btn--primary:hover { opacity: 0.85; }
			.up-action-btn--following {
				background: transparent;
				color: rgba(255, 255, 255, 0.9);
			}
			.up-action-btn--following:hover {
				border-color: #ff6b6b;
				color: #ff6b6b;
			}
			.up-action-btn--following:hover .up-follow-label::after { content: 'Unfollow'; }
			.up-action-btn--following:hover .up-follow-label { font-size: 0; }
			.up-action-btn--following:hover .up-follow-label::after { font-size: 0.85rem; }
			.up-action-btn[disabled] { opacity: 0.5; cursor: default; }

			.up-stat--link { cursor: pointer; background: none; border: 0; font-family: inherit; }
			.up-stat--link:hover .up-stat-num { color: #fff; }

			/* Modals (edit + follow lists) */
			.up-modal-backdrop {
				position: fixed;
				inset: 0;
				background: rgba(0, 0, 0, 0.7);
				backdrop-filter: blur(6px);
				display: flex;
				align-items: center;
				justify-content: center;
				z-index: 9999;
				padding: 1rem;
			}
			.up-modal {
				background: var(--bg-0, #0a0a0a);
				border: 1px solid rgba(255, 255, 255, 0.12);
				border-radius: 16px;
				width: 100%;
				max-width: 460px;
				max-height: 85vh;
				overflow-y: auto;
				color: rgba(255, 255, 255, 0.95);
				animation: up-modal-in 0.2s ease both;
			}
			@keyframes up-modal-in {
				from { opacity: 0; transform: translateY(10px) scale(0.98); }
				to { opacity: 1; transform: none; }
			}
			.up-modal-head {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 1.2rem 1.4rem;
				border-bottom: 1px solid rgba(255, 255, 255, 0.08);
				position: sticky;
				top: 0;
				background: var(--bg-0, #0a0a0a);
			}
			.up-modal-head h3 { margin: 0; font-weight: 500; font-size: 1.05rem; }
			.up-modal-close {
				background: transparent;
				border: 0;
				color: rgba(255, 255, 255, 0.5);
				font-size: 1.5rem;
				line-height: 1;
				cursor: pointer;
			}
			.up-modal-close:hover { color: #fff; }
			.up-modal-body { padding: 1.4rem; }

			.up-field { margin-bottom: 1.1rem; }
			.up-field label {
				display: block;
				font-size: 0.8rem;
				color: rgba(255, 255, 255, 0.55);
				margin-bottom: 0.4rem;
			}
			.up-field input,
			.up-field textarea {
				width: 100%;
				background: #000;
				color: #fff;
				border: 1px solid rgba(255, 255, 255, 0.14);
				border-radius: 9px;
				padding: 0.65rem 0.85rem;
				font-size: 0.92rem;
				font-family: inherit;
				box-sizing: border-box;
				transition: border-color var(--duration-fast) var(--ease-standard);
			}
			.up-field input:focus,
			.up-field textarea:focus {
				outline: none;
				border-color: rgba(255, 255, 255, 0.4);
			}
			.up-field textarea { resize: vertical; min-height: 80px; }
			.up-field-count { float: right; font-size: 0.72rem; color: rgba(255, 255, 255, 0.35); }
			.up-modal-error {
				color: #ff7a7a;
				font-size: 0.82rem;
				min-height: 1.2em;
				margin-bottom: 0.6rem;
			}
			.up-modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; }

			.up-follow-row {
				display: flex;
				align-items: center;
				gap: 0.75rem;
				padding: 0.7rem 0;
				border-bottom: 1px solid rgba(255, 255, 255, 0.06);
			}
			.up-follow-row:last-child { border-bottom: 0; }
			.up-follow-pfp {
				width: 40px;
				height: 40px;
				border-radius: 50%;
				object-fit: cover;
				background: rgba(255, 255, 255, 0.06);
				border: 1px solid rgba(255, 255, 255, 0.1);
				display: flex;
				align-items: center;
				justify-content: center;
				color: rgba(255, 255, 255, 0.4);
				text-decoration: none;
				flex-shrink: 0;
				overflow: hidden;
			}
			.up-follow-pfp img { width: 100%; height: 100%; object-fit: cover; }
			.up-follow-info { flex: 1; min-width: 0; }
			.up-follow-name { color: #fff; text-decoration: none; font-weight: 500; font-size: 0.9rem; }
			.up-follow-name:hover { text-decoration: underline; }
			.up-follow-handle { color: rgba(255, 255, 255, 0.4); font-size: 0.8rem; }
			.up-follow-mini {
				font-family: inherit;
				font-size: 0.78rem;
				font-weight: 500;
				padding: 0.35rem 0.85rem;
				border-radius: 999px;
				border: 1px solid rgba(255, 255, 255, 0.2);
				background: transparent;
				color: #fff;
				cursor: pointer;
				flex-shrink: 0;
			}
			.up-follow-mini[data-following="true"] { color: rgba(255, 255, 255, 0.55); }
			.up-follow-mini:hover { border-color: rgba(255, 255, 255, 0.45); }

			/* ── Wallets row ─────────────────────────────────────────────────── */
			.up-wallets {
				display: flex;
				flex-wrap: wrap;
				gap: 0.45rem;
				margin: 0.6rem 0 0;
			}
			.up-wallet-chip {
				display: inline-flex;
				align-items: center;
				gap: 0.4rem;
				background: rgba(255, 255, 255, 0.03);
				border: 1px solid rgba(255, 255, 255, 0.09);
				border-radius: 999px;
				padding: 0.3rem 0.4rem 0.3rem 0.7rem;
				font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
				font-size: 0.68rem;
				color: rgba(255, 255, 255, 0.6);
				transition: border-color var(--duration-fast), background var(--duration-fast);
			}
			.up-wallet-chip:hover { border-color: rgba(255, 255, 255, 0.2); }
			.up-wallet-chip .up-chain-dot {
				width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
			}
			.up-wallet-chip[data-chain="solana"] .up-chain-dot { background: #14f195; }
			.up-wallet-chip[data-chain="evm"] .up-chain-dot { background: #627eea; }
			.up-wallet-chip a { color: inherit; text-decoration: none; }
			.up-wallet-chip a:hover { color: #fff; }
			.up-wallet-copy, .up-wallet-link {
				background: transparent;
				border: 0;
				color: rgba(255, 255, 255, 0.35);
				cursor: pointer;
				padding: 0.15rem;
				display: inline-flex;
				border-radius: 5px;
				transition: color var(--duration-fast), background var(--duration-fast);
			}
			.up-wallet-copy:hover, .up-wallet-link:hover {
				color: #fff;
				background: rgba(255, 255, 255, 0.08);
			}
			.up-wallet-copy.copied { color: var(--success); }

			/* ── NFT grid ────────────────────────────────────────────────────── */
			.up-nft-grid {
				display: grid;
				grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
				gap: 1rem;
			}
			.up-nft-card {
				background: rgba(255, 255, 255, 0.02);
				border: 1px solid rgba(255, 255, 255, 0.07);
				border-radius: 12px;
				overflow: hidden;
				display: flex;
				flex-direction: column;
				text-decoration: none;
				color: inherit;
				transition: border-color var(--duration-fast), transform var(--duration-fast);
			}
			.up-nft-card:hover { border-color: rgba(255, 255, 255, 0.16); transform: translateY(-2px); }
			.up-nft-media {
				aspect-ratio: 1;
				background: radial-gradient(ellipse at center, rgba(255, 215, 0, 0.04), transparent 70%);
				position: relative;
				overflow: hidden;
			}
			.up-nft-media img, .up-nft-media model-viewer {
				width: 100%; height: 100%; object-fit: cover; background: transparent;
				--poster-color: transparent;
			}
			.up-nft-badge {
				position: absolute;
				top: 0.5rem;
				right: 0.5rem;
				font-size: 0.5rem;
				text-transform: uppercase;
				letter-spacing: 0.1em;
				padding: 0.15rem 0.45rem;
				border-radius: 999px;
				background: rgba(0, 0, 0, 0.55);
				backdrop-filter: blur(4px);
				color: #ffd700;
				border: 1px solid rgba(255, 215, 0, 0.3);
			}
			.up-nft-chain {
				position: absolute;
				top: 0.5rem;
				left: 0.5rem;
				width: 9px; height: 9px; border-radius: 50%;
				box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.4);
			}
			.up-nft-chain[data-chain="solana"] { background: #14f195; }
			.up-nft-chain[data-chain="evm"] { background: #627eea; }
			.up-nft-body { padding: 0.6rem 0.7rem 0.7rem; }
			.up-nft-name {
				font-size: 0.78rem;
				color: rgba(255, 255, 255, 0.9);
				margin: 0;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.up-nft-coll {
				font-size: 0.6rem;
				color: rgba(255, 255, 255, 0.35);
				margin: 0.15rem 0 0;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}

			/* ── Accessories grid ────────────────────────────────────────────── */
			.up-acc-grid {
				display: grid;
				grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
				gap: 0.875rem;
			}
			.up-acc-card {
				background: rgba(255, 255, 255, 0.02);
				border: 1px solid rgba(255, 255, 255, 0.07);
				border-radius: 12px;
				overflow: hidden;
				text-align: center;
			}
			.up-acc-thumb {
				aspect-ratio: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				background: radial-gradient(ellipse at center, rgba(154, 140, 255, 0.06), transparent 70%);
			}
			.up-acc-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 0.6rem; box-sizing: border-box; }
			.up-acc-thumb-empty { font-size: 2rem; color: rgba(154, 140, 255, 0.4); }
			.up-acc-body { padding: 0.5rem 0.6rem 0.7rem; }
			.up-acc-name { font-size: 0.74rem; color: rgba(255, 255, 255, 0.85); margin: 0 0 0.3rem; }
			.up-rarity {
				display: inline-block;
				font-size: 0.5rem;
				text-transform: uppercase;
				letter-spacing: 0.08em;
				padding: 0.12rem 0.45rem;
				border-radius: 999px;
			}
			.up-rarity[data-rarity="common"] { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.6); }
			.up-rarity[data-rarity="rare"] { background: rgba(105,183,255,0.12); color: #69b7ff; }
			.up-rarity[data-rarity="epic"] { background: rgba(186,104,255,0.14); color: #ba68ff; }
			.up-rarity[data-rarity="legendary"] { background: rgba(255,196,0,0.14); color: #ffc400; }

			/* ── Fork button on avatar cards ─────────────────────────────────── */
			.up-card-actions {
				display: flex;
				align-items: center;
				justify-content: space-between;
				gap: 0.5rem;
				padding-top: 0.4rem;
			}
			.up-fork-btn {
				display: inline-flex;
				align-items: center;
				gap: 0.3rem;
				background: transparent;
				border: 1px solid rgba(255, 255, 255, 0.14);
				color: rgba(255, 255, 255, 0.6);
				font-family: inherit;
				font-size: 0.6rem;
				padding: 0.22rem 0.55rem;
				border-radius: 999px;
				cursor: pointer;
				transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast);
			}
			.up-fork-btn:hover { border-color: rgba(154, 140, 255, 0.5); color: #9a8cff; }
			.up-fork-btn[disabled] { opacity: 0.5; cursor: default; }
			.up-fork-count {
				font-size: 0.55rem;
				font-family: ui-monospace, Menlo, monospace;
				color: rgba(255, 255, 255, 0.3);
			}

			/* ── Fork action on agent rows ───────────────────────────────────── */
			.up-card-row-wrap { display: flex; flex-direction: column; }
			.up-agent-fork-bar {
				display: flex;
				align-items: center;
				gap: 0.6rem;
				padding: 0.4rem 0.25rem 0;
			}
			.up-agent-fork-btn {
				display: inline-flex;
				align-items: center;
				gap: 0.3rem;
				background: transparent;
				border: 1px solid rgba(255, 255, 255, 0.14);
				color: rgba(255, 255, 255, 0.6);
				font-family: inherit;
				font-size: 0.6rem;
				padding: 0.22rem 0.55rem;
				border-radius: 999px;
				cursor: pointer;
				transition: border-color var(--duration-fast), color var(--duration-fast), background var(--duration-fast);
			}
			.up-agent-fork-btn:hover { border-color: rgba(154, 140, 255, 0.5); color: #9a8cff; }
			.up-agent-fork-btn[disabled] { opacity: 0.5; cursor: default; }

			/* ── Share menu ──────────────────────────────────────────────────── */
			.profile-share-wrap { position: relative; }
			.profile-share-menu {
				position: absolute;
				top: calc(100% + 0.4rem);
				right: 0;
				background: var(--bg-0, #0a0a0a);
				border: 1px solid rgba(255, 255, 255, 0.12);
				border-radius: 12px;
				padding: 0.4rem;
				min-width: 200px;
				z-index: 50;
				box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
				animation: up-modal-in 0.15s ease both;
			}
			.profile-share-menu[hidden] { display: none; }
			.profile-share-item {
				display: flex;
				align-items: center;
				gap: 0.6rem;
				width: 100%;
				background: transparent;
				border: 0;
				color: rgba(255, 255, 255, 0.85);
				font-family: inherit;
				font-size: 0.8rem;
				padding: 0.55rem 0.6rem;
				border-radius: 8px;
				cursor: pointer;
				text-align: left;
				text-decoration: none;
				transition: background var(--duration-fast);
			}
			.profile-share-item:hover { background: rgba(255, 255, 255, 0.06); }
			.profile-share-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.75; }

			/* ── Toast ───────────────────────────────────────────────────────── */
			.up-toast {
				position: fixed;
				left: 50%;
				bottom: 2rem;
				transform: translateX(-50%) translateY(1rem);
				background: rgba(20, 20, 20, 0.96);
				border: 1px solid rgba(255, 255, 255, 0.14);
				color: #fff;
				padding: 0.7rem 1.1rem;
				border-radius: 999px;
				font-size: 0.85rem;
				z-index: 10000;
				opacity: 0;
				transition: opacity var(--duration-base) var(--ease-standard), transform var(--duration-base) var(--ease-standard);
				box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
				display: flex;
				align-items: center;
				gap: 0.5rem;
			}
			.up-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
			.up-toast a { color: #9a8cff; text-decoration: none; }
			.up-toast--ok { border-color: rgba(74, 222, 128, 0.4); }
			.up-toast--err { border-color: rgba(255, 122, 122, 0.5); }
		</style>
		<link rel="stylesheet" href="/nav.css" />
		<link rel="stylesheet" href="/mobile.css" />
		<script src="/model-viewer-meshopt.js"></script>
	</head>
	<body>
		<header><div id="nav-container"></div></header>
		<script src="/nav.js"></script>

		<header class="profile-page-header">
			<a href="/" aria-label="Back to three.ws home" data-i18n="profile.three_ws" data-i18n-attr="aria-label:profile.back_to_three_ws_home_arialabel">← three.ws</a>
			<div class="profile-share-wrap">
				<button class="profile-copy-btn" id="share-profile-btn" aria-label="Share profile" aria-haspopup="true" aria-expanded="false" data-i18n="profile.share" data-i18n-attr="aria-label:profile.share_profile_arialabel">
					share ↗
				</button>
				<div class="profile-share-menu" id="share-menu" role="menu" hidden></div>
			</div>
		</header>

		<main>
			<div class="profile-root" id="profile-root">
				<div class="up-error">Loading profile…</div>
			</div>
		</main>

		<footer class="h-footer-horizon">
			<div class="h-footer-glow-line" aria-hidden="true"></div>
			<div class="h-footer-floor" aria-hidden="true"></div>
			<div class="h-footer-haze" aria-hidden="true"></div>
			<div class="h-footer-watermark" aria-hidden="true">three.ws</div>
			<div class="h-footer-avatar" aria-hidden="true">
				<model-viewer
					src="/animations/robotexpressive.glb"
					auto-rotate
					auto-rotate-delay="0"
					rotation-per-second="20deg"
					interaction-prompt="none"
					camera-controls="false"
					disable-zoom
					shadow-intensity="0"
					exposure="0.7"
					environment-image="neutral"
					camera-orbit="0deg 80deg 9m"
					field-of-view="35deg"
					loading="lazy"
				></model-viewer>
			</div>
			<div class="h-footer-cta">
				<div class="h-footer-newsletter">
					<h3 data-i18n="profile.stay_in_the_loop">Stay in the loop</h3>
					<p data-i18n="profile.get_updates_on_new_features_agent_tooling">Get updates on new features, agent tooling, and protocol changes.</p>
					<form class="h-footer-newsletter-form" data-newsletter-form novalidate>
						<input
							type="email"
							class="h-footer-newsletter-input"
							name="email"
							placeholder="Enter your email"
							aria-label="Email address"
							autocomplete="email"
							required
						/>
						<button
							type="submit"
							class="h-footer-newsletter-btn"
							aria-label="Subscribe"
						 data-i18n-attr="aria-label:profile.subscribe_arialabel">
							<svg viewBox="0 0 16 16" aria-hidden="true">
								<path
									fill="none"
									stroke="currentColor"
									stroke-width="1.6"
									stroke-linecap="round"
									stroke-linejoin="round"
									d="M2 8h11m0 0L9 4m4 4l-4 4"
								/>
							</svg>
						</button>
					</form>
					<p class="h-footer-newsletter-msg" data-newsletter-msg aria-live="polite"></p>
				</div>
				<div class="h-footer-community">
					<h3 data-i18n="profile.join_the_community">Join the community</h3>
					<p data-i18n="profile.follow_along_for_builds_demos_and_conversati">Follow along for builds, demos, and conversations with the team.</p>
					<a
						class="h-footer-community-btn"
						href="https://x.com/trythreews"
						target="_blank"
						rel="noopener"
					>
						<svg viewBox="0 0 24 24" aria-hidden="true">
							<path
								fill="currentColor"
								d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"
							/>
						</svg>
						Follow on X
					</a>
				</div>
			</div>
			<div class="h-footer-inner">
				<div class="h-footer-brand-col">
					<div class="h-footer-brand">
						<img class="wordmark-logo" src="/three.svg" alt="" aria-hidden="true" />
						<span class="wordmark-dot" aria-hidden="true"></span>
						<span data-i18n="profile.three_ws_2">three.ws</span>
					</div>
					<p class="h-footer-tagline" data-i18n="profile.give_your_ai_a_body">Give your AI a body.</p>
					<div class="h-footer-socials">
						<a
							class="h-footer-social"
							href="https://x.com/trythreews"
							target="_blank"
							rel="noopener"
							aria-label="three.ws on X"
						 data-i18n-attr="aria-label:profile.three_ws_on_x_arialabel">
							<svg viewBox="0 0 24 24" aria-hidden="true">
								<path
									fill="currentColor"
									d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"
								/>
							</svg>
						</a>
						<a
							class="h-footer-social"
							href="https://github.com/nirholas/three.ws"
							target="_blank"
							rel="noopener"
							aria-label="three.ws on GitHub"
						 data-i18n-attr="aria-label:profile.three_ws_on_github_arialabel">
							<svg viewBox="0 0 16 16" aria-hidden="true">
								<path
									fill="currentColor"
									d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"
								/>
							</svg>
						</a>
					</div>
				</div>
				<nav class="h-footer-links" aria-label="Footer">
					<div class="h-footer-link-col">
						<h4 class="h-footer-link-heading" data-i18n="profile.product">Product</h4>
						<a href="/create" data-i18n="profile.create">Create</a>
						<a href="/studio" data-i18n="profile.studio">Studio</a>
						<a href="/widgets" data-i18n="profile.widgets">Widgets</a>
						<a href="/discover" data-i18n="profile.discover">Discover</a>
					</div>
					<div class="h-footer-link-col">
						<h4 class="h-footer-link-heading" data-i18n="profile.developers">Developers</h4>
						<a href="/docs" data-i18n="profile.docs">Docs</a>
						<a
							href="https://github.com/nirholas/three.ws"
							target="_blank"
							rel="noopener"
							 data-i18n="profile.github">GitHub</a
						>
						<a
							href="https://eips.ethereum.org/EIPS/eip-8004"
							target="_blank"
							rel="noopener"
							 data-i18n="profile.erc_8004">ERC-8004</a
						>
					</div>
					<div class="h-footer-link-col">
						<h4 class="h-footer-link-heading" data-i18n="profile.resources">Resources</h4>
						<a href="/blog" data-i18n="profile.blog">Blog</a>
						<a href="/dashboard" data-i18n="profile.dashboard">Dashboard</a>
					</div>
				</nav>
			</div>
			<div class="h-footer-bottom">
				<p class="h-footer-legal" data-i18n="profile.2026_three_ws_all_rights_reserved">© 2026 three.ws — All rights reserved.</p>
				<div class="h-footer-legal-links">
					<a href="/legal/privacy" data-i18n="profile.privacy_policy">Privacy Policy</a>
					<a href="/legal/tos" data-i18n="profile.terms_of_use">Terms of Use</a>
				</div>
			</div>
		</footer>

		<script type="module">
			import { mountUserProfile } from '/src/erc8004/user-profile.js';
			import { onchainBadgeHTML } from '/src/shared/onchain-badge.js';
			import { apiFetch } from '/src/api.js';
			import { mountProfileWalkHero } from '/src/profile-walk-hero.js';

			const esc = (s) =>
				String(s ?? '').replace(
					/[&<>"']/g,
					(c) =>
						({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[
							c
						],
				);
			const attr = (s) =>
				String(s ?? '').replace(
					/[&<>"']/g,
					(c) =>
						({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
				);

			const segments = location.pathname.split('/').filter(Boolean);
			const slug = segments[1]; // /u/<slug>

			const root = document.getElementById('profile-root');
			const shareBtn = document.getElementById('share-profile-btn');
			const shareMenu = document.getElementById('share-menu');

			if (!slug) {
				// Bare /profile: resolve the signed-in user and show their own profile.
				root.innerHTML = `<div class="up-loading-shimmer"></div>`;
				fetch('/api/auth/me', { credentials: 'include' })
					.then((r) => (r.ok ? r.json() : null))
					.then((j) => {
						const me = j?.user || null;
						if (me?.username) {
							location.replace(`/u/${encodeURIComponent(me.username)}`);
						} else if (me) {
							// Signed in, but usernames are claimed after signup, so the
							// /u/<handle> URL doesn't exist yet. Claim it right here
							// instead of dead-ending at a sign-in wall.
							renderClaimHandle(root, me);
						} else {
							root.innerHTML = `<div class="up-error">Sign in to view your profile. <a href="/login?next=%2Fprofile" style="color:#69e16f">Sign in →</a></div>`;
						}
					})
					.catch(() => {
						root.innerHTML = `<div class="up-error">Couldn't check who's signed in. <a href="/profile" style="color:#69e16f">Retry →</a></div>`;
					});
			} else if (/^0x[0-9a-fA-F]{40}$/.test(slug)) {
				// Legacy: on-chain wallet address profile
				const short = slug.slice(0, 6) + '…' + slug.slice(-4);
				document.title = `${short} — Agents`;
				const profileUrl = `${location.origin}/u/${slug}`;
				document.querySelector('#og-title')?.setAttribute('content', `${short} — Agents`);
				document
					.querySelector('#og-description')
					?.setAttribute('content', `On-chain agent identity profile for ${slug}`);
				document.querySelector('#og-url')?.setAttribute('content', profileUrl);
				document.querySelector('#tw-title')?.setAttribute('content', `${short} — Agents`);
				document
					.querySelector('#tw-description')
					?.setAttribute('content', `On-chain agent identity profile for ${slug}`);
				mountUserProfile(root, slug).catch((err) => {
					root.innerHTML = `<div class="up-error">Could not load profile: ${esc(err.message)}</div>`;
				});
			} else {
				// Username-based profile
				mountUsernameProfile(root, slug).catch((err) => {
					root.innerHTML = `<div class="up-error">Could not load profile: ${esc(err.message)}</div>`;
				});
			}

			// Signed-in users without a username have no /u/<handle> URL yet.
			// Claiming one here mirrors the editor in /dashboard/account
			// (PATCH /api/auth/profile, username settable but never clearable).
			function renderClaimHandle(rootEl, me) {
				const USERNAME_RE = /^[a-zA-Z0-9_-]{3,30}$/;
				const seed = (me.display_name || (me.email || '').split('@')[0] || '')
					.toLowerCase()
					.replace(/[^a-z0-9_-]+/g, '-')
					.replace(/^[-_]+|[-_]+$/g, '')
					.slice(0, 30);
				const suggestion = USERNAME_RE.test(seed) ? seed : '';
				document.title = 'Claim your handle · three.ws';
				rootEl.innerHTML = `
					<div class="up-claim">
						<h1 class="up-claim-title">Claim your handle</h1>
						<p class="up-claim-sub">You're signed in. Your creator profile just needs a public name: everything you make shows up at <span class="up-claim-url">three.ws/u/<span id="claim-preview">${esc(suggestion || 'yourname')}</span></span></p>
						<form class="up-claim-row" id="claim-form">
							<span class="up-claim-at" aria-hidden="true">@</span>
							<input id="claim-input" type="text" value="${attr(suggestion)}" maxlength="30" placeholder="username" autocapitalize="off" autocomplete="off" autocorrect="off" spellcheck="false" aria-label="Username" />
							<button type="submit" id="claim-save">Claim</button>
						</form>
						<p class="up-claim-err" id="claim-err" role="alert"></p>
						<p class="up-claim-hint">3 to 30 characters. Letters, numbers, _ or - only. You can change it later in <a href="/dashboard/account">account settings</a>.</p>
					</div>`;
				const input = rootEl.querySelector('#claim-input');
				const btn = rootEl.querySelector('#claim-save');
				const errEl = rootEl.querySelector('#claim-err');
				const preview = rootEl.querySelector('#claim-preview');
				input.addEventListener('input', () => {
					preview.textContent = input.value.trim() || 'yourname';
					errEl.textContent = '';
				});
				input.focus();
				rootEl.querySelector('#claim-form').addEventListener('submit', async (e) => {
					e.preventDefault();
					const next = input.value.trim();
					if (!USERNAME_RE.test(next)) {
						errEl.textContent = '3 to 30 characters, using letters, numbers, _ or - only.';
						return;
					}
					btn.disabled = true;
					btn.textContent = 'Claiming…';
					try {
						const r = await apiFetch('/api/auth/profile', {
							method: 'PATCH',
							credentials: 'include',
							headers: { 'content-type': 'application/json' },
							body: JSON.stringify({ username: next }),
						});
						const j = await r.json().catch(() => ({}));
						if (!r.ok) {
							errEl.textContent =
								r.status === 409
									? 'That username is already taken. Try another.'
									: j.error_description || j.issues?.[0]?.message || 'Could not save. Try again.';
							btn.disabled = false;
							btn.textContent = 'Claim';
							return;
						}
						location.replace(`/u/${encodeURIComponent(j.user?.username || next)}`);
					} catch {
						errEl.textContent = 'Network error. Check your connection and try again.';
						btn.disabled = false;
						btn.textContent = 'Claim';
					}
				});
			}

			async function mountUsernameProfile(rootEl, username) {
				rootEl.innerHTML = `<div class="up-loading-shimmer"></div>`;

				const res = await fetch(`/api/users/${encodeURIComponent(username)}`);
				if (!res.ok) {
					const data = await res.json().catch(() => ({}));
					const msg =
						res.status === 404
							? 'User not found.'
							: data.error_description || res.statusText;
					rootEl.innerHTML = `<div class="up-error">${esc(msg)}</div>`;
					return;
				}
				const data = await res.json();
				const {
					user,
					stats = {},
					streak = { currentStreak: 0, longestStreak: 0, lastActiveDay: null },
					badges = [],
					social = {},
					avatars = [],
					agents = [],
					widgets = [],
					skills = [],
					plugins = [],
					coins = [],
					memories = [],
					shop = [],
					creations = [],
					creationsNext = null,
				} = data;

				// Who's viewing? Drives the owner-only Edit button vs the Follow button.
				const viewer = await fetch('/api/auth/me', { credentials: 'include' })
					.then((r) => (r.ok ? r.json() : null))
					.then((j) => j?.user || null)
					.catch(() => null);
				const isOwner = Boolean(viewer && user.id && viewer.id === user.id);

				// Follow state (only meaningful for a signed-in non-owner viewer).
				let followState = { following: false, followed_by: false };
				if (viewer && !isOwner) {
					followState = await fetch(
						`/api/users/${encodeURIComponent(user.username)}/follow`,
						{ credentials: 'include' },
					)
						.then((r) => (r.ok ? r.json() : null))
						.then((j) => j || followState)
						.catch(() => followState);
				}

				// Update page meta
				const display = user.display_name || user.username;
				const title = `@${user.username} — three.ws`;
				const summaryParts = [];
				if (stats.avatars)
					summaryParts.push(`${stats.avatars} avatar${stats.avatars === 1 ? '' : 's'}`);
				if (stats.agents)
					summaryParts.push(`${stats.agents} agent${stats.agents === 1 ? '' : 's'}`);
				if (stats.widgets)
					summaryParts.push(`${stats.widgets} widget${stats.widgets === 1 ? '' : 's'}`);
				if (stats.skills)
					summaryParts.push(`${stats.skills} skill${stats.skills === 1 ? '' : 's'}`);
				const desc = `${display} on three.ws — ${summaryParts.join(' · ') || 'on-chain agent identity'}.`;
				document.title = title;
				const profileUrl = `${location.origin}/u/${encodeURIComponent(user.username)}`;
				const ogImage = `${location.origin}/api/u-og?username=${encodeURIComponent(user.username)}`;
				document.querySelector('#og-title')?.setAttribute('content', title);
				document.querySelector('#og-description')?.setAttribute('content', desc);
				document.querySelector('#og-url')?.setAttribute('content', profileUrl);
				document.querySelector('#og-image')?.setAttribute('content', ogImage);
				document.querySelector('#tw-title')?.setAttribute('content', title);
				document.querySelector('#tw-description')?.setAttribute('content', desc);
				document.querySelector('#tw-image')?.setAttribute('content', ogImage);

				// Hero 3D
				const heroAvatar = avatars.find((a) => a.model_url) || null;
				const heroMedia = heroAvatar
					? `<model-viewer
						src="${attr(heroAvatar.model_url)}"
						alt="${attr(heroAvatar.name)}"
						auto-rotate
						auto-rotate-delay="0"
						rotation-per-second="18deg"
						interaction-prompt="none"
						camera-controls
						disable-zoom
						shadow-intensity="0.6"
						exposure="0.95"
						environment-image="neutral"
						loading="lazy"
					></model-viewer>`
					: heroAvatar?.thumbnail_url
						? `<img src="${attr(heroAvatar.thumbnail_url)}" alt="${attr(heroAvatar?.name || display)}">`
						: `<div class="up-hero-3d-empty">◎</div>`;

				// Meta line: location + website + joined date + social
				const metaBits = [];
				if (user.location) {
					metaBits.push(`<span>
						<svg width="11" height="11" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0a5 5 0 0 0-5 5c0 3.5 5 11 5 11s5-7.5 5-11a5 5 0 0 0-5-5m0 7a2 2 0 1 1 0-4 2 2 0 0 1 0 4"/></svg>
						${esc(user.location)}
					</span>`);
				}
				if (user.website) {
					let host = user.website;
					try { host = new URL(user.website).host.replace(/^www\./, ''); } catch {}
					metaBits.push(`<a href="${attr(user.website)}" target="_blank" rel="noopener nofollow">
						<svg width="11" height="11" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M6.9 11.1 5.5 9.7a1 1 0 0 0-.3.2l-1 1a2 2 0 1 1-2.8-2.8l1-1a2 2 0 0 1 2.8 0 1 1 0 0 0 1.4-1.4 4 4 0 0 0-5.6 0l-1 1a4 4 0 0 0 5.6 5.6l1-1a1 1 0 0 0 .3-.8zm7.7-9.7a4 4 0 0 0-5.6 0l-1 1a1 1 0 0 0 1.4 1.4l1-1a2 2 0 0 1 2.8 2.8l-1 1a2 2 0 0 1-2.8 0 1 1 0 0 0-1.4 1.4 4 4 0 0 0 5.6 0l1-1a4 4 0 0 0 0-5.6z"/></svg>
						${esc(host)}
					</a>`);
				}
				if (user.created_at) {
					const joined = new Date(user.created_at);
					metaBits.push(
						`Joined ${joined.toLocaleDateString(undefined, { month: 'long', year: 'numeric' })}`,
					);
				}
				if (social.twitter || social.x) {
					const x = social.twitter || social.x;
					metaBits.push(`<a href="https://x.com/${attr(x)}" target="_blank" rel="noopener">
						<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
						@${esc(x)}
					</a>`);
				}
				if (social.farcaster) {
					metaBits.push(
						`<a href="https://warpcast.com/${attr(social.farcaster)}" target="_blank" rel="noopener">@${esc(social.farcaster)} on Farcaster</a>`,
					);
				}

				const walletPill = user.wallet_address
					? `<span class="up-wallet-pill" title="${attr(user.wallet_address)}">
						<svg width="10" height="10" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M2 4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v1H2zm0 2h12v6a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2zm9 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2"/></svg>
						${esc(user.wallet_address.slice(0, 6))}…${esc(user.wallet_address.slice(-4))}
					</span>`
					: '';

				// SNS subdomain pill + pay-by-name button. Look up
				// `<username>.threews.sol`; if claimed, badge it as a verified
				// on-chain handle and surface the pay-by-name action. If unclaimed
				// AND the visitor owns this profile, surface a claim CTA instead.
				const snsPillSlot = `<span id="up-sns-pill"></span><span id="up-pay-slot"></span>`;
				(async () => {
					try {
						const snsRes = await fetch(
							`/api/threews/subdomain?label=${encodeURIComponent(user.username)}`,
						);

						if (snsRes.ok) {
							const j = await snsRes.json();
							const d = j?.data;
							if (d?.claim && d.claim.username === user.username) {
								const pill = document.getElementById('up-sns-pill');
								if (pill) {
									pill.outerHTML = `<a class="up-wallet-pill" style="text-decoration:none" href="https://www.sns.id/domain?domain=${attr(d.full)}" target="_blank" rel="noopener" title="${attr(d.full)}">
										<svg width="10" height="10" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M8 0l2.39 4.84L16 5.92l-4 3.9L13 16l-5-2.63L3 16l1-6.18L0 5.92l5.61-1.08z"/></svg>
										${esc(d.full)}
									</a>`;
								}
								const paySlot = document.getElementById('up-pay-slot');
								if (paySlot) {
									paySlot.outerHTML = `<button class="up-wallet-pill" id="up-pay-btn" style="cursor:pointer;border:0;font-family:inherit" data-name="${attr(d.full)}" data-handle="${attr(user.username)}">
										Pay @${esc(user.username)} in USDC
									</button>`;
									document
										.getElementById('up-pay-btn')
										?.addEventListener('click', () =>
											openPayModal(d.full, user.username),
										);
								}
								return;
							}
						}

						// Unclaimed. If visitor is the profile owner, show a claim CTA.
						if (isOwner) {
							const pill = document.getElementById('up-sns-pill');
							if (pill) {
								pill.outerHTML = `<a class="up-wallet-pill" style="text-decoration:none;background:rgba(105,225,111,.08);border-color:rgba(105,225,111,.35);color:#69e16f" href="/threews/claim" title="Claim ${attr(user.username)}.threews.sol">
									Claim ${esc(user.username)}.threews.sol →
								</a>`;
							}
						}
					} catch {}
				})();

				function openPayModal(name, handle) {
					// Remove any open modal first.
					document.getElementById('up-pay-modal')?.remove();
					const modal = document.createElement('div');
					modal.id = 'up-pay-modal';
					modal.setAttribute('role', 'dialog');
					modal.setAttribute('aria-modal', 'true');
					modal.style.cssText =
						'position:fixed;inset:0;background:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:9999;padding:1rem;backdrop-filter:blur(6px)';
					modal.innerHTML = `
						<div class="up-pay-card" style="background:var(--bg-0);border:1px solid rgba(255,255,255,.1);border-radius:14px;padding:1.5rem;max-width:420px;width:100%;color:rgba(255,255,255,.95)">
							<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:.4rem">
								<h3 style="margin:0;font-weight:500;font-size:1.1rem">Pay @${esc(handle)}</h3>
								<button id="up-pay-close" aria-label="Close" style="background:transparent;border:0;color:rgba(255,255,255,.5);font-size:1.4rem;cursor:pointer;line-height:1;padding:0">×</button>
							</div>
							<p style="color:rgba(255,255,255,.5);font-size:.85rem;margin:0 0 1.2rem">Sending USDC to <code style="background:rgba(255,255,255,.06);padding:.1em .4em;border-radius:4px">${esc(name)}</code> on Solana. Resolved on-chain; signed in your wallet.</p>
							<label style="display:block;font-size:.85rem;color:rgba(255,255,255,.5);margin-bottom:.4rem">Amount (USDC)</label>
							<input id="up-pay-amount" type="number" min="0.000001" step="0.01" value="1" style="width:100%;background:#000;color:#fff;border:1px solid rgba(255,255,255,.12);border-radius:8px;padding:.7rem .9rem;font-size:1rem;font-family:inherit;margin-bottom:1rem;box-sizing:border-box">
							<div id="up-pay-status" style="min-height:1.2em;font-size:.85rem;color:rgba(255,255,255,.5);margin-bottom:.8rem"></div>
							<button id="up-pay-go" style="width:100%;background:#fff;color:#000;border:0;border-radius:10px;padding:.85rem;font-size:1rem;font-weight:500;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:.5rem">
								<svg width="14" height="14" viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M21.93 7.5a1 1 0 0 0-.86-.5h-3.07a1 1 0 0 1-1-1V3a1 1 0 0 0-.5-.86 1 1 0 0 0-1 0L3.5 9.86A1 1 0 0 0 3 10.73v2.54a1 1 0 0 0 .5.86l12 7.73a1 1 0 0 0 .5.14 1 1 0 0 0 .5-.14 1 1 0 0 0 .5-.86V18a1 1 0 0 1 1-1h3.07a1 1 0 0 0 .86-.5 1 1 0 0 0 0-1z"/></svg>
								Pay with Solana wallet
							</button>
							<div id="up-pay-result" style="display:none;margin-top:1rem;padding:1rem;border:1px solid rgba(105,225,111,.3);background:rgba(105,225,111,.05);border-radius:10px;font-size:.85rem"></div>
						</div>
					`;
					document.body.appendChild(modal);
					const close = () => modal.remove();
					modal.addEventListener('click', (e) => {
						if (e.target === modal) close();
					});
					modal.querySelector('#up-pay-close').addEventListener('click', close);
					document.addEventListener('keydown', function onPayEscKey(e) {
						if (e.key === 'Escape') {
							close();
							document.removeEventListener('keydown', onPayEscKey);
						}
					});

					const goBtn = modal.querySelector('#up-pay-go');
					const statusEl = modal.querySelector('#up-pay-status');
					const resultEl = modal.querySelector('#up-pay-result');
					goBtn.addEventListener('click', async () => {
						const amount = Number(modal.querySelector('#up-pay-amount').value);
						if (!Number.isFinite(amount) || amount <= 0) {
							statusEl.textContent = 'Enter a positive USDC amount.';
							statusEl.style.color = '#ff7a7a';
							return;
						}
						goBtn.disabled = true;
						statusEl.style.color = 'rgba(255,255,255,.5)';
						try {
							const { payByName } = await import('/src/sns/pay-by-name.js');
							const result = await payByName({
								name,
								amount,
								onStatus: (s) => {
									statusEl.textContent = s;
								},
							});
							statusEl.textContent = '';
							resultEl.style.display = 'block';
							resultEl.innerHTML = `
								<div style="font-weight:500;color:#69e16f;margin-bottom:.4em">Payment sent.</div>
								<div style="color:rgba(255,255,255,.7);line-height:1.5">
									<strong>${esc(String(result.amount_usdc))} USDC</strong> → <code style="background:rgba(255,255,255,.06);padding:.1em .4em;border-radius:4px">${esc(result.recipient.resolved)}</code>
								</div>
								<a href="${esc(result.explorer)}" target="_blank" rel="noopener" style="display:inline-block;margin-top:.5em;color:#69e16f;text-decoration:none;font-family:ui-monospace,Menlo,monospace;font-size:.75rem;word-break:break-all">
									${esc(result.signature.slice(0, 16))}…${esc(result.signature.slice(-8))} ↗
								</a>
							`;
						} catch (err) {
							statusEl.style.color = '#ff7a7a';
							if (err?.code === 'no_wallet') {
								statusEl.innerHTML =
									'Install <a href="https://phantom.app/" target="_blank" rel="noopener" style="color:#ab9ff2">Phantom</a> or another Solana wallet, then retry.';
							} else if (err?.code === 'confirm_timeout' && err.signature) {
								statusEl.innerHTML = `Submitted but not confirmed in window. <a href="https://solscan.io/tx/${encodeURIComponent(err.signature)}" target="_blank" rel="noopener" style="color:#69e16f">Check Solscan ↗</a>`;
							} else {
								statusEl.textContent = err?.message || 'Payment failed.';
							}
							goBtn.disabled = false;
						}
					});
				}

				// Stats strip. Followers/Following lead and are clickable (open the
				// social list modal); the rest are static creation counts.
				const followStats = [
					['followers', 'Followers'],
					['following', 'Following'],
				]
					.map(
						([key, label]) => `
					<button class="up-stat up-stat--link" type="button" data-follows="${key}">
						<span class="up-stat-num">${formatStat(stats[key] || 0)}</span>
						<span class="up-stat-label">${label}</span>
					</button>
				`,
					)
					.join('');

				const statDefs = [
					['creations', 'Creations'],
					['avatars', 'Avatars'],
					['agents', 'Agents'],
					['widgets', 'Widgets'],
					['skills', 'Skills'],
					['plugins', 'Plugins'],
					['coins', 'Coins'],
					['memories', 'Memories'],
					['shop', 'For Sale'],
				];
				if (stats.widget_views > 0) statDefs.push(['widget_views', 'Widget Views']);
				const statsHtml =
					followStats +
					statDefs
						.filter(([key]) => stats[key] > 0)
						.map(
							([key, label]) => `
					<div class="up-stat">
						<span class="up-stat-num">${formatStat(stats[key] || 0)}</span>
						<span class="up-stat-label">${label}</span>
					</div>
				`,
						)
						.join('');

				// Streak + earned badges — a real earned-record row, never a
				// synthetic trophy. Hidden entirely for a user with no streak and no
				// badges yet, rather than showing an empty "0-day streak" ghost.
				const streakHtml = (() => {
					const days = streak.currentStreak || 0;
					const badgeChips = badges
						.map(
							(b) => `
						<span class="up-badge-chip" title="${attr(b.description || '')}">
							<span aria-hidden="true">${esc(b.icon || '★')}</span> ${esc(b.label || b.code)}
						</span>
					`,
						)
						.join('');
					if (!days && !badgeChips) return '';
					const streakPill = days
						? `<span class="up-streak-pill"><span class="up-streak-flame" aria-hidden="true">🔥</span> ${days}-day streak</span>`
						: '';
					return `<div class="up-streak-row">${streakPill}${badgeChips}</div>`;
				})();

				// Tabs: only show those with content; default to first non-empty
				const tabs = [
					{ key: 'creations', label: 'Creations', count: stats.creations || creations.length },
					{ key: 'avatars', label: 'Avatars', count: avatars.length },
					{ key: 'agents', label: 'Agents', count: agents.length },
					{ key: 'widgets', label: 'Widgets', count: widgets.length },
					{ key: 'skills', label: 'Skills', count: skills.length },
					{ key: 'plugins', label: 'Plugins', count: plugins.length },
					{ key: 'shop', label: 'For sale', count: shop.length },
					{ key: 'coins', label: 'Coins', count: coins.length },
					{ key: 'memories', label: 'Memories', count: memories.length },
				];
				const visibleTabs = tabs.filter((t) => t.count > 0);
				const defaultTab = visibleTabs[0]?.key || 'avatars';

				// Tab bar is always present (with an id) so the lazily-loaded NFT and
				// Accessories tabs can be appended once /collectibles resolves. It is
				// hidden whenever fewer than two tabs are ultimately visible.
				const tabBar = `<div class="up-tabs" id="up-tab-bar" role="tablist"${visibleTabs.length > 1 ? '' : ' hidden'}>
						${visibleTabs
							.map(
								(t) => `
							<button class="up-tab${t.key === defaultTab ? ' up-tab--active' : ''}" role="tab" data-tab="${t.key}" aria-selected="${t.key === defaultTab}">
								${esc(t.label)}
								<span class="up-tab-badge">${t.count}</span>
							</button>
						`,
							)
							.join('')}
					</div>`;

				// Banner + profile picture + bio + actions
				const bannerHtml = user.banner_url
					? `<div class="up-banner" style="background-image:url('${attr(user.banner_url)}')"></div>`
					: '';
				const pfpHtml = user.avatar_url
					? `<img class="up-pfp" src="${attr(user.avatar_url)}" alt="${attr(display)}" referrerpolicy="no-referrer">`
					: '';
				const bioHtml = user.bio ? `<p class="up-bio">${esc(user.bio)}</p>` : '';

				const followLabel = followState.following
					? 'Following'
					: followState.followed_by
						? 'Follow back'
						: 'Follow';
				let actionsHtml = '';
				if (isOwner) {
					actionsHtml = `
						<button class="up-action-btn" id="up-edit-btn" type="button">
							<svg width="13" height="13" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M11.5 1.5a2.1 2.1 0 0 1 3 3L6 13l-4 1 1-4z"/></svg>
							Edit profile
						</button>
						<a class="up-action-btn" href="/feed">Your feed</a>`;
				} else if (viewer) {
					actionsHtml = `<button class="up-action-btn ${followState.following ? 'up-action-btn--following' : 'up-action-btn--primary'}" id="up-follow-btn" type="button" data-following="${followState.following}">
						<span class="up-follow-label">${esc(followLabel)}</span>
					</button>`;
				} else {
					actionsHtml = `<a class="up-action-btn up-action-btn--primary" href="/login?return=${encodeURIComponent('/u/' + user.username)}">Follow</a>`;
				}

				rootEl.innerHTML = `
					${bannerHtml}
					<div class="up-hero-rich${user.banner_url ? ' up-banner-pad' : ''}">
						<div class="up-hero-3d">${heroMedia}</div>
						<div class="up-hero-info">
							${pfpHtml}
							<h1 class="up-display-name">${esc(display)}</h1>
							<p class="up-handle">@${esc(user.username)}</p>
							${bioHtml}
							${metaBits.length ? `<div class="up-bio-meta">${metaBits.join('')}</div>` : ''}
							<div class="up-actions">${actionsHtml}</div>
							<div class="up-pill-row" style="display:flex;flex-wrap:wrap;gap:.4rem;align-items:center;margin-top:.6rem">
								${walletPill}
								${snsPillSlot}
							</div>
							<div class="up-wallets" id="up-wallets"></div>
						</div>
					</div>
					<div id="up-walk-hero"></div>
					<div class="up-stats">${statsHtml}</div>
					${streakHtml}
					${tabBar}
					<section class="up-section" data-section="creations"${defaultTab === 'creations' ? '' : ' hidden'}>
						${renderCreationsGrid(creations)}
					</section>
					<section class="up-section" data-section="avatars"${defaultTab === 'avatars' ? '' : ' hidden'}>
						${renderAvatarsGrid(avatars)}
					</section>
					<section class="up-section" data-section="agents"${defaultTab === 'agents' ? '' : ' hidden'}>
						${renderAgentsList(agents)}
					</section>
					<section class="up-section" data-section="widgets"${defaultTab === 'widgets' ? '' : ' hidden'}>
						${renderWidgetsList(widgets)}
					</section>
					<section class="up-section" data-section="skills"${defaultTab === 'skills' ? '' : ' hidden'}>
						${renderSkillsList(skills)}
					</section>
					<section class="up-section" data-section="plugins"${defaultTab === 'plugins' ? '' : ' hidden'}>
						${renderPluginsList(plugins)}
					</section>
					<section class="up-section" data-section="coins"${defaultTab === 'coins' ? '' : ' hidden'}>
						${renderCoinsGrid(coins)}
					</section>
					<section class="up-section" data-section="memories"${defaultTab === 'memories' ? '' : ' hidden'}>
						${renderMemoriesList(memories)}
					</section>
					<section class="up-section" data-section="shop"${defaultTab === 'shop' ? '' : ' hidden'}>
						${renderShopGrid(shop)}
					</section>
					<section class="up-section" data-section="nfts" hidden>
						<div id="up-nfts-body"></div>
					</section>
					<section class="up-section" data-section="accessories" hidden>
						<div id="up-accessories-body"></div>
					</section>
				`;

				wireCreationsPagination(rootEl, user.username, creationsNext);

				// Tab switching — delegated so lazily-added NFT/Accessories tabs work.
				const tabBarEl = rootEl.querySelector('#up-tab-bar');
				function activateTab(key) {
					rootEl.querySelectorAll('.up-tab').forEach((b) => {
						const active = b.dataset.tab === key;
						b.classList.toggle('up-tab--active', active);
						b.setAttribute('aria-selected', active ? 'true' : 'false');
					});
					rootEl.querySelectorAll('.up-section').forEach((s) => {
						s.hidden = s.dataset.section !== key;
					});
				}
				tabBarEl?.addEventListener('click', (e) => {
					const btn = e.target.closest('.up-tab');
					if (btn) activateTab(btn.dataset.tab);
				});

				// Copy a creation's generating prompt straight off its card.
				rootEl.addEventListener('click', async (e) => {
					const copyBtn = e.target.closest('[data-copy-prompt]');
					if (!copyBtn) return;
					e.preventDefault();
					const prompt = copyBtn.dataset.copyPrompt;
					if (!prompt) return;
					try {
						await navigator.clipboard.writeText(prompt);
						const prev = copyBtn.textContent;
						copyBtn.textContent = 'Copied!';
						setTimeout(() => {
							copyBtn.textContent = prev;
						}, 1200);
					} catch {
						// Clipboard blocked: open the composer prefilled instead.
						window.open(`/create/prompt?prompt=${encodeURIComponent(prompt)}`, '_blank', 'noopener');
					}
				});

				// Fork an avatar (clones the GLB + its agent + a fresh wallet into the
				// viewer's namespace). Signed-out viewers are routed to login first.
				rootEl.addEventListener('click', async (e) => {
					const btn = e.target.closest('.up-fork-btn');
					if (!btn) return;
					e.preventDefault();
					if (!viewer) {
						location.href = `/login?return=${encodeURIComponent('/u/' + user.username)}`;
						return;
					}
					const avatarId = btn.dataset.avatar;
					btn.disabled = true;
					const label = btn.querySelector('.up-fork-label');
					const prev = label ? label.textContent : '';
					if (label) label.textContent = 'Forking…';
					try {
						const r = await apiFetch('/api/avatars/fork', {
							method: 'POST',
							credentials: 'include',
							headers: { 'content-type': 'application/json' },
							body: JSON.stringify({ source_avatar_id: avatarId }),
						});
						const j = await r.json().catch(() => ({}));
						if (!r.ok) throw new Error(j.error_description || 'Fork failed');
						const newId = j.avatar?.id || j.id;
						showToast(
							newId
								? `Forked. <a href="/avatars/${esc(newId)}">Open your copy →</a>`
								: 'Forked to your account.',
							'ok',
						);
						// Bump the visible fork count optimistically.
						const countEl = btn.parentElement?.querySelector('.up-fork-count');
						if (countEl) {
							const n = (parseInt(countEl.dataset.count || '0', 10) || 0) + 1;
							countEl.dataset.count = String(n);
							countEl.textContent = `${formatStat(n)} fork${n === 1 ? '' : 's'}`;
						}
					} catch (err) {
						showToast(esc(err.message || 'Could not fork.'), 'err');
					} finally {
						btn.disabled = false;
						if (label) label.textContent = prev || 'Fork';
					}
				});

				// Fork an agent (clones it into the viewer's account via the
				// marketplace fork endpoint). Only published agents render the button.
				rootEl.addEventListener('click', async (e) => {
					const btn = e.target.closest('.up-agent-fork-btn');
					if (!btn) return;
					e.preventDefault();
					if (!viewer) {
						location.href = `/login?return=${encodeURIComponent('/u/' + user.username)}`;
						return;
					}
					const agentId = btn.dataset.agent;
					btn.disabled = true;
					const label = btn.querySelector('.up-agent-fork-label');
					const prev = label ? label.textContent : '';
					if (label) label.textContent = 'Forking…';
					try {
						const r = await apiFetch(
							`/api/marketplace/agents/${encodeURIComponent(agentId)}/fork`,
							{ method: 'POST', credentials: 'include' },
						);
						const j = await r.json().catch(() => ({}));
						if (!r.ok) throw new Error(j.error_description || j.error || 'Fork failed');
						const newId = j.data?.agent?.id || j.agent?.id || j.id;
						showToast(
							newId
								? `Forked. <a href="/agents/${esc(newId)}">Open your copy →</a>`
								: 'Forked to your account.',
							'ok',
						);
						const countEl = btn.parentElement?.querySelector('.up-fork-count');
						if (countEl) {
							const n = (parseInt(countEl.dataset.count || '0', 10) || 0) + 1;
							countEl.dataset.count = String(n);
							countEl.textContent = `${formatStat(n)} fork${n === 1 ? '' : 's'}`;
						}
					} catch (err) {
						showToast(esc(err.message || 'Could not fork.'), 'err');
					} finally {
						btn.disabled = false;
						if (label) label.textContent = prev || 'Fork';
					}
				});

				// Lazy-load on-chain collectibles (NFTs, accessories, wallets). Kept
				// out of the main payload because the NFT providers are slow + billed;
				// the profile paints first, these fill in after.
				loadCollectibles(rootEl, user, tabBarEl, activateTab);

				// Follow / unfollow
				const followBtn = rootEl.querySelector('#up-follow-btn');
				if (followBtn) {
					followBtn.addEventListener('click', async () => {
						const wasFollowing = followBtn.dataset.following === 'true';
						followBtn.disabled = true;
						try {
							const r = await apiFetch(
								`/api/users/${encodeURIComponent(user.username)}/follow`,
								{ method: wasFollowing ? 'DELETE' : 'POST', credentials: 'include' },
							);
							if (!r.ok) throw new Error('follow failed');
							const j = await r.json();
							const nowFollowing = Boolean(j.following);
							followBtn.dataset.following = String(nowFollowing);
							followBtn.classList.toggle('up-action-btn--following', nowFollowing);
							followBtn.classList.toggle('up-action-btn--primary', !nowFollowing);
							followBtn.querySelector('.up-follow-label').textContent = nowFollowing
								? 'Following'
								: j.followed_by
									? 'Follow back'
									: 'Follow';
							// Reflect the new follower count on the strip.
							const fc = rootEl.querySelector('[data-follows="followers"] .up-stat-num');
							if (fc && typeof j.followers_count === 'number') {
								fc.textContent = formatStat(j.followers_count);
							}
						} catch {
							/* leave button as-is; user can retry */
						} finally {
							followBtn.disabled = false;
						}
					});
				}

				// Edit profile (owner only)
				const editBtn = rootEl.querySelector('#up-edit-btn');
				if (editBtn) editBtn.addEventListener('click', () => openEditModal(user));

				// Followers / following lists
				rootEl.querySelectorAll('[data-follows]').forEach((btn) => {
					btn.addEventListener('click', () =>
						openFollowsModal(user.username, btn.dataset.follows, viewer),
					);
				});

				// Live walking-avatar hero — embodies the owner's primary avatar
				// in a /walk-embed iframe with "Say hi" (real chat) + "Walk with me".
				const walkHeroSlot = rootEl.querySelector('#up-walk-hero');
				if (walkHeroSlot) {
					mountProfileWalkHero(walkHeroSlot, {
						user,
						avatars,
						agents,
						isOwner,
					});
				}
			}

			// ── Edit profile modal ──────────────────────────────────────────────
			function openEditModal(user) {
				const fields = [
					{ key: 'display_name', label: 'Display name', value: user.display_name || '', max: 80 },
					{ key: 'bio', label: 'Bio', value: user.bio || '', max: 280, textarea: true },
					{ key: 'location', label: 'Location', value: user.location || '', max: 80, placeholder: 'Where you are' },
					{ key: 'website', label: 'Website', value: user.website || '', max: 500, placeholder: 'https://…' },
					{ key: 'avatar_url', label: 'Profile picture URL', value: user.avatar_url || '', max: 500, placeholder: 'https://…' },
					{ key: 'banner_url', label: 'Banner image URL', value: user.banner_url || '', max: 500, placeholder: 'https://…' },
				];
				const body = fields
					.map((f) => {
						const inputId = `up-edit-${attr(f.key)}`;
						const counter = f.max
							? `<span class="up-field-count" data-count-for="${attr(f.key)}">${(f.value || '').length}/${f.max}</span>`
							: '';
						const input = f.textarea
							? `<textarea id="${inputId}" name="${attr(f.key)}" maxlength="${f.max}" placeholder="${attr(f.placeholder || '')}">${esc(f.value)}</textarea>`
							: `<input id="${inputId}" name="${attr(f.key)}" type="text" maxlength="${f.max}" value="${attr(f.value)}" placeholder="${attr(f.placeholder || '')}">`;
						return `<div class="up-field"><label for="${inputId}">${esc(f.label)}${counter}</label>${input}</div>`;
					})
					.join('');

				const modal = buildModal('Edit profile', `
					<div class="up-modal-error" id="up-edit-error"></div>
					<form id="up-edit-form">
						${body}
						<div class="up-modal-actions">
							<button type="button" class="up-action-btn" data-close>Cancel</button>
							<button type="submit" class="up-action-btn up-action-btn--primary" id="up-edit-save">Save</button>
						</div>
					</form>
				`);

				// Live char counters
				modal.querySelectorAll('input[maxlength], textarea[maxlength]').forEach((el) => {
					el.addEventListener('input', () => {
						const c = modal.querySelector(`[data-count-for="${el.name}"]`);
						if (c) c.textContent = `${el.value.length}/${el.getAttribute('maxlength')}`;
					});
				});

				const form = modal.querySelector('#up-edit-form');
				const errEl = modal.querySelector('#up-edit-error');
				const saveBtn = modal.querySelector('#up-edit-save');
				form.addEventListener('submit', async (e) => {
					e.preventDefault();
					errEl.textContent = '';
					saveBtn.disabled = true;
					saveBtn.textContent = 'Saving…';
					const payload = {};
					for (const f of fields) {
						payload[f.key] = (form.elements[f.key].value || '').trim();
					}
					try {
						const r = await apiFetch('/api/auth/profile', {
							method: 'PATCH',
							credentials: 'include',
							headers: { 'content-type': 'application/json' },
							body: JSON.stringify(payload),
						});
						const j = await r.json().catch(() => ({}));
						if (!r.ok) {
							errEl.textContent =
								j.error_description || j.issues?.[0]?.message || 'Could not save changes.';
							saveBtn.disabled = false;
							saveBtn.textContent = 'Save';
							return;
						}
						// Reload to reflect the saved profile cleanly.
						location.reload();
					} catch {
						errEl.textContent = 'Network error — try again.';
						saveBtn.disabled = false;
						saveBtn.textContent = 'Save';
					}
				});
			}

			// ── Followers / following modal ─────────────────────────────────────
			async function openFollowsModal(username, type, viewer) {
				const titles = { followers: 'Followers', following: 'Following' };
				const modal = buildModal(
					titles[type] || 'People',
					`<div id="up-follows-list"><p class="up-empty" style="padding:1rem 0">Loading…</p></div>`,
				);
				const listEl = modal.querySelector('#up-follows-list');
				try {
					const r = await fetch(
						`/api/users/${encodeURIComponent(username)}/follows?type=${type}&limit=100`,
						{ credentials: 'include' },
					);
					if (!r.ok) throw new Error(`HTTP ${r.status}`);
					const j = await r.json();
					const users = j.users || [];
					if (!users.length) {
						listEl.innerHTML = `<p class="up-empty" style="padding:1.5rem 0;text-align:center">${
							type === 'followers' ? 'No followers yet.' : 'Not following anyone yet.'
						}</p>`;
						return;
					}
					listEl.innerHTML = users
						.map((u) => {
							const pfp = u.avatar_url
								? `<img loading="lazy" decoding="async" src="${attr(u.avatar_url)}" alt="" referrerpolicy="no-referrer">`
								: '◎';
							const btn =
								viewer && !u.is_self
									? `<button class="up-follow-mini" data-username="${attr(u.username)}" data-following="${u.is_following}">${u.is_following ? 'Following' : 'Follow'}</button>`
									: '';
							return `
								<div class="up-follow-row">
									<a class="up-follow-pfp" href="/u/${attr(u.username)}">${pfp}</a>
									<div class="up-follow-info">
										<a class="up-follow-name" href="/u/${attr(u.username)}">${esc(u.display_name)}</a>
										<div class="up-follow-handle">@${esc(u.username)}</div>
									</div>
									${btn}
								</div>`;
						})
						.join('');

					// In-modal follow toggles
					listEl.querySelectorAll('.up-follow-mini').forEach((b) => {
						b.addEventListener('click', async () => {
							const uname = b.dataset.username;
							const following = b.dataset.following === 'true';
							b.disabled = true;
							try {
								const rr = await apiFetch(
									`/api/users/${encodeURIComponent(uname)}/follow`,
									{ method: following ? 'DELETE' : 'POST', credentials: 'include' },
								);
								if (!rr.ok) throw new Error();
								const jj = await rr.json();
								b.dataset.following = String(jj.following);
								b.textContent = jj.following ? 'Following' : 'Follow';
							} catch {
								/* retry on next click */
							} finally {
								b.disabled = false;
							}
						});
					});
				} catch {
					listEl.innerHTML = `<p class="up-empty" style="padding:1.5rem 0;text-align:center">Could not load list.</p>`;
				}
			}

			// Shared modal scaffold. Returns the modal element (already in the DOM).
			function buildModal(title, innerHtml) {
				document.getElementById('up-modal-backdrop')?.remove();
				const backdrop = document.createElement('div');
				backdrop.className = 'up-modal-backdrop';
				backdrop.id = 'up-modal-backdrop';
				backdrop.setAttribute('role', 'dialog');
				backdrop.setAttribute('aria-modal', 'true');
				backdrop.setAttribute('aria-labelledby', 'up-modal-title');
				backdrop.innerHTML = `
					<div class="up-modal">
						<div class="up-modal-head">
							<h3 id="up-modal-title">${esc(title)}</h3>
							<button class="up-modal-close" aria-label="Close" data-close>×</button>
						</div>
						<div class="up-modal-body">${innerHtml}</div>
					</div>`;
				document.body.appendChild(backdrop);
				const close = () => backdrop.remove();
				backdrop.addEventListener('click', (e) => {
					if (e.target === backdrop || e.target.closest('[data-close]')) close();
				});
				document.addEventListener('keydown', function onKey(e) {
					if (e.key === 'Escape') {
						close();
						document.removeEventListener('keydown', onKey);
					}
				});
				return backdrop;
			}

			function formatStat(n) {
				if (n >= 1_000_000) return (n / 1_000_000).toFixed(1).replace(/\.0$/, '') + 'M';
				if (n >= 1_000) return (n / 1_000).toFixed(1).replace(/\.0$/, '') + 'K';
				return String(n);
			}

			// Transient bottom toast. `kind` ∈ {'', 'ok', 'err'}. HTML allowed for the
			// short "open your copy" link — callers escape any interpolated values.
			let toastTimer;
			function showToast(html, kind = '') {
				document.getElementById('up-toast')?.remove();
				clearTimeout(toastTimer);
				const t = document.createElement('div');
				t.id = 'up-toast';
				t.className = `up-toast${kind ? ' up-toast--' + kind : ''}`;
				t.innerHTML = html;
				document.body.appendChild(t);
				requestAnimationFrame(() => t.classList.add('show'));
				toastTimer = setTimeout(() => {
					t.classList.remove('show');
					setTimeout(() => t.remove(), 250);
				}, 5000);
			}

			// ── Collectibles (lazy) ─────────────────────────────────────────────
			// Fetches /api/users/:username/collectibles after the main paint and
			// fills the Wallets row + NFT/Accessories tabs. Failure is silent — the
			// surfaces just stay absent rather than showing a broken state.
			async function loadCollectibles(rootEl, user, tabBarEl, activateTab) {
				let data;
				try {
					const r = await fetch(
						`/api/users/${encodeURIComponent(user.username)}/collectibles`,
					);
					if (!r.ok) return;
					data = await r.json();
				} catch {
					return;
				}
				const { wallets = [], nfts = [], accessories = [] } = data;

				// Wallets row — chain-tagged chips with copy + explorer.
				const walletsEl = rootEl.querySelector('#up-wallets');
				if (walletsEl && wallets.length) {
					walletsEl.innerHTML = wallets
						.map((w) => {
							const short = `${w.address.slice(0, 4)}…${w.address.slice(-4)}`;
							const label = w.chain === 'solana' ? 'SOL' : 'EVM';
							return `<span class="up-wallet-chip" data-chain="${attr(w.chain)}" title="${attr(w.address)}">
								<span class="up-chain-dot"></span>
								<span class="up-wallet-label">${esc(label)}</span>
								<a href="${attr(w.explorer)}" target="_blank" rel="noopener">${esc(short)}</a>
								<button class="up-wallet-copy" type="button" data-addr="${attr(w.address)}" aria-label="Copy address">
									<svg width="12" height="12" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M10 1H4a2 2 0 0 0-2 2v7h1.5V3a.5.5 0 0 1 .5-.5h6zM12 4H7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h5a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2"/></svg>
								</button>
							</span>`;
						})
						.join('');
					walletsEl.querySelectorAll('.up-wallet-copy').forEach((b) => {
						b.addEventListener('click', async () => {
							try {
								await navigator.clipboard.writeText(b.dataset.addr);
								b.classList.add('copied');
								setTimeout(() => b.classList.remove('copied'), 1200);
							} catch {}
						});
					});
				}

				// NFTs + Accessories tabs are revealed only when non-empty. If the
				// user has no content in the main tabs (no active tab yet), auto-activate
				// the first deferred tab so the content isn't stuck behind a hidden section.
				const hadActiveTab = Boolean(tabBarEl?.querySelector('.up-tab--active'));
				if (nfts.length) {
					rootEl.querySelector('#up-nfts-body').innerHTML = renderNftGrid(nfts);
					addDeferredTab(tabBarEl, 'nfts', 'Collectibles', nfts.length);
					addStat(rootEl, 'NFTs', nfts.length);
					if (!hadActiveTab && activateTab) activateTab('nfts');
				}
				if (accessories.length) {
					rootEl.querySelector('#up-accessories-body').innerHTML =
						renderAccessoriesGrid(accessories);
					addDeferredTab(tabBarEl, 'accessories', 'Accessories', accessories.length);
					addStat(rootEl, 'Accessories', accessories.length);
					// Only auto-activate accessories if NFTs didn't already take the active slot.
					if (!hadActiveTab && !nfts.length && activateTab) activateTab('accessories');
				}
			}

			// Append a tab button to the (initially possibly-hidden) tab bar and
			// reveal the bar once it carries more than one tab.
			function addDeferredTab(tabBarEl, key, label, count) {
				if (!tabBarEl || tabBarEl.querySelector(`[data-tab="${key}"]`)) return;
				const btn = document.createElement('button');
				btn.className = 'up-tab';
				btn.setAttribute('role', 'tab');
				btn.dataset.tab = key;
				btn.setAttribute('aria-selected', 'false');
				btn.innerHTML = `${esc(label)} <span class="up-tab-badge">${count}</span>`;
				tabBarEl.appendChild(btn);
				// Reveal the bar whenever at least one tab exists. The >= 1 threshold
				// handles profiles with no static tabs (no avatars/agents/etc.) that
				// still have on-chain collectibles — without this they get a hidden bar
				// and an unreachable NFT section.
				if (tabBarEl.querySelectorAll('.up-tab').length >= 1) tabBarEl.hidden = false;
				// If this is the ONLY tab in the bar, auto-activate it so the section
				// it points to is shown instead of the default "No avatars" empty state.
				if (tabBarEl.querySelectorAll('.up-tab').length === 1) {
					btn.classList.add('up-tab--active');
					btn.setAttribute('aria-selected', 'true');
					const profileRoot = tabBarEl.closest('#profile-root');
					if (profileRoot) {
						profileRoot.querySelectorAll('.up-section').forEach((s) => {
							s.hidden = s.dataset.section !== key;
						});
					}
				}
			}

			// Append a read-only stat tile to the strip.
			function addStat(rootEl, label, n) {
				const strip = rootEl.querySelector('.up-stats');
				if (!strip) return;
				const tile = document.createElement('div');
				tile.className = 'up-stat';
				tile.innerHTML = `<span class="up-stat-num">${formatStat(n)}</span><span class="up-stat-label">${esc(label)}</span>`;
				strip.appendChild(tile);
			}

			function renderNftGrid(nfts) {
				if (!nfts.length) return `<p class="up-empty">No collectibles found.</p>`;
				const cards = nfts
					.map((n) => {
						const media = n.model
							? `<model-viewer src="${attr(n.model)}" alt="${attr(n.name)}" auto-rotate auto-rotate-delay="0" rotation-per-second="20deg" interaction-prompt="none" camera-controls disable-zoom shadow-intensity="0.4" exposure="0.95" environment-image="neutral" loading="lazy"></model-viewer><span class="up-nft-badge">3D</span>`
							: n.image
								? `<img src="${attr(n.image)}" alt="${attr(n.name)}" loading="lazy" referrerpolicy="no-referrer">`
								: `<div class="up-card-thumb-placeholder">◎</div>`;
						const inner = `
							<div class="up-nft-media">
								<span class="up-nft-chain" data-chain="${attr(n.chain)}" title="${attr(n.chain === 'solana' ? 'Solana' : 'EVM')}"></span>
								${media}
							</div>
							<div class="up-nft-body">
								<p class="up-nft-name" title="${attr(n.name)}">${esc(n.name)}</p>
								${n.collection ? `<p class="up-nft-coll">${esc(n.collection)}</p>` : ''}
							</div>`;
						return n.explorer
							? `<a class="up-nft-card" href="${attr(n.explorer)}" target="_blank" rel="noopener">${inner}</a>`
							: `<div class="up-nft-card">${inner}</div>`;
					})
					.join('');
				return `<div class="up-nft-grid">${cards}</div>`;
			}

			function renderAccessoriesGrid(items) {
				if (!items.length) return `<p class="up-empty">No accessories owned yet.</p>`;
				const cards = items
					.map((a) => {
						const thumb = a.previewImage
							? `<img src="${attr(a.previewImage)}" alt="${attr(a.name)}" loading="lazy">`
							: `<div class="up-acc-thumb-empty">◈</div>`;
						return `
							<div class="up-acc-card">
								<div class="up-acc-thumb">${thumb}</div>
								<div class="up-acc-body">
									<p class="up-acc-name">${esc(a.name)}</p>
									<span class="up-rarity" data-rarity="${attr(a.rarity || 'common')}">${esc(a.rarity || 'common')}</span>
								</div>
							</div>`;
					})
					.join('');
				return `<div class="up-acc-grid">${cards}</div>`;
			}

			function renderAvatarsGrid(avatars) {
				if (!avatars.length) {
					return `<p class="up-empty">No public avatars yet.</p>`;
				}
				const cards = avatars
					.map((a) => {
						const thumb = a.thumbnail_url
							? `<img loading="lazy" decoding="async" src="${attr(a.thumbnail_url)}" alt="${attr(a.name)}" style="width:100%;height:100%;object-fit:cover">`
							: `<div class="up-card-thumb-placeholder">◎</div>`;
						const tags = (a.tags || [])
							.slice(0, 3)
							.map((t) => `<span class="up-tag">#${esc(t)}</span>`)
							.join('');
						const sizeKB = a.size_bytes ? Math.round(a.size_bytes / 1024) : 0;
						const sizeLabel =
							sizeKB >= 1024 ? `${(sizeKB / 1024).toFixed(1)} MB` : `${sizeKB} KB`;
						return `
						<article class="up-card">
							<a href="/avatars/${attr(a.id)}" class="up-card-thumb-link" tabindex="-1" aria-hidden="true">
								<div class="up-card-thumb">${thumb}</div>
							</a>
							<div class="up-card-body">
								<a href="/avatars/${attr(a.id)}" class="up-card-name">${esc(a.name)}</a>
								${a.description ? `<p class="up-card-desc">${esc(a.description)}</p>` : ''}
								<div class="up-card-footer">
									<div>${tags}</div>
									${a.size_bytes ? `<span class="up-card-id">${esc(sizeLabel)}</span>` : ''}
								</div>
								<div class="up-card-actions">
									<button class="up-fork-btn" type="button" data-avatar="${attr(a.id)}" title="Save a copy of this avatar to your account">
										<svg width="11" height="11" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M5 3.25a1.75 1.75 0 1 0-2.5 1.58v6.34A1.75 1.75 0 1 0 5 12.75v-1.06a3 3 0 0 1 3-3h.59a1.75 1.75 0 1 0 0-1.5H8a4.5 4.5 0 0 0-3 1.14V4.83A1.75 1.75 0 0 0 5 3.25"/></svg>
										<span class="up-fork-label">Fork</span>
									</button>
									<span class="up-fork-count" data-count="${a.fork_count || 0}">${a.fork_count ? `${formatStat(a.fork_count)} fork${a.fork_count === 1 ? '' : 's'}` : ''}</span>
								</div>
							</div>
						</article>
					`;
					})
					.join('');
				return `<div class="up-grid">${cards}</div>`;
			}

			function renderAgentsList(agents) {
				if (!agents.length) return `<p class="up-empty">No public agents yet.</p>`;
				const cards = agents
					.map((a) => {
						const img = a.profile_image_url || a.avatar_url;
						const thumb = img
							? `<img loading="lazy" decoding="async" src="${attr(img)}" alt="${attr(a.name)}">`
							: `<span>◎</span>`;
						const meta = [];
						if (a.sns_domain)
							meta.push(
								`<a href="https://www.sns.id/domain?domain=${attr(a.sns_domain)}" target="_blank" rel="noopener">◎ ${esc(a.sns_domain)}</a>`,
							);
						if (a.erc8004_agent_id && a.chain_id)
							meta.push(
								`ERC-8004 #${esc(a.erc8004_agent_id)} · chain ${esc(String(a.chain_id))}`,
							);
						if (a.wallet_address)
							meta.push(
								`${esc(a.wallet_address.slice(0, 6))}…${esc(a.wallet_address.slice(-4))}`,
							);
						if (a.x_username)
							meta.push(
								`<a href="https://x.com/${attr(a.x_username)}" target="_blank" rel="noopener">@${esc(a.x_username)}</a>`,
							);
						if (a.farcaster_fname)
							meta.push(
								`<a href="https://warpcast.com/${attr(a.farcaster_fname)}" target="_blank" rel="noopener">/${esc(a.farcaster_fname)}</a>`,
							);
						// Forkable agents (published) expose a Fork button that clones the
						// agent into the viewer's account. The button sits OUTSIDE the card
						// link so it isn't a nested interactive element.
						const forkBar = a.is_published
							? `<div class="up-agent-fork-bar">
									<button class="up-agent-fork-btn" type="button" data-agent="${attr(a.id)}" title="Fork this agent into your account">
										<svg width="11" height="11" viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M5 3.25a1.75 1.75 0 1 0-2.5 1.58v6.34A1.75 1.75 0 1 0 5 12.75v-1.06a3 3 0 0 1 3-3h.59a1.75 1.75 0 1 0 0-1.5H8a4.5 4.5 0 0 0-3 1.14V4.83A1.75 1.75 0 0 0 5 3.25"/></svg>
										<span class="up-agent-fork-label">Fork</span>
									</button>
									<span class="up-fork-count" data-count="${a.forks_count || 0}">${a.forks_count ? `${formatStat(a.forks_count)} fork${a.forks_count === 1 ? '' : 's'}` : ''}</span>
									${a.is_fork ? '<span class="up-tag">forked</span>' : ''}
								</div>`
							: a.is_fork
								? `<div class="up-agent-fork-bar"><span class="up-tag">forked</span></div>`
								: '';
						return `
						<div class="up-card-row-wrap">
							<a class="up-card-row" href="/agents/${attr(a.id)}">
								<div class="up-card-row-thumb">${thumb}</div>
								<div class="up-card-row-body">
									<div class="up-card-row-head">
										<h3 class="up-card-row-name">${esc(a.name)}</h3>
										${onchainBadgeHTML(a, { link: false })}
									</div>
									${a.description ? `<p class="up-card-row-desc">${esc(a.description)}</p>` : ''}
									${meta.length ? `<div class="up-card-row-meta">${meta.map((m) => `<span>${m}</span>`).join('')}</div>` : ''}
								</div>
							</a>
							${forkBar}
						</div>
					`;
					})
					.join('');
				return `<div class="up-list up-list-cols-2">${cards}</div>`;
			}

			function renderWidgetsList(widgets) {
				if (!widgets.length)
					return `<p class="up-empty">No public widgets yet. <a href="/widgets">Build one →</a></p>`;
				const typeIcons = {
					turntable: '◐',
					'animation-gallery': '▶',
					'talking-agent': '💬',
					passport: '◉',
					'hotspot-tour': '⊙',
				};
				const cards = widgets
					.map((w) => {
						const icon = typeIcons[w.type] || '◎';
						return `
						<a class="up-card-row" href="/w/${attr(w.id)}">
							<div class="up-card-row-thumb">${icon}</div>
							<div class="up-card-row-body">
								<div class="up-card-row-head">
									<h3 class="up-card-row-name">${esc(w.name)}</h3>
									<span class="up-card-row-pill">${esc(w.type)}</span>
								</div>
								<div class="up-card-row-meta">
									<span>${formatStat(w.view_count)} view${w.view_count === 1 ? '' : 's'}</span>
									<span>${esc(w.id)}</span>
								</div>
							</div>
						</a>
					`;
					})
					.join('');
				return `<div class="up-list up-list-cols-2">${cards}</div>`;
			}

			function renderSkillsList(skills) {
				if (!skills.length) return `<p class="up-empty">No published skills yet.</p>`;
				const cards = skills
					.map((s) => {
						const tags = (s.tags || [])
							.slice(0, 3)
							.map((t) => `<span class="up-tag">#${esc(t)}</span>`)
							.join('');
						const price =
							s.price_per_call_usd > 0
								? `$${Number(s.price_per_call_usd).toFixed(4)}/call`
								: 'free';
						return `
						<a class="up-card-row" href="/marketplace#${attr(s.slug)}">
							<div class="up-card-row-thumb">⚡</div>
							<div class="up-card-row-body">
								<div class="up-card-row-head">
									<h3 class="up-card-row-name">${esc(s.name)}</h3>
									<span class="up-card-row-pill">${esc(s.category)}</span>
								</div>
								${s.description ? `<p class="up-card-row-desc">${esc(s.description)}</p>` : ''}
								<div class="up-card-row-meta">
									<span>${esc(price)}</span>
									<span>${formatStat(s.install_count)} install${s.install_count === 1 ? '' : 's'}</span>
									${tags ? `<span>${tags}</span>` : ''}
								</div>
							</div>
						</a>
					`;
					})
					.join('');
				return `<div class="up-list up-list-cols-2">${cards}</div>`;
			}

			function renderPluginsList(plugins) {
				if (!plugins.length) return `<p class="up-empty">No published plugins yet.</p>`;
				const cards = plugins
					.map((p) => {
						const rating =
							p.rating_count > 0
								? `★ ${Number(p.avg_rating).toFixed(1)} (${p.rating_count})`
								: 'unrated';
						return `
						<div class="up-card-row">
							<div class="up-card-row-thumb">◈</div>
							<div class="up-card-row-body">
								<div class="up-card-row-head">
									<h3 class="up-card-row-name">${esc(p.name)}</h3>
									<span class="up-card-row-pill">${esc(p.category)}</span>
								</div>
								${p.description ? `<p class="up-card-row-desc">${esc(p.description)}</p>` : ''}
								<div class="up-card-row-meta">
									<span>${esc(p.identifier)}</span>
									<span>${formatStat(p.install_count)} install${p.install_count === 1 ? '' : 's'}</span>
									<span>${esc(rating)}</span>
								</div>
							</div>
						</div>
					`;
					})
					.join('');
				return `<div class="up-list up-list-cols-2">${cards}</div>`;
			}

			function renderCoinsGrid(coins) {
				if (!coins.length) return `<p class="up-empty">No coins launched yet.</p>`;
				const cards = coins
					.map((c) => {
						const thumb = c.image
							? `<img loading="lazy" decoding="async" src="${attr(c.image)}" alt="${attr(c.name)}" style="width:100%;height:100%;object-fit:cover" referrerpolicy="no-referrer">`
							: `<div class="up-card-thumb-placeholder">◎</div>`;
						const symbol = c.symbol
							? `<span class="up-card-chain">$${esc(c.symbol.replace(/^\$/, ''))}</span>`
							: '';
						const devnet =
							c.cluster && c.cluster !== 'mainnet'
								? `<span class="up-card-id">${esc(c.cluster)}</span>`
								: '';
						const inner = `
						<div class="up-card-thumb">${thumb}</div>
						<div class="up-card-body">
							${symbol}
							<span class="up-card-name">${esc(c.name)}</span>
							${c.description ? `<p class="up-card-desc">${esc(c.description)}</p>` : ''}
							<div class="up-card-footer">
								<span class="up-card-id" title="${attr(c.mint)}">${esc(c.mint.slice(0, 4))}…${esc(c.mint.slice(-4))}</span>
								${devnet}
							</div>
						</div>`;
						// Link out to the live coin page when present; otherwise fall back to
						// the launching agent so the card is never a dead end.
						return c.url
							? `<a class="up-card" href="${attr(c.url)}" target="_blank" rel="noopener" style="text-decoration:none">${inner}</a>`
							: `<a class="up-card" href="/agents/${attr(c.agent_id)}" style="text-decoration:none">${inner}</a>`;
					})
					.join('');
				return `<div class="up-grid">${cards}</div>`;
			}

			// Forged 3D models + saved worlds (dioramas) — the "Creations" tab.
			// Merged, recency-ordered feed from /api/users/:username (first page)
			// with a "Load more" button that pages through GET
			// /api/users/:username/creations (cursor by created_at) for creators
			// with 100+ items. Each card is a real, live 3D thumbnail (glb model
			// for a forged mesh; the same for a world's first forged object) that
			// deep-links to the actual viewer -- never a static screenshot.
			function creationCardHtml(c) {
				const thumb = c.thumbnailUrl
					? `<model-viewer src="${attr(c.thumbnailUrl)}" loading="lazy" reveal="auto" ` +
						`auto-rotate rotation-per-second="16deg" interaction-prompt="none" disable-zoom ` +
						`camera-orbit="35deg 78deg auto" shadow-intensity="0" exposure="0.9" ` +
						`style="width:100%;height:100%;pointer-events:none;--poster-color:transparent" ` +
						`aria-hidden="true"></model-viewer>`
					: `<div class="up-card-thumb-placeholder">${c.type === 'world' ? '⛰' : c.type === 'restyle' ? '✦' : '◎'}</div>`;
				const badge = c.type === 'world' ? 'World' : c.type === 'restyle' ? 'Restyle' : 'Model';
				const date = c.createdAt
					? new Date(c.createdAt).toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' })
					: '';
				// The card stays one big anchor; the prompt action floats above it
				// (sibling + z-index, same pattern as the forge showcase) so the
				// markup never nests interactive elements.
				const promptBtn = c.prompt
					? `<button type="button" class="up-copy-prompt" data-copy-prompt="${attr(c.prompt)}" ` +
						`title="Copy the prompt that made this" aria-label="Copy generation prompt">⧉ prompt</button>`
					: '';
				return `
					<div class="up-card-wrap">
						<a class="up-card" href="${attr(c.viewerUrl)}" style="text-decoration:none">
							<div class="up-card-thumb">${thumb}</div>
							<div class="up-card-body">
								<span class="up-card-chain">${esc(badge)}${c.category ? ` · ${esc(c.category)}` : ''}</span>
								<span class="up-card-name">${esc((c.title || 'Untitled').slice(0, 80))}</span>
								<div class="up-card-footer">
									<span class="up-card-id">${esc(date)}</span>
									${c.isRemix ? `<span class="up-tag">remix</span>` : ''}
								</div>
							</div>
						</a>
						${promptBtn}
					</div>
				`;
			}

			function renderCreationsGrid(creations) {
				if (!creations.length) {
					return `<p class="up-empty">No creations yet. <a href="/create">Forge your first model →</a></p>`;
				}
				return `<div class="up-grid" id="up-creations-grid">${creations.map(creationCardHtml).join('')}</div>
					<div class="up-load-more-row" id="up-creations-more-row" style="text-align:center;margin-top:1.2rem"></div>`;
			}

			// Wires the "Load more" button once the Creations section is in the
			// DOM. Idempotent: safe to call every time the tab renders since the
			// button element is (re)created fresh in renderCreationsGrid.
			function wireCreationsPagination(rootEl, username, initialNext) {
				const row = rootEl.querySelector('#up-creations-more-row');
				const grid = rootEl.querySelector('#up-creations-grid');
				if (!row || !grid) return;
				let cursor = initialNext;
				if (!cursor) return;
				const renderMoreBtn = () => {
					row.innerHTML = `<button type="button" class="up-action-btn" id="up-creations-load-more">Load more</button>`;
					row.querySelector('#up-creations-load-more')?.addEventListener('click', loadMore, { once: true });
				};
				async function loadMore() {
					row.innerHTML = `<span class="up-empty" style="display:inline">Loading…</span>`;
					try {
						const r = await fetch(
							`/api/users/${encodeURIComponent(username)}/creations?before=${encodeURIComponent(cursor)}`,
						);
						const j = await r.json().catch(() => ({}));
						const items = j.items || [];
						grid.insertAdjacentHTML('beforeend', items.map(creationCardHtml).join(''));
						cursor = j.next || null;
						if (cursor) renderMoreBtn();
						else row.innerHTML = '';
					} catch {
						row.innerHTML = `<button type="button" class="up-action-btn" id="up-creations-load-more">Retry</button>`;
						row.querySelector('#up-creations-load-more')?.addEventListener('click', loadMore, { once: true });
					}
				}
				renderMoreBtn();
			}

			// Items the user actively lists for sale (asset_prices). Each card deep
			// links to the item's own page, where the existing purchase flow lives —
			// the profile never duplicates checkout.
			function renderShopGrid(shop) {
				if (!shop.length) {
					return `<p class="up-empty">Nothing for sale yet. <a href="/marketplace">Visit the marketplace →</a></p>`;
				}
				const glyphs = { avatar: '◎', agent: '◆', plugin: '◈' };
				const fmtPrice = (n) => {
					if (!Number.isFinite(n)) return '0';
					const s = n.toFixed(n < 1 ? 4 : 2);
					return s.replace(/\.?0+$/, '');
				};
				const cards = shop
					.map((s) => {
						const thumb = s.image
							? `<img loading="lazy" decoding="async" src="${attr(s.image)}" alt="${attr(s.name)}" style="width:100%;height:100%;object-fit:cover" referrerpolicy="no-referrer">`
							: `<div class="up-card-thumb-placeholder">${glyphs[s.item_type] || '◎'}</div>`;
						const priceLabel = `${fmtPrice(s.price)} ${esc(s.currency || '')}`.trim();
						return `
						<a class="up-card" href="${attr(s.href)}" style="text-decoration:none">
							<div class="up-card-thumb">${thumb}</div>
							<div class="up-card-body">
								<span class="up-card-chain">${esc(s.item_type)}</span>
								<span class="up-card-name">${esc(s.name)}</span>
								<div class="up-card-footer">
									<span class="up-card-row-pill">${priceLabel}</span>
									<span class="up-card-edit">Buy →</span>
								</div>
							</div>
						</a>
					`;
					})
					.join('');
				return `<div class="up-grid">${cards}</div>`;
			}

			function renderMemoriesList(memories) {
				if (!memories.length) return `<p class="up-empty">No public memories yet.</p>`;
				const cards = memories
					.map((m) => {
						const tags = (m.tags || [])
							.slice(0, 4)
							.map((t) => `<span class="up-tag">#${esc(t)}</span>`)
							.join('');
						const when = m.created_at
							? new Date(m.created_at).toLocaleDateString(undefined, {
									month: 'short',
									day: 'numeric',
									year: 'numeric',
								})
							: '';
						const agent = m.agent_name
							? `<a href="/agents/${attr(m.agent_id)}">${esc(m.agent_name)}</a>`
							: '';
						return `
						<div class="up-card-row">
							<div class="up-card-row-thumb">◇</div>
							<div class="up-card-row-body">
								<div class="up-card-row-head">
									<span class="up-card-row-pill">${esc(m.type)}</span>
								</div>
								<p class="up-card-row-desc" style="-webkit-line-clamp:4">${esc(m.content)}</p>
								<div class="up-card-row-meta">
									${agent ? `<span>${agent}</span>` : ''}
									${when ? `<span>${esc(when)}</span>` : ''}
									${tags ? `<span>${tags}</span>` : ''}
								</div>
							</div>
						</div>
					`;
					})
					.join('');
				return `<div class="up-list up-list-cols-2">${cards}</div>`;
			}

			// ── Social share ────────────────────────────────────────────────────
			// Toggle a small menu: native share (where supported), share to X, and
			// copy link. The menu is built lazily off the live document title/URL so
			// it reflects whichever profile finished rendering.
			function buildShareMenu() {
				const url = location.href;
				const title = document.title.replace(/ — three\.ws$/, '');
				const xText = `${title} on three.ws`;
				const xUrl = `https://x.com/intent/tweet?text=${encodeURIComponent(xText)}&url=${encodeURIComponent(url)}`;
				const canNativeShare = typeof navigator.share === 'function';
				shareMenu.innerHTML = `
					${
						canNativeShare
							? `<button class="profile-share-item" data-share="native" role="menuitem">
								<svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M11 5.5a2.5 2.5 0 1 0-2.45-3L5.9 4.06a2.5 2.5 0 1 0 0 3.88l2.65 1.56A2.5 2.5 0 1 0 11 7.5a2.49 2.49 0 0 0-1.6.58L6.95 6.56a2.5 2.5 0 0 0 0-1.12L9.4 4.92A2.49 2.49 0 0 0 11 5.5"/></svg>
								Share…
							</button>`
							: ''
					}
					<a class="profile-share-item" href="${attr(xUrl)}" target="_blank" rel="noopener" role="menuitem">
						<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
						Share to X
					</a>
					<button class="profile-share-item" data-share="copy" role="menuitem">
						<svg viewBox="0 0 16 16" aria-hidden="true"><path fill="currentColor" d="M10 1H4a2 2 0 0 0-2 2v7h1.5V3a.5.5 0 0 1 .5-.5h6zM12 4H7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h5a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2"/></svg>
						<span data-copy-label>Copy link</span>
					</button>
				`;
				shareMenu.querySelector('[data-share="native"]')?.addEventListener('click', async () => {
					closeShareMenu();
					try {
						await navigator.share({ title, url });
					} catch {}
				});
				shareMenu.querySelector('[data-share="copy"]')?.addEventListener('click', async (e) => {
					const lbl = e.currentTarget.querySelector('[data-copy-label]');
					try {
						await navigator.clipboard.writeText(url);
						if (lbl) lbl.textContent = 'Copied ✓';
						setTimeout(() => {
							if (lbl) lbl.textContent = 'Copy link';
							closeShareMenu();
						}, 1100);
					} catch {}
				});
			}
			function openShareMenu() {
				buildShareMenu();
				shareMenu.hidden = false;
				shareBtn.setAttribute('aria-expanded', 'true');
				setTimeout(() => document.addEventListener('click', onDocClick), 0);
			}
			function closeShareMenu() {
				shareMenu.hidden = true;
				shareBtn.setAttribute('aria-expanded', 'false');
				document.removeEventListener('click', onDocClick);
			}
			function onDocClick(e) {
				if (!e.target.closest('.profile-share-wrap')) closeShareMenu();
			}
			shareBtn.addEventListener('click', (e) => {
				e.stopPropagation();
				if (shareMenu.hidden) openShareMenu();
				else closeShareMenu();
			});
			document.addEventListener('keydown', (e) => {
				if (e.key === 'Escape' && !shareMenu.hidden) closeShareMenu();
			});
		</script>
		<script src="/brand.js" defer></script>
		<div id="footer-container"></div>
		<script src="/footer.js"></script>
		<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
	<script type="module" src="/i18n.js"></script>
</body>
</html>